geocoding

Home Forums MapPress Support geocoding

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #12495
    p36p
    Participant

      Hi Chris I have two questions :

      – The content is geocoded, It’s gecoded forever right ? it’s not geocoded every time I search it ?

      – Is it possible to auto fill a custom field LATITUDE and LONGITUDE from the automattic map generated from adress/Zip/city custom field ?

      Thank you very much for your answers

      #12507
      Chris
      Keymaster

        Hi,

        The map is created and saved in the database so it doesn’t need to be geocoded on each request.  This makes things much faster (geocoding can take 1 sec) and also helps to avoid Google’s per-day geocoding limits.

        You can write the lat/lng values to a custom field by hooking into the ‘save’ action.  I haven’t tested it, but code like this should write the first poi lat/lng to custom fields:

        <?php 
        function myaction($map) {
         global $post;
         $first_poi = isset($map->pois[0]) ? $map->pois[0] : null;
         if ($first_poi) {
           $lat = $poi->point['lat'];
          $lng = $poi->point['lng'];
          update_post_meta($post->ID, 'mylat', $lat);
          update_post_meta($post->ID, 'mylng', $lat);
         }
        }
        add_action('mappress_map_save', 'myaction', 10, 2);
        ?>
      Viewing 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.