Skip to content

Instantly share code, notes, and snippets.

View DylanCodeCabin's full-sized avatar

Dylan Auty DylanCodeCabin

View GitHub Profile
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);
}
jQuery(($) => {
WPGMZA.Map.prototype.addMarker = function(marker){
if(!(marker instanceof WPGMZA.Marker))
throw new Error("Argument must be an instance of WPGMZA.Marker");
let englishOnly = window.location.href.indexOf('/en/') !== -1 ? true : false;
if(englishOnly){
@DylanCodeCabin
DylanCodeCabin / gist:c03797089b882ab8f7abd1e696690763
Created December 18, 2023 13:38
wpgmza-hover-bounce-marker.js
jQuery(($) => {
WPGMZA.ProMarker.prototype.__onMouseOver = WPGMZA.ProMarker.prototype.onMouseOver;
WPGMZA.ProMarker.prototype.onMouseOver = function(event){
this.__onMouseOver(event);
if(WPGMZA._selectedMarker){
WPGMZA._selectedMarker.setAnimation(WPGMZA.Marker.ANIMATION_NONE);
}
WPGMZA._selectedMarker = this;
@DylanCodeCabin
DylanCodeCabin / ol-geocoder-remap.js
Created August 10, 2023 13:58
Hotfix for OpenLayers Geocoding issue
jQuery(($) => {
WPGMZA.OLGeocoder.prototype.getResponseFromNominatim = function(options, callback) {
var data = {
q: options.address,
format: "json"
};
options.componentRestrictions && options.componentRestrictions.country ? data.countrycodes = options.componentRestrictions.country : options.country && (data.countrycodes = options.country),
$.ajax("https://nominatim.openstreetmap.org/search", {
data: data,
success: function(response, xhr, status) {
jQuery(function($){
$(document.body).on('markersplaced.wpgmza', () => {
for(let m in WPGMZA.maps){
for(let i in WPGMZA.maps[m].markers){
const marker = WPGMZA.maps[m].markers[i];
if(marker && marker.googleMarker){
google.maps.event.addListener(marker.googleMarker, 'mouseover', function (e) {
if(e && e.domEvent && e.domEvent.target){
try{
e.domEvent.target.removeAttribute('title');
/* Restrict autocomplete to more than one country
*
* In this case: Republic of Ireland and United Kingdom
*/
jQuery(($) => {
WPGMZA.AddressInput.prototype.loadGoogleAutocomplete = function(){
/* UK + Repuclic of Ireland */
const countries = ['ie', 'gb'];
if(WPGMZA.settings){
if(WPGMZA.settings.googleMapsApiKey || WPGMZA.settings.wpgmza_google_maps_api_key){
/**
* This script will automatically reload the marker data via the REST API
*
* It only appends new markers, meaning this is somewhat resful
*
* Currently, this does not deal with shapes or any other data (markers only)
*
* Adjust 'refresh.seconds' to change how frequently the polling request is made
*/
jQuery(($) => {
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)){