Skip to content

Instantly share code, notes, and snippets.

@DylanCodeCabin
Created February 21, 2023 05:34
Show Gist options
  • Save DylanCodeCabin/07d27be0f719526d78ed9f0206aa0bcf to your computer and use it in GitHub Desktop.
Save DylanCodeCabin/07d27be0f719526d78ed9f0206aa0bcf to your computer and use it in GitHub Desktop.
jQuery(function($){
$(document.body).on('markersplaced.wpgmza', () => {
const titleQuery = WPGMZA.getQueryParamValue('qtitle');
const zoomQuery = WPGMZA.getQueryParamValue('qzoom');
if(titleQuery){
const map = WPGMZA.maps[0];
const markers = map.markers;
let matchFound = false;
for(let marker of markers){
if(matchFound){ continue; }
if(marker.title.toLowerCase().trim() === titleQuery.toLowerCase().trim()){
map.setZoom(zoomQuery ? parseInt(zoomQuery) : 16);
marker.trigger('select');
map.setCenter(marker.getPosition());
}
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment