Static Map Image (and/or watching for Geo changes)

Support MB Geolocation Static Map Image (and/or watching for Geo changes)Resolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #16784
    brandonjpbrandonjp
    Participant

    I really love the Geo and Maps fields. There are a few places where showing the full interactive map is overkill, but we would still like to show the location on a map if the user selects/enters an address in the autocomplete field.

    Any suggestions on how to watch for a user to select a new address from the autocomplete? Like what js events the MB Map is using? -- Basically I'm wanting to mimic the behavior of the MB Google Map field, but only show a static image map instead of the full interactive map.

    I've tried watching for change events on the autocomplete address field and a number of other fields (like formatted_address etc) but change events don't seem to be recognized. And I've been reading through the Google Maps API docs, but getting a little lost. So far, I'm able to display a static image when a user is editing a post by using the previous address entry & a static map src such as:
    https://maps.googleapis.com/maps/api/staticmap?center=ADDRESS&zoom=14&scale=1&size=400x400&maptype=hybrid&key=API_KEY&format=png&visual_refresh=true&markers=size:mid%7Ccolor:0xff0000%7Clabel:%7CADDRESS - But I'd like to refresh my image when the user selects a new address.

    #16796
    brandonjpbrandonjp
    Participant

    This topic can be marked ✅Resolved

    I tracked down that I can watch the address input field for selected_address event:

    jQuery('input#address_job_site').on('selected_address', function(event) {
      // do stuff
    });
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.