Home Forums Backend Issues (wp-admin) Upgrade to use Google Maps field type


Upgrade to use Google Maps field type

  • Hello,

    I’m working on a website which was originally created by another developer. A while ago, I was tasked with updating all plugins on the site and upgrading WordPress to 3.8. This all went fine and everything still functioned properly after the updates (after a few tweaks). However, I have just noticed that a custom field called network_location can no longer be updated from the backend. I presume this is because the previous developer used a plugin called Advanced Custom Fields Location addon, which if I understand correctly has now been replaced with the Google Maps field in the core of ACF.

    I have searched around but I couldn’t find a guide or advice on how to convert from a location field to a Google Maps field. I tried changing the field type in Custom Fields (at the moment it says “Error Field type does not exist”) to Google Maps, but then when I edit a post using the network_location field, none of the old data is shown and the map just shows the default Melbourne area.

    So My question is, how can I import the previously entered latitude and longitude values provided with the Advanced Custom Fields Location plugin into the new Google Maps field?

    When I look at the code on the front end for displaying the lat/long, it reads like this:

    $longlat = get_post_meta($network->ID, 'network_location', true); // for some reason acf shorthand fails						
    						$ll = explode(";", $longlat);												
    						$return_points['markers'][] = array('id' => $network->ID, 'latitude' => $ll[0], 'longitude' => $ll[1], 'title' => $network->post_title, 'content' => $content);

    So that looks like latitude and longitude are stored side by side, separated by a ; .

    Surely I can’t be the only user this has happened to, what are my options?


  • So I have done some checking and when I convert the field to a text field, the values are shown like this:


    so the format is Latitude;Longitude.

    I checked and with the Google Maps field option, the data is stored like this:

    a:3:{s:7:”address”;s:7:”CV3 2TX”;s:3:”lat”;s:10:”52.4022271″;s:3:”lng”;s:17:”-1.44103999999993″;}

    I have post codes for all of the locations, so is there a way of running a converter like script that will format the lat;long values in a way that makes them readable by the new Google Maps field?



  • Just ran across the same issue, bump!

  • Same problem here, is there any kind of “migrate fields/values” plugin that you guys know, I’m trying to find it but without any success

  • I had a reply from Michael De Wildt a while ago but I haven’t had time to try and fix this.

    Now that there are 3 people asking I might send another support request.

  • I’m looking for the exact same thing. Any progress on this?

  • Also looking for a fix for this!

  • Hi, is there any updates on this one? I also need to migrate to the new Google Map field type.

  • I wanted to migrate a website with > 1600 geotagged posts to ACF PRO, but this is keeping me from doing so. Will / can this be fixed in the near future?

  • I also have a site with thousands of posts using the old version which I would love to upgrade – did anyone figure out a way of doing this?

  • I closely read the update_field() documentation and built a template that pulls the old content into the new fields.

    Looked something like this, this is inside the loop:

    // switch on "show field keys", see
    $field_key = "field_somethingrandom"; //this is the new field
    $post_id = get_the_ID();
    // the $address, $latitude, $longitude values come from the old fields
    $value = array(
    "address" => $address,
    "lat" => $latitude,
    "lng" => $longitude
    update_field( $field_key, $value, $post_id );

    Be sure to back up your database, this can mess up your data.

  • Hi Florian,

    Thanks very much for sharing your code. I’ll give that a try today.

    To ACF: I think its quite bad support that after 13 months and almost 10 other users (some of whom are paid subscribers) there has been no official reply to this topic.

  • Paid subscribers can also email support. That’s what I did and what led me to this solution.

  • Yeah I did too but I couldn’t work out how to do it from the information given. Now you’ve given some example code and explained it a bit better I’m sure it will be fine. Thanks again for sharing, I always try to do the same.

Viewing 14 posts - 1 through 14 (of 14 total)

The topic ‘Upgrade to use Google Maps field type’ is closed to new replies.