Created
May 11, 2022 13:48
-
-
Save DylanCodeCabin/5f15d5a79234cfd09a87f221fa30c84c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Overrides the scroll functionality on marker listings | |
*/ | |
jQuery(function($){ | |
WPGMZA.MarkerListing.prototype.onItemClick = function(event) { | |
var marker_id = $(event.currentTarget).attr("mid"); | |
var marker = this.map.getMarkerByID(marker_id); | |
var listingPushedInMap = WPGMZA.maps[0].settings.push_in_map && WPGMZA.maps[0].settings.push_in_map.length; | |
var clickedGetDirections = $(event.target).hasClass("wpgmza_gd"); | |
var zoomLevelOnClick = 13; | |
marker.trigger("select"); | |
if(this.style != WPGMZA.MarkerListing.STYLE_MODERN && | |
!WPGMZA.settings.disable_scroll_on_marker_listing_click && | |
!clickedGetDirections && | |
!listingPushedInMap) | |
{ | |
var offset = 0; | |
if(WPGMZA.settings.marker_listing_item_click_scroll_offset) | |
offset = parseInt(WPGMZA.settings.marker_listing_item_click_scroll_offset); | |
} | |
if(this.map.settings.zoom_level_on_marker_listing_override && this.map.settings.zoom_level_on_marker_listing_click){ | |
zoomLevelOnClick = this.map.settings.zoom_level_on_marker_listing_click; | |
} else { | |
// Check for clusters | |
if(this.map.settings.mass_marker_support){ | |
if(WPGMZA.settings.clusterAdvancedEnabled && WPGMZA.settings.clusterMaxZoom){ | |
zoomLevelOnClick = parseInt(WPGMZA.settings.clusterMaxZoom); | |
} | |
} | |
} | |
if(this.map instanceof WPGMZA.GoogleMap) | |
{ | |
this.map.panTo(marker.getPosition()); | |
this.map.setZoom(zoomLevelOnClick); | |
} | |
else | |
{ | |
this.map.panTo(marker.getPosition(), zoomLevelOnClick); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment