Last active
April 26, 2019 22:59
-
-
Save andtrev/b06b7f548c1e8b9ab93732fd11650a6a 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
jQuery(function($){ | |
$('.wpgmza_map').on('wpgooglemaps_loaded', function() { | |
var mid = parseInt($(this).attr('data-map-id')); | |
if($('#wpgmaptotal'+mid).length < 1){ | |
$('#wpgmza_map_'+mid).before('<div id="wpgmaptotal'+mid+'" style="width:100%;text-align:center;">'+Object.keys(wpgmaps_localize_marker_data[mid]).length+' Patios</div>'); | |
} | |
}); | |
}); | |
jQuery(function($){ | |
WPGMZA.ProInfoWindow.prototype.legacyCreateDefaultInfoWindow = function(map) | |
{ | |
var marker = this.mapObject; | |
var map = marker.map; | |
function empty(field) | |
{ | |
return !(field && field.length && field.length > 0); | |
} | |
var container = $("<div class='wpgmza_markerbox scrollFix'></div>"); | |
if(this.maxWidth) | |
container.css({"max-width": this.maxWidth}); | |
if(!empty(marker.pic)) | |
{ | |
var img = $("<img/>"); | |
img.addClass("wpgmza_infowindow_image"); | |
img.attr("src", marker.pic); | |
img.css({"float": "right"}); | |
if(this.maxWidth) | |
img.css({"max-width": this.maxWidth}); | |
if(this.enableImageResizing && this.imageWidth) | |
{ | |
img.css({"width": this.imageWidth}); | |
img.css({"height": this.imageHeight}); | |
} | |
if(!this.enableImageResizing) | |
img.css({"margin": "5px"}); | |
container.append(img); | |
} | |
if(!empty(marker.title)) | |
{ | |
var p = $("<p class='wpgmza_infowindow_title'></p>"); | |
p.text(marker.title); | |
container.append(p); | |
} | |
if(!empty(marker.address) && this.showAddress) | |
{ | |
var p = $("<p class='wpgmza_infowindow_address'></p>"); | |
p.text(marker.address); | |
container.append(p); | |
} | |
if(!empty(marker.desc)) | |
{ | |
var div = $("<div class='wpgmza_infowindow_description'></div>"); | |
div.html(marker.desc); | |
container.append(div); | |
} | |
if(!empty(marker.linkd) || !empty(marker.link)) | |
{ | |
var link = empty(marker.link) ? marker.linkd : marker.link; | |
var p = $("<p class='wpgmza_infowindow_link'></p>"); | |
var a = $("<a class='wpgmza_infowindow_link'></a>"); | |
a.attr("href", WPGMZA.decodeEntities(link)); | |
a.attr("target", this.linkTarget); | |
a.text(this.linkText); | |
p.append(a); | |
container.append(p); | |
} | |
if(map.directionsEnabled) | |
{ | |
var p = $("<p></p>"); | |
var a = $("<a class='wpgmza_gd'></a>"); | |
a.attr("href", "javascript: ;"); | |
a.attr("id", map.id); | |
a.attr("data-address", marker.address); | |
a.attr("data-latlng", marker.getPosition().toString()); | |
// Legacy fields | |
a.attr("wpgm_addr_field", marker.address); | |
a.attr("gps", marker.lat+","+marker.lng); | |
a.text(this.directionsText); | |
p.append(a); | |
container.append(p); | |
} | |
var distanceToDisplay = -1; | |
this.mapObject.map.settings.store_locator_distance = 1; | |
var filteringParameters = map.markerFilter.getFilteringParameters(); | |
if (typeof MYMAP[parseInt(map.id)].map.userLocationMarker !== "undefined"){ | |
var distanceInKM = WPGMZA.Distance.between( | |
MYMAP[parseInt(map.id)].map.userLocationMarker.getPosition(), | |
marker.getPosition() | |
); | |
distanceToDisplay = distanceInKM; | |
if(this.distanceUnits == WPGMZA.Distance.MILES) | |
distanceToDisplay /= WPGMZA.Distance.KILOMETERS_PER_MILE; | |
} else if(filteringParameters.center) | |
{ | |
var distanceInKM = WPGMZA.Distance.between( | |
filteringParameters.center, | |
marker.getPosition() | |
); | |
distanceToDisplay = distanceInKM; | |
if(this.distanceUnits == WPGMZA.Distance.MILES) | |
distanceToDisplay /= WPGMZA.Distance.KILOMETERS_PER_MILE; | |
} | |
if (distanceToDisplay > -1){ | |
var text = Math.round(distanceToDisplay*10)/10 + " "; | |
if(this.distanceUnits == WPGMZA.Distance.MILES) | |
text += WPGMZA.localized_strings.miles_away; | |
else | |
text += WPGMZA.localized_strings.kilometers_away; | |
var p = $("<p></p>"); | |
p.text(text); | |
container.append(p); | |
} | |
if(marker.custom_fields_html) | |
container.append(marker.custom_fields_html); | |
this.setContent(container.html()); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment