Skip to content

Instantly share code, notes, and snippets.

@DylanCodeCabin
Last active February 5, 2024 06:27
Show Gist options
  • Save DylanCodeCabin/aa407ca56de0c5a8a4c3df1397b87564 to your computer and use it in GitHub Desktop.
Save DylanCodeCabin/aa407ca56de0c5a8a4c3df1397b87564 to your computer and use it in GitHub Desktop.
setmarkeronclick.js
jQuery(($) => {
WPGMZA.ProMarker.prototype.__onClick = WPGMZA.ProMarker.prototype.onClick;
WPGMZA.ProMarker.prototype.onClick = function(event){
this.__onClick(event);
if(WPGMZA._selectedMarker){
WPGMZA._selectedMarker.setIcon(WPGMZA._selectedMarker._prevIcon);
}
WPGMZA._selectedMarker = this;
WPGMZA._selectedMarker._prevIcon = WPGMZA._selectedMarker.icon.url;
this.setIcon("https://www.recyclebox.info/wp-content/uploads/wp-google-maps/icons/65a7e3a01ce208.42662492.png");
}
WPGMZA.AdvancedTableMarkerListing.prototype.__onItemClick = WPGMZA.AdvancedTableMarkerListing.prototype.onItemClick;
WPGMZA.AdvancedTableMarkerListing.prototype.onItemClick = function(event) {
this.__onItemClick(event);
if(WPGMZA._selectedMarker){
WPGMZA._selectedMarker.setIcon(WPGMZA._selectedMarker._prevIcon);
}
let marker_id = $(event.currentTarget).attr("mid");
if(marker_id){
let marker = WPGMZA.maps[0].getMarkerByID(marker_id);
if(marker){
WPGMZA._selectedMarker = marker;
WPGMZA._selectedMarker._prevIcon = WPGMZA._selectedMarker.icon.url;
marker.setIcon("https://www.recyclebox.info/wp-content/uploads/wp-google-maps/icons/65a7e3a01ce208.42662492.png");
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment