Support

Account

Home Forums Bug Reports Google Map location marker snapping to nearest road

Solving

Google Map location marker snapping to nearest road

  • Since updating to ACF Pro Version 5.8.6, the backend map location marker cannot be manually dragged into place. Instead it snaps to the nearest road / address.

    In my use case we’ve been marking places of interest in the countryside, but the location marker is then snapping to the nearest road.

  • We’re seeing the same issue where our custom ‘countryside’ pins can no longer be placed as such and the pin will snap to the nearest road or point of interest.

    We have come up with a fix for it, but it would be ideal if ACF could acknowledge if this is indeed a bug or a feature we need to now workaround?

    • Theo LG

    • November 6, 2019 at 7:35 pm

    We have the same issue, we create maps with pointers that need to be geolocated precisely.

    Is there an option to disable this feature ?

    @adammontague : Can you share your fix?

    Thanks,

  • Load the following script in your admin.

    var hm_googlemap = null;
    
    if (eval("typeof acf") != undefined) {
      console.log('ACF IS HERE!');  
      
      acf.addAction('google_map_init', function(map, marker, field) {
        hm_googlemap = map;
    
        //Override the searchPosition function on the 
        //map ACF Field which normally does a geocode search
        field.__proto__.searchPosition = function(lat, lng) {	      
          var zoom = (hm_googlemap !== null) ? hm_googlemap.zoom : 15;
          var val = {
            address: "Custom Location: (" + lat + ", " + lng + ")",
            lat: lat,
            lng: lng,
            zoom: zoom,
            country: "", 
            country_short: "", 
            place_id: "",
            post_code: "", 
            state: "", 
            street_name: "", 
            street_name_short: "",
          };
          
    //console.log(val);
    	  this.val(val);				
        };    
      });  
    }
    • Theo LG

    • November 7, 2019 at 12:13 am

    Works like a charm, Thanks,

  • Had the same problem and the script above fixed it, but this does feel like a bug introduced by the latest update.

  • Thank you @adammontague, this solves the problem, though it would be good to know when the bug will be patched. I presume this is a bug rather than a feature because of the many ways in which people use the Google Maps field. I’d be surprised if the functionality was deliberately limited without consultation.

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.