Skip to content

Instantly share code, notes, and snippets.

View DylanCodeCabin's full-sized avatar

Dylan Auty DylanCodeCabin

View GitHub Profile
const customMapId = 1;
/* An array with objects, each object represents a marker */
const customMarkerData = [
{
title : "Example Title",
address: "Example Address",
map_id: customMapId,
lat: 41.973052569247955,
lng: -120.2621297558594,
const customMapId = 1;
/* An array with objects, each object represents a polygon */
const customPolygonData = [
{
description : "This is an example",
fillcolor: "#808080",
linecolor: "#666666",
lineopacity: "0.5",
linethickness: "3",
class CustomEventSystem {
constructor(target) {
this.target = target;
}
trigger(event, data){
const relay = new CustomEvent(event, { detail: (data ? data : false) });
this.target.dispatchEvent(relay);
}
/**
* Our default hide until search behaviour still performs an initial "cache" of markers, but the markers are not shown
*
* This really shows weakness at large data set handling (thousands) where the search will fail if the initial cache is not created
*
* This series of overrides will overcome this by only doing the first fetch when the search is performed
*
* It then re-runs the search after the fact, but only if it has not been done already
*
* This can be added in Maps > Settings > Custom Scripts > Custom JavaScript
Column Type Description
id int Marker ID, auto incremented on insert
map_id int Map ID that this marker is bound to
address string The visual address for the marker
description string The description content, can contain HTML
pic string URL to an image, leave empty to ignore
link string URL for the more details link, leave empty to ignore
icon string Icon data, usually a JSON object for marker icons
lat float Visual lat coordinate for the marker, not used for placement
/**
* Custom script which handles loading remote images via Google Photos API
*
* Import your image photo references accordingly
*/
jQuery(function($){
WPGMZA.ProInfoWindow.prototype.open = function(map, feature)
{
var self = this;
/**
* 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");
jQuery(function(){
jQuery(window).load(function(){
WPGMZA.MarkerClusterer.prototype.redraw = function() {
WPGMZA.MarkerClusterer.log("redraw called", this);
this.map.clusterSepBridge = true;
if(typeof this.shouldRegenNVC === 'undefined'){
this.shouldRegenNVC = true;
}
jQuery(function($){
let bouncingMark = false;
$(document.body).on('mouseenter', '.wpgmaps_mlist_row', function(){
const map = WPGMZA.maps[0];
const markerId = $(this).attr('mid');
if(markerId){
if(bouncingMark !== markerId){
/**
* The following script allows custom field to be used as part of get variable filtering
*
* Create a custom field called 'id', set it to visible in info-window, and ensure your marker has the relevant field filled with a number
*
* Once done, add thos script and append your variable as ?custom_id=1
*/
jQuery(function($){
$(document.body).on('markersplaced.wpgmza', function(){