Skip to content

Instantly share code, notes, and snippets.

View DylanCodeCabin's full-sized avatar

Dylan Auty DylanCodeCabin

View GitHub Profile
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; }
jQuery(function($){
/* Clone the original method */
WPGMZA.ProInfoWindow.prototype._populatePanel = WPGMZA.ProInfoWindow.prototype.populatePanel;
WPGMZA.ProInfoWindow.prototype.populatePanel = function(){
/* Call the original method */
this._populatePanel();
/* Grab a self refernce, to be used in our loop */
const self = this;
/* Demo of how you might replace the HTML template for Atlas Novus Panel info widnows
*
* This uses a dynamic hook, from the shortcode class, and can be applied to any module that is contained in a panel
*
* This assumes, you are targeting the "left" panel, but the same can be applied to the right panel if the anchor is set this way
*/
add_filter('wpgmza_map_panel_elements_left', 'wpgmza_infowindow_override', 10, 1);
function wpgmza_infowindow_override($elements){
if(is_array($elements)){
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");