I see there is the following openInfoWindow(wpgmza_markerid,wpgmza_mapid,true); but I read that it is perhaps no longer supported? This looks to be what I need.
Hi @logicred,
Thank you for getting in touch, we do appreciate your time.
Although we do support some types of links on a map page, in this case you would probably be better off with a custom JavaScript function that meets your needs a bit closer.
I would firstly recommend setting up your links using data-attributes, as this can might be more modular for adding new links in the future:
<a href="#" class="wpgmza-button-relay" data-lat="51.5286416" data-lng="-0.1015987" data-zoom="12">
London
</a>
With this in place, you should be able to add the following custom JavaScript to your site to action these links:
jQuery(function($){
$(document.body).on('click', '.wpgmza-button-relay', function(event){
event.preventDefault();
const lat = $(this).data('lat');
const lng = $(this).data('lng');
const zoom = $(this).data('zoom');
if(lat && lng){
WPGMZA.maps[0].setCenter({lat: lat, lng: lng});
}
if(zoom){
WPGMZA.maps[0].setZoom(zoom);
}
});
});
This can be added to the plugins custom JavaScript area, or within a custom JavaScript file if preferred.
I hope this helps?
Thanks Dylan! Works perfectly! Could I do the same thing, but pass the function a marked ID (instead of the Lat/Long cords) and it zooms to that?
Thank you
Hi @logicred,
Only a pleasure!
Yes, you could use a Marker ID instead, as an example the following HTML:
<a href="#" class="wpgmza-button-relay" data-marker="1">
London
</a>
Could then be handled with this JavaScript:
jQuery(function($){
$(document.body).on('click', '.wpgmza-button-relay', function(event){
event.preventDefault();
const marker = $(this).data('marker');
if(marker){
WPGMZA.maps[0].getMarkerByID(marker).onSelect();
}
});
});
I hope this helps?