Save PHP generated Map

Home Forums MapPress Support Save PHP generated Map

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #13936
    hawkesley
    Participant

      I am using Mapress Pro and would like to save a Map generated from php code as per the documentation.
      Is this possible in principle and if so can you provide any guidance.
      Thanks
      <?php
      $mymap = new Mappress_Map(array(“width” => 425, ‘height’ => 350));
      $address = “An Address”;
      $mypoi_1 = new Mappress_Poi(array(“address” => $address ));
      $mypoi_1->geocode(); // Works for me
      $mymap->pois = array($mypoi_1);
      echo $mymap->display();

      ?>

      #13943
      Chris
      Keymaster

        Hi,

        Sorry, I don’t understand the question. Are you asking how to save a map you generated? If so, it’s possible to save a map to a post. But it’s usually easier to just generate the map from custom fields in the post (or edit it there manually).

        #13947
        hawkesley
        Participant

          HiChris,
          Thanks for coming back. Yes I want to save the map I generated.
          I am not using posts directly in my application, but I am entering data to generate the map (address) in the front end through Gravity forms.
          For each address I want to save a Map and later display selected content.
          I hope thats a bit clearer.

          #13956
          Chris
          Keymaster

            Hi,

            MapPress requires that each map be associated with a post. But I think Gravity Forms will automatically generate a post on the backend with the data you enter, is that correct?

            I think they also save the entered data as custom fields.

            If so, you can use the MapPress ‘geocoding’ settings to generate the map in that post from those custom field values. For example if your form includes a field ‘address’ then use that field in the geocoding settings.

            I’d suggest configuring geocoding and creating a post manually from the custom field(s) to test that it’s working. Then try sending in the same fields from GF to generate it.

            There’s some additional information on setting up geocoding in the documentation.

            #13957
            hawkesley
            Participant

              Thanks Chris,
              I will try that approach.Custom Fields can only be a single entry not multiple fields in GF from what I understand so I am hoping that a Uk postcode (in my case) will suffice to generate the map.

              #13964
              hawkesley
              Participant

                Hi Chris,
                Just to say the approach with custom fields works.
                I created custom fields in the GF submission form for Post Code entry and a post and map are created and stored in the database.
                I now need to associate the map id with the post code so I wondering if it is possible to save the post code (and maybe other custom fields) with the map id either in the maps table or in a new table.
                Would you have a view on this?
                Thanks

                #13965
                hawkesley
                Participant

                  Just to add it should be useful to capture the map id when the poi is created from the custom field.Is it this function and if so where is it called?function create_meta_map($postid)
                  I am trying to understand how the gravity form post data is captured from the map press geocode options.

                  #13971
                  Chris
                  Keymaster

                    This may help:

                    • When the post is saved, MapPress reads the custom field values and generates the map.
                    • The map is saved in table ‘mappress_maps’ and its relationship of the map ID to the post ID is saved in table ‘mappress_posts’.
                    • There are some functions in file ‘mappress_map.php’ that can be used to read maps or lists of maps.
                  Viewing 8 posts - 1 through 8 (of 8 total)
                  • You must be logged in to reply to this topic.