Support

Account

Home Forums General Issues How To Trigger Google Maps Marker From Select DropDown Reply To: How To Trigger Google Maps Marker From Select DropDown

  • Hey,

    You need to have your select option values correspond to the markers index key (0,1,2,3) etc.

    As you can see in the script you linked there’s a global variable gmarkers that you need to push each marker into and then use to target the appropriate marker with your trigger.

    So in essence:

    1. Create a global variable (array).
    2. Push each new created marker into this array.
    3. Loop through each location to create your select options and give them the value of their key (0,1,2 etc) in a foreach loop foreach( $markers as $key => $marker ).
    4. When user selects a value from the dropdown, take the value and trigger the click event on the marker in the global array with the same index key.

    The example you sent is pretty much exactly what you need.. you just need to add these things to the ACF example code instead.