Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Customize the map's marker behavior on the homepage
function customizeHomepageMapMarkerBehavior(){
if($('body.home').length > 0 && typeof WPGMZA !== 'undefined'){
$(WPGMZA.maps).each(function(){
$(this.markers).each(function(){
// Clear out previous googleMarker listener events
google.maps.event.clearListeners(this.googleMarker, 'mouseover');
google.maps.event.clearListeners(this.googleMarker, 'click');
// Create our own marker event listeners (note: `this.googleMarker` is for the Google Maps Marker itself while `this` is the WPGM marker [includes title & other info])
google.maps.event.addListener(this.googleMarker, 'mouseover', function(event) {
$('.location-details .group').hide(); // Hide the current community
$('.location-details .group h4:contains("'+this.title+'")').closest('.group').show(); // Show the appropriate community
$('.location-details select option').removeAttr('selected').filter(':contains("'+this.title+'")').prop('selected', true); // Set the selector to the correct community
});
google.maps.event.addListener(this.googleMarker, 'click', function(event) {
window.location.href = this.link; // Follow marker's link URL when clicked
});
});
});
}
}
customizeHomepageMapMarkerBehavior();
setTimeout(function(){customizeHomepageMapMarkerBehavior();},500);
setTimeout(function(){customizeHomepageMapMarkerBehavior();},1000);
setTimeout(function(){customizeHomepageMapMarkerBehavior();},2000);
setTimeout(function(){customizeHomepageMapMarkerBehavior();},5000);
setTimeout(function(){customizeHomepageMapMarkerBehavior();},10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.