Reply To: geocoding

Home Forums MapPress Support geocoding Reply To: geocoding



    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:

    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);