/**
* This jQuery plugin displays map and it's components.
* @author Flipper Code (hello *at* flippercode *dot* com)
* @version 1.0
*/
(function($, window, document, undefined) {
"use strict";
function wpgmpInitializeInfoBox() {
var InfoBox = function(opt_opts) {
opt_opts = opt_opts || {};
google.maps.OverlayView.apply(this, arguments);
// Standard options (in common with google.maps.InfoWindow):
//
this.content_ = opt_opts.content || "";
this.disableAutoPan_ = opt_opts.disableAutoPan || false;
this.maxWidth_ = opt_opts.maxWidth || 0;
this.pixelOffset_ = opt_opts.pixelOffset || new google.maps.Size(0, 0);
this.position_ = opt_opts.position || new google.maps.LatLng(0, 0);
this.zIndex_ = opt_opts.zIndex || null;
// Additional options (unique to InfoBox):
//
this.boxClass_ = opt_opts.boxClass || "infoBox";
this.boxStyle_ = opt_opts.boxStyle || {};
this.closeBoxMargin_ = opt_opts.closeBoxMargin || "2px";
this.closeBoxURL_ = opt_opts.closeBoxURL || "//www.google.com/intl/en_us/mapfiles/close.gif";
if (opt_opts.closeBoxURL === "") {
this.closeBoxURL_ = "";
}
this.closeBoxTitle_ = opt_opts.closeBoxTitle || " Close ";
this.infoBoxClearance_ = opt_opts.infoBoxClearance || new google.maps.Size(1, 1);
if (typeof opt_opts.visible === "undefined") {
if (typeof opt_opts.isHidden === "undefined") {
opt_opts.visible = true;
} else {
opt_opts.visible = !opt_opts.isHidden;
}
}
this.isHidden_ = !opt_opts.visible;
this.alignBottom_ = opt_opts.alignBottom || false;
this.pane_ = opt_opts.pane || "floatPane";
this.enableEventPropagation_ = opt_opts.enableEventPropagation || false;
this.div_ = null;
this.closeListener_ = null;
this.moveListener_ = null;
this.contextListener_ = null;
this.eventListeners_ = null;
this.fixedWidthSet_ = null;
}
InfoBox.prototype = new google.maps.OverlayView();
/**
* Creates the DIV representing the InfoBox.
* @private
*/
InfoBox.prototype.createInfoBoxDiv_ = function() {
var i;
var events;
var bw;
var me = this;
// This handler prevents an event in the InfoBox from being passed on to the map.
//
var cancelHandler = function(e) {
e.cancelBubble = true;
if (e.stopPropagation) {
e.stopPropagation();
}
};
// This handler ignores the current event in the InfoBox and conditionally prevents
// the event from being passed on to the map. It is used for the contextmenu event.
//
var ignoreHandler = function(e) {
e.returnValue = false;
if (e.preventDefault) {
e.preventDefault();
}
if (!me.enableEventPropagation_) {
cancelHandler(e);
}
};
if (!this.div_) {
this.div_ = document.createElement("div");
this.setBoxStyle_();
if (typeof this.content_.nodeType === "undefined") {
this.div_.innerHTML = this.getCloseBoxImg_() + this.content_;
} else {
this.div_.innerHTML = this.getCloseBoxImg_();
this.div_.appendChild(this.content_);
}
// Add the InfoBox DIV to the DOM
this.getPanes()[this.pane_].appendChild(this.div_);
this.addClickHandler_();
if (this.div_.style.width) {
this.fixedWidthSet_ = true;
} else {
if (this.maxWidth_ !== 0 && this.div_.offsetWidth > this.maxWidth_) {
this.div_.style.width = this.maxWidth_;
this.div_.style.overflow = "auto";
this.fixedWidthSet_ = true;
} else { // The following code is needed to overcome problems with MSIE
bw = this.getBoxWidths_();
this.div_.style.width = (this.div_.offsetWidth - bw.left - bw.right) + "px";
this.fixedWidthSet_ = false;
}
}
this.panBox_(this.disableAutoPan_);
if (!this.enableEventPropagation_) {
this.eventListeners_ = [];
// Cancel event propagation.
//
// Note: mousemove not included (to resolve Issue 152)
events = ["mousedown", "mouseover", "mouseout", "mouseup",
"click", "dblclick", "touchstart", "touchend", "touchmove"
];
for (i = 0; i < events.length; i++) {
this.eventListeners_.push(google.maps.event.addDomListener(this.div_, events[i], cancelHandler));
}
// Workaround for Google bug that causes the cursor to change to a pointer
// when the mouse moves over a marker underneath InfoBox.
this.eventListeners_.push(google.maps.event.addDomListener(this.div_, "mouseover", function(e) {
this.style.cursor = "default";
}));
}
this.contextListener_ = google.maps.event.addDomListener(this.div_, "contextmenu", ignoreHandler);
/**
* This event is fired when the DIV containing the InfoBox's content is attached to the DOM.
* @name InfoBox#domready
* @event
*/
google.maps.event.trigger(this, "domready");
}
};
/**
* Returns the HTML tag for the close box.
* @private
*/
InfoBox.prototype.getCloseBoxImg_ = function() {
var img = "";
if (this.closeBoxURL_ !== "") {
img = "
";
}
return img;
};
/**
* Adds the click handler to the InfoBox close box.
* @private
*/
InfoBox.prototype.addClickHandler_ = function() {
var closeBox;
if (this.closeBoxURL_ !== "") {
closeBox = this.div_.firstChild;
this.closeListener_ = google.maps.event.addDomListener(closeBox, "click", this.getCloseClickHandler_());
} else {
this.closeListener_ = null;
}
};
/**
* Returns the function to call when the user clicks the close box of an InfoBox.
* @private
*/
InfoBox.prototype.getCloseClickHandler_ = function() {
var me = this;
return function(e) {
// 1.0.3 fix: Always prevent propagation of a close box click to the map:
e.cancelBubble = true;
if (e.stopPropagation) {
e.stopPropagation();
}
/**
* This event is fired when the InfoBox's close box is clicked.
* @name InfoBox#closeclick
* @event
*/
google.maps.event.trigger(me, "closeclick");
me.close();
};
};
/**
* Pans the map so that the InfoBox appears entirely within the map's visible area.
* @private
*/
InfoBox.prototype.panBox_ = function(disablePan) {
var map;
var bounds;
var xOffset = 0,
yOffset = 0;
if (!disablePan) {
map = this.getMap();
if (map instanceof google.maps.Map) { // Only pan if attached to map, not panorama
if (!map.getBounds().contains(this.position_)) {
// Marker not in visible area of map, so set center
// of map to the marker position first.
map.setCenter(this.position_);
}
var iwOffsetX = this.pixelOffset_.width;
var iwOffsetY = this.pixelOffset_.height;
var iwWidth = this.div_.offsetWidth;
var iwHeight = this.div_.offsetHeight;
var padX = this.infoBoxClearance_.width;
var padY = this.infoBoxClearance_.height;
if (map.panToBounds.length == 2) {
// Using projection.fromLatLngToContainerPixel to compute the infowindow position
// does not work correctly anymore for JS Maps API v3.32 and above if there is a
// previous synchronous call that causes the map to animate (e.g. setCenter when
// the position is not within bounds). Hence, we are using panToBounds with
// padding instead, which works synchronously.
var padding = {
left: 0,
right: 0,
top: 0,
bottom: 0
};
padding.left = -iwOffsetX + padX;
padding.right = iwOffsetX + iwWidth + padX;
if (this.alignBottom_) {
padding.top = -iwOffsetY + padY + iwHeight;
padding.bottom = iwOffsetY + padY;
} else {
padding.top = -iwOffsetY + padY;
padding.bottom = iwOffsetY + iwHeight + padY;
}
map.panToBounds(new google.maps.LatLngBounds(this.position_), padding);
} else {
var mapDiv = map.getDiv();
var mapWidth = mapDiv.offsetWidth;
var mapHeight = mapDiv.offsetHeight;
var pixPosition = this.getProjection().fromLatLngToContainerPixel(this.position_);
if (pixPosition.x < (-iwOffsetX + padX)) {
xOffset = pixPosition.x + iwOffsetX - padX;
} else if ((pixPosition.x + iwWidth + iwOffsetX + padX) > mapWidth) {
xOffset = pixPosition.x + iwWidth + iwOffsetX + padX - mapWidth;
}
if (this.alignBottom_) {
if (pixPosition.y < (-iwOffsetY + padY + iwHeight)) {
yOffset = pixPosition.y + iwOffsetY - padY - iwHeight;
} else if ((pixPosition.y + iwOffsetY + padY) > mapHeight) {
yOffset = pixPosition.y + iwOffsetY + padY - mapHeight;
}
} else {
if (pixPosition.y < (-iwOffsetY + padY)) {
yOffset = pixPosition.y + iwOffsetY - padY;
} else if ((pixPosition.y + iwHeight + iwOffsetY + padY) > mapHeight) {
yOffset = pixPosition.y + iwHeight + iwOffsetY + padY - mapHeight;
}
}
if (!(xOffset === 0 && yOffset === 0)) {
// Move the map to the shifted center.
//
var c = map.getCenter();
map.panBy(xOffset, yOffset);
}
}
}
}
};
/**
* Sets the style of the InfoBox by setting the style sheet and applying
* other specific styles requested.
* @private
*/
InfoBox.prototype.setBoxStyle_ = function() {
var i, boxStyle;
if (this.div_) {
// Apply style values from the style sheet defined in the boxClass parameter:
this.div_.className = this.boxClass_;
// Clear existing inline style values:
this.div_.style.cssText = "";
// Apply style values defined in the boxStyle parameter:
boxStyle = this.boxStyle_;
for (i in boxStyle) {
if (boxStyle.hasOwnProperty(i)) {
this.div_.style[i] = boxStyle[i];
}
}
// Fix for iOS disappearing InfoBox problem.
// See http://stackoverflow.com/questions/9229535/google-maps-markers-disappear-at-certain-zoom-level-only-on-iphone-ipad
// Required: use "matrix" technique to specify transforms in order to avoid this bug.
if ((typeof this.div_.style.WebkitTransform === "undefined") || (this.div_.style.WebkitTransform.indexOf("translateZ") === -1 && this.div_.style.WebkitTransform.indexOf("matrix") === -1)) {
this.div_.style.WebkitTransform = "translateZ(0)";
}
// Fix up opacity style for benefit of MSIE:
//
if (typeof this.div_.style.opacity !== "undefined" && this.div_.style.opacity !== "") {
// See http://www.quirksmode.org/css/opacity.html
this.div_.style.MsFilter = "\"progid:DXImageTransform.Microsoft.Alpha(Opacity=" + (this.div_.style.opacity * 100) + ")\"";
this.div_.style.filter = "alpha(opacity=" + (this.div_.style.opacity * 100) + ")";
}
// Apply required styles:
//
this.div_.style.position = "absolute";
this.div_.style.visibility = 'hidden';
if (this.zIndex_ !== null) {
this.div_.style.zIndex = this.zIndex_;
}
}
};
/**
* Get the widths of the borders of the InfoBox.
* @private
* @return {Object} widths object (top, bottom left, right)
*/
InfoBox.prototype.getBoxWidths_ = function() {
var computedStyle;
var bw = {
top: 0,
bottom: 0,
left: 0,
right: 0
};
var box = this.div_;
if (document.defaultView && document.defaultView.getComputedStyle) {
computedStyle = box.ownerDocument.defaultView.getComputedStyle(box, "");
if (computedStyle) {
// The computed styles are always in pixel units (good!)
bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0;
bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0;
bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0;
}
} else if (document.documentElement.currentStyle) { // MSIE
if (box.currentStyle) {
// The current styles may not be in pixel units, but assume they are (bad!)
bw.top = parseInt(box.currentStyle.borderTopWidth, 10) || 0;
bw.bottom = parseInt(box.currentStyle.borderBottomWidth, 10) || 0;
bw.left = parseInt(box.currentStyle.borderLeftWidth, 10) || 0;
bw.right = parseInt(box.currentStyle.borderRightWidth, 10) || 0;
}
}
return bw;
};
/**
* Invoked when close is called. Do not call it directly.
*/
InfoBox.prototype.onRemove = function() {
if (this.div_) {
this.div_.parentNode.removeChild(this.div_);
this.div_ = null;
}
};
/**
* Draws the InfoBox based on the current map projection and zoom level.
*/
InfoBox.prototype.draw = function() {
this.createInfoBoxDiv_();
var pixPosition = this.getProjection().fromLatLngToDivPixel(this.position_);
this.div_.style.left = (pixPosition.x + this.pixelOffset_.width) + "px";
if (this.alignBottom_) {
this.div_.style.bottom = -(pixPosition.y + this.pixelOffset_.height) + "px";
} else {
this.div_.style.top = (pixPosition.y + this.pixelOffset_.height) + "px";
}
if (this.isHidden_) {
this.div_.style.visibility = "hidden";
} else {
this.div_.style.visibility = "visible";
}
};
/**
* Sets the options for the InfoBox. Note that changes to the maxWidth,
* closeBoxMargin, closeBoxTitle, closeBoxURL, and
* enableEventPropagation properties have no affect until the current
* InfoBox is closed and a new one is opened.
* @param {InfoBoxOptions} opt_opts
*/
InfoBox.prototype.setOptions = function(opt_opts) {
if (typeof opt_opts.boxClass !== "undefined") { // Must be first
this.boxClass_ = opt_opts.boxClass;
this.setBoxStyle_();
}
if (typeof opt_opts.boxStyle !== "undefined") { // Must be second
this.boxStyle_ = opt_opts.boxStyle;
this.setBoxStyle_();
}
if (typeof opt_opts.content !== "undefined") {
this.setContent(opt_opts.content);
}
if (typeof opt_opts.disableAutoPan !== "undefined") {
this.disableAutoPan_ = opt_opts.disableAutoPan;
}
if (typeof opt_opts.maxWidth !== "undefined") {
this.maxWidth_ = opt_opts.maxWidth;
}
if (typeof opt_opts.pixelOffset !== "undefined") {
this.pixelOffset_ = opt_opts.pixelOffset;
}
if (typeof opt_opts.alignBottom !== "undefined") {
this.alignBottom_ = opt_opts.alignBottom;
}
if (typeof opt_opts.position !== "undefined") {
this.setPosition(opt_opts.position);
}
if (typeof opt_opts.zIndex !== "undefined") {
this.setZIndex(opt_opts.zIndex);
}
if (typeof opt_opts.closeBoxMargin !== "undefined") {
this.closeBoxMargin_ = opt_opts.closeBoxMargin;
}
if (typeof opt_opts.closeBoxURL !== "undefined") {
this.closeBoxURL_ = opt_opts.closeBoxURL;
}
if (typeof opt_opts.closeBoxTitle !== "undefined") {
this.closeBoxTitle_ = opt_opts.closeBoxTitle;
}
if (typeof opt_opts.infoBoxClearance !== "undefined") {
this.infoBoxClearance_ = opt_opts.infoBoxClearance;
}
if (typeof opt_opts.isHidden !== "undefined") {
this.isHidden_ = opt_opts.isHidden;
}
if (typeof opt_opts.visible !== "undefined") {
this.isHidden_ = !opt_opts.visible;
}
if (typeof opt_opts.enableEventPropagation !== "undefined") {
this.enableEventPropagation_ = opt_opts.enableEventPropagation;
}
if (this.div_) {
this.draw();
}
};
/**
* Sets the content of the InfoBox.
* The content can be plain text or an HTML DOM node.
* @param {string|Node} content
*/
InfoBox.prototype.setContent = function(content) {
this.content_ = content;
if (this.div_) {
if (this.closeListener_) {
google.maps.event.removeListener(this.closeListener_);
this.closeListener_ = null;
}
// Odd code required to make things work with MSIE.
//
if (!this.fixedWidthSet_) {
this.div_.style.width = "";
}
if (typeof content.nodeType === "undefined") {
this.div_.innerHTML = this.getCloseBoxImg_() + content;
} else {
this.div_.innerHTML = this.getCloseBoxImg_();
this.div_.appendChild(content);
}
// Perverse code required to make things work with MSIE.
// (Ensures the close box does, in fact, float to the right.)
//
if (!this.fixedWidthSet_) {
this.div_.style.width = this.div_.offsetWidth + "px";
if (typeof content.nodeType === "undefined") {
this.div_.innerHTML = this.getCloseBoxImg_() + content;
} else {
this.div_.innerHTML = this.getCloseBoxImg_();
this.div_.appendChild(content);
}
}
this.addClickHandler_();
}
/**
* This event is fired when the content of the InfoBox changes.
* @name InfoBox#content_changed
* @event
*/
google.maps.event.trigger(this, "content_changed");
};
/**
* Sets the geographic location of the InfoBox.
* @param {LatLng} latlng
*/
InfoBox.prototype.setPosition = function(latlng) {
this.position_ = latlng;
if (this.div_) {
this.draw();
}
/**
* This event is fired when the position of the InfoBox changes.
* @name InfoBox#position_changed
* @event
*/
google.maps.event.trigger(this, "position_changed");
};
/**
* Sets the zIndex style for the InfoBox.
* @param {number} index
*/
InfoBox.prototype.setZIndex = function(index) {
this.zIndex_ = index;
if (this.div_) {
this.div_.style.zIndex = index;
}
/**
* This event is fired when the zIndex of the InfoBox changes.
* @name InfoBox#zindex_changed
* @event
*/
google.maps.event.trigger(this, "zindex_changed");
};
/**
* Sets the visibility of the InfoBox.
* @param {boolean} isVisible
*/
InfoBox.prototype.setVisible = function(isVisible) {
this.isHidden_ = !isVisible;
if (this.div_) {
this.div_.style.visibility = (this.isHidden_ ? "hidden" : "visible");
}
};
/**
* Returns the content of the InfoBox.
* @returns {string}
*/
InfoBox.prototype.getContent = function() {
return this.content_;
};
/**
* Returns the geographic location of the InfoBox.
* @returns {LatLng}
*/
InfoBox.prototype.getPosition = function() {
return this.position_;
};
/**
* Returns the zIndex for the InfoBox.
* @returns {number}
*/
InfoBox.prototype.getZIndex = function() {
return this.zIndex_;
};
/**
* Returns a flag indicating whether the InfoBox is visible.
* @returns {boolean}
*/
InfoBox.prototype.getVisible = function() {
var isVisible;
if ((typeof this.getMap() === "undefined") || (this.getMap() === null)) {
isVisible = false;
} else {
isVisible = !this.isHidden_;
}
return isVisible;
};
/**
* Returns the width of the InfoBox in pixels.
* @returns {number}
*/
InfoBox.prototype.getWidth = function() {
var width = null;
if (this.div_) {
width = this.div_.offsetWidth;
}
return width;
};
/**
* Returns the height of the InfoBox in pixels.
* @returns {number}
*/
InfoBox.prototype.getHeight = function() {
var height = null;
if (this.div_) {
height = this.div_.offsetHeight;
}
return height;
};
/**
* Shows the InfoBox. [Deprecated; use setVisible instead.]
*/
InfoBox.prototype.show = function() {
this.isHidden_ = false;
if (this.div_) {
this.div_.style.visibility = "visible";
}
};
/**
* Hides the InfoBox. [Deprecated; use setVisible instead.]
*/
InfoBox.prototype.hide = function() {
this.isHidden_ = true;
if (this.div_) {
this.div_.style.visibility = "hidden";
}
};
/**
* Adds the InfoBox to the specified map or Street View panorama. If anchor
* (usually a google.maps.Marker) is specified, the position
* of the InfoBox is set to the position of the anchor. If the
* anchor is dragged to a new location, the InfoBox moves as well.
* @param {Map|StreetViewPanorama} map
* @param {MVCObject} [anchor]
*/
InfoBox.prototype.open = function(map, anchor) {
var me = this;
if (anchor) {
this.setPosition(anchor.getPosition()); // BUG FIX 2/17/2018: needed for v3.32
this.moveListener_ = google.maps.event.addListener(anchor, "position_changed", function() {
me.setPosition(this.getPosition());
});
}
this.setMap(map);
if (this.div_) {
this.panBox_(this.disableAutoPan_); // BUG FIX 2/17/2018: add missing parameter
}
};
/**
* Removes the InfoBox from the map.
*/
InfoBox.prototype.close = function() {
var i;
if (this.closeListener_) {
google.maps.event.removeListener(this.closeListener_);
this.closeListener_ = null;
}
if (this.eventListeners_) {
for (i = 0; i < this.eventListeners_.length; i++) {
google.maps.event.removeListener(this.eventListeners_[i]);
}
this.eventListeners_ = null;
}
if (this.moveListener_) {
google.maps.event.removeListener(this.moveListener_);
this.moveListener_ = null;
}
if (this.contextListener_) {
google.maps.event.removeListener(this.contextListener_);
this.contextListener_ = null;
}
this.setMap(null);
};
return new InfoBox();
}
function GoogleMaps(element, map_data) {
var options;
this.element = element;
map_data = JSON.parse(atob(map_data));
this.map_data = $.extend({}, {}, map_data);
options = this.map_data.map_options;
this.settings = $.extend({
"zoom": "5",
"map_type_id": "ROADMAP",
"scroll_wheel": true,
"map_visual_refresh": false,
"full_screen_control": false,
"full_screen_control_position": "BOTTOM_RIGHT",
"zoom_control": true,
"zoom_control_style": "SMALL",
"zoom_control_position": "TOP_LEFT",
"map_type_control": true,
"map_type_control_style": "HORIZONTAL_BAR",
"map_type_control_position": "RIGHT_TOP",
"scale_control": true,
"street_view_control": true,
"street_view_control_position": "TOP_LEFT",
"overview_map_control": true,
"center_lat": "40.6153983",
"center_lng": "-74.2535216",
"draggable": true
}, {}, options);
this.container = $("div[rel='" + $(this.element).attr("id") + "']");
$(document).find(".wpgmp_map_container_placeholder").remove();
$(document).find(".wpgmp_hide_map_container").removeClass("wpgmp_hide_map_container");
var suppress_markers = false;
if (this.map_data.map_tabs && this.map_data.map_tabs.direction_tab) {
suppress_markers = this.map_data.map_tabs.direction_tab.suppress_markers;
}
this.directionsService = new google.maps.DirectionsService();
this.directionsDisplay = new google.maps.DirectionsRenderer({
suppressMarkers: suppress_markers,
});
this.drawingmanager = {};
this.geocoder = new google.maps.Geocoder();
this.places = [];
this.show_places = [];
this.categories = {};
this.tabs = [];
this.all_shapes = [];
this.wpgmp_polylines = [];
this.wpgmp_polygons = [];
this.wpgmp_circles = [];
this.wpgmp_shape_events = [];
this.wpgmp_rectangles = [];
this.per_page_value = 0;
this.current_amenities = [];
this.route_directions = [];
this.search_area = '';
this.infobox = wpgmpInitializeInfoBox();
this.markerClusterer = null;
this.infowindow_marker = new google.maps.InfoWindow();
this.init();
}
GoogleMaps.prototype = {
init: function() {
var map_obj = this;
if (map_obj.map_data.map_property && map_obj.map_data.map_property.debug_mode == true) {
console.log('*********WPGMP Debug Mode Output*********');
console.log('Map ID =' + map_obj.map_data.map_property.map_id);
if (map_obj.map_data.places) {
console.log('Total Locations=' + map_obj.map_data.places.length);
}
console.log('WPGMP Object=');
console.log(map_obj.map_data);
console.log('*********WPGMP Debug Mode End Output*********');
}
var center = new google.maps.LatLng(map_obj.settings.center_lat, map_obj.settings.center_lng);
map_obj.map = new google.maps.Map(map_obj.element, {
zoom: parseInt(map_obj.settings.zoom),
center: center,
disableDoubleClickZoom: (map_obj.settings.scroll_wheel != 'false'),
scrollwheel: map_obj.settings.scroll_wheel,
zoomControl: (map_obj.settings.zoom_control === true),
fullscreenControl: (map_obj.settings.full_screen_control === true),
fullscreenControlOptions: {
position: eval("google.maps.ControlPosition." + map_obj.settings.full_screen_control_position)
},
zoomControlOptions: {
style: eval("google.maps.ZoomControlStyle." + map_obj.settings.zoom_control_style),
position: eval("google.maps.ControlPosition." + map_obj.settings.zoom_control_position)
},
mapTypeControl: (map_obj.settings.map_type_control == true),
mapTypeControlOptions: {
style: eval("google.maps.MapTypeControlStyle." + map_obj.settings.map_type_control_style),
position: eval("google.maps.ControlPosition." + map_obj.settings.map_type_control_position)
},
scaleControl: (map_obj.settings.scale_control == true),
streetViewControl: (map_obj.settings.street_view_control == true),
streetViewControlOptions: {
position: eval("google.maps.ControlPosition." + map_obj.settings.street_view_control_position)
},
overviewMapControl: (map_obj.settings.overview_map_control == true),
overviewMapControlOptions: {
opened: map_obj.settings.overview_map_control
},
draggable: map_obj.settings.draggable,
mapTypeId: eval("google.maps.MapTypeId." + map_obj.settings.map_type_id),
styles: eval(map_obj.map_data.styles)
});
map_obj.map_loaded();
map_obj.responsive_map();
map_obj.create_markers();
map_obj.display_markers();
if (typeof map_obj.settings.google_fonts !== 'undefined') {
map_obj.load_google_fonts(map_obj.settings.google_fonts);
}
if ( map_obj.map_data.street_view ) {
map_obj.set_streetview(center);
}
if ( map_obj.map_data.bicyle_layer) {
map_obj.set_bicyle_layer();
}
if ( map_obj.map_data.traffic_layer) {
map_obj.set_traffic_layer();
}
if (map_obj.map_data.transit_layer) {
map_obj.set_transit_layer();
}
if ( map_obj.map_data.panoramio_layer ) {
map_obj.set_panoramic_layer();
}
if (map_obj.settings.display_45_imagery == '45') {
map_obj.set_45_imagery();
}
if (typeof map_obj.map_data.map_visual_refresh === true) {
map_obj.set_visual_refresh();
}
if (map_obj.map_data.marker_cluster) {
map_obj.set_marker_cluster();
}
if (map_obj.settings.search_control == true) {
map_obj.show_search_control();
}
if (map_obj.map_data.listing) {
$(map_obj.container).on('click', '.categories_filter_reset_btn', function() {
$(map_obj.container).find('.wpgmp_filter_wrappers select').each(function() {
$(this).find('option:first').attr('selected', 'selected');
});
$('.wpgmp_search_input').val('');
map_obj.update_filters();
});
$(map_obj.container).on('change', '[data-filter="dropdown"]', function() {
map_obj.update_filters();
});
$(map_obj.container).on('click', '[data-filter="checklist"]', function() {
map_obj.update_filters();
});
$(map_obj.container).on('click', '[data-filter="list"]', function() {
if ($(this).hasClass('fc_selected')) {
$(this).removeClass('fc_selected');
} else {
$(this).addClass('fc_selected');
}
map_obj.update_filters();
});
map_obj.display_filters_listing();
$.each(map_obj.map_data.listing.filters, function(key, filter) {
$(map_obj.container).find('select[name="' + filter + '"]').on('change', function() {
map_obj.update_filters();
});
});
$(map_obj.container).find('[data-name="radius"]').on('change', function() {
var search_data = $(map_obj.container).find('[data-input="wpgmp-search-text"]').val();
if (search_data.length >= 2 && $(this).val() != '') {
map_obj.geocoder.geocode({
"address": search_data
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map_obj.search_area = results[0].geometry.location;
map_obj.update_filters();
}
});
} else {
map_obj.search_area = '';
map_obj.update_filters();
}
});
$(map_obj.container).find('[data-filter="map-perpage-location-sorting"]').on('change', function() {
map_obj.per_page_value = $(this).val();
map_obj.update_filters();
});
$(map_obj.container).find('[data-input="wpgmp-search-text"]').on('keyup', function() {
var search_data = $(this).val();
$(map_obj.container).find('[data-filter="map-radius"]').val('');
map_obj.search_area = '';
// Apply default radius
if (search_data.length >= 2 && map_obj.map_data.listing.apply_default_radius == true) {
if (search_data.length >= 2) {
map_obj.geocoder.geocode({
"address": search_data
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map_obj.search_area = results[0].geometry.location;
map_obj.update_filters();
}
});
}
} else {
map_obj.update_filters();
}
});
}
$("body").on("click", ".wpgmp_marker_link", function() {
map_obj.open_infowindow($(this).data("marker"));
$('html, body').animate({
scrollTop: $(map_obj.container).offset().top - 150
}, 500);
});
$(map_obj.container).on("click", "a[data-marker]", function() {
map_obj.open_infowindow($(this).data("marker"));
$('html, body').animate({
scrollTop: $(map_obj.container).offset().top - 150
}, 500);
});
$(map_obj.container).on("click", "a[data-marker]", function() {
map_obj.open_infowindow($(this).data("marker"));
});
// REGISTER AUTO SUGGEST
map_obj.google_auto_suggest($(".wpgmp_auto_suggest"));
if (map_obj.settings.fit_bounds === true) {
map_obj.fit_bounds();
}
},
load_google_fonts: function(fonts) {
if (fonts && fonts.length > 0) {
$.each(fonts, function(k, font) {
if (font.indexOf(',') >= 0) {
font = font.split(",");
font = font[0];
}
if (font.indexOf('"') >= 0) {
font = font.replace('"', '');
font = font.replace('"', '');
}
WebFont.load({
google: {
families: [font]
}
});
});
}
},
createMarker: function(place) {
var map_obj = this;
var map = map_obj.map;
var placeLoc = place.geometry.location;
var image = {
url: place.icon,
size: new google.maps.Size(25, 25),
scaledSize: new google.maps.Size(25, 25)
};
place.marker = new google.maps.Marker({
map: map,
position: place.geometry.location,
icon: image
});
google.maps.event.addListener(place.marker, 'click', function() {
if (map_obj.settings.map_infowindow_customisations === true)
map_obj.amenity_infowindow.setContent('