Custom Fields
Re-Envisioned
Support Meta Box Geolocation Static Map Image (and/or watching for Geo changes)

This topic contains 1 reply, has 1 voice, and was last updated by  brandonjp 1 week, 3 days ago.

  • Creator
    Topic
  • #16784
    Resolved
    brandonjp
    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.

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #16796

    brandonjp
    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 1 replies (of 1 total)

You must be logged in to reply to this topic.