PageSourceSearch

https://xn--80ajakqeleachkecdkr0a2n.xn--p1ai/wp-content/plugins/wp…/assets/js/maps.js?ver=4.6.9

js xn--80ajakqeleachkecdkr0a2n.xn--p1ai collected 2026-10-09 22:43:20 UTC 98,928 bytes, 2,457 lines download raw bytes

vendor: 4,936 bytes, lines 1-134
1/**
2 * This jQuery plugin displays map and it's components.
3 * @author Flipper Code (hello *at* flippercode *dot* com)
4 * @version 1.0
5 */
6(function($, window, document, undefined) {
7	"use strict";	
8
9    function wpgmpInitializeInfoBox() {
10
11        var InfoBox = function(opt_opts) {
12
13            opt_opts = opt_opts || {};
14        
15            google.maps.OverlayView.apply(this, arguments);
16        
17            // Standard options (in common with google.maps.InfoWindow):
18            //
19            this.content_ = opt_opts.content || "";
20            this.disableAutoPan_ = opt_opts.disableAutoPan || false;
21            this.maxWidth_ = opt_opts.maxWidth || 0;
22            this.pixelOffset_ = opt_opts.pixelOffset || new google.maps.Size(0, 0);
23            this.position_ = opt_opts.position || new google.maps.LatLng(0, 0);
24            this.zIndex_ = opt_opts.zIndex || null;
25        
26            // Additional options (unique to InfoBox):
27            //
28            this.boxClass_ = opt_opts.boxClass || "infoBox";
29            this.boxStyle_ = opt_opts.boxStyle || {};
30            this.closeBoxMargin_ = opt_opts.closeBoxMargin || "2px";
31            this.closeBoxURL_ = opt_opts.closeBoxURL || "//www.google.com/intl/en_us/mapfiles/close.gif";
32            if (opt_opts.closeBoxURL === "") {
33                this.closeBoxURL_ = "";
34            }
35            this.closeBoxTitle_ = opt_opts.closeBoxTitle || " Close ";
36            this.infoBoxClearance_ = opt_opts.infoBoxClearance || new google.maps.Size(1, 1);
37        
38            if (typeof opt_opts.visible === "undefined") {
39                if (typeof opt_opts.isHidden === "undefined") {
40                    opt_opts.visible = true;
41                } else {
42                    opt_opts.visible = !opt_opts.isHidden;
43                }
44            }
45            this.isHidden_ = !opt_opts.visible;
46        
47            this.alignBottom_ = opt_opts.alignBottom || false;
48            this.pane_ = opt_opts.pane || "floatPane";
49            this.enableEventPropagation_ = opt_opts.enableEventPropagation || false;
50        
51            this.div_ = null;
52            this.closeListener_ = null;
53            this.moveListener_ = null;
54            this.contextListener_ = null;
55            this.eventListeners_ = null;
56            this.fixedWidthSet_ = null;
57        }
58
59        InfoBox.prototype = new google.maps.OverlayView();
60        
61        /**
62         * Creates the DIV representing the InfoBox.
63         * @private
64         */
65        InfoBox.prototype.createInfoBoxDiv_ = function() {
66        
67            var i;
68            var events;
69            var bw;
70            var me = this;
71        
72            // This handler prevents an event in the InfoBox from being passed on to the map.
73            //
74            var cancelHandler = function(e) {
75                e.cancelBubble = true;
76                if (e.stopPropagation) {
77                    e.stopPropagation();
78                }
79            };
80        
81            // This handler ignores the current event in the InfoBox and conditionally prevents
82            // the event from being passed on to the map. It is used for the contextmenu event.
83            //
84            var ignoreHandler = function(e) {
85        
86                e.returnValue = false;
87        
88                if (e.preventDefault) {
89        
90                    e.preventDefault();
91                }
92        
93                if (!me.enableEventPropagation_) {
94        
95                    cancelHandler(e);
96                }
97            };
98        
99            if (!this.div_) {
100        
101                this.div_ = document.createElement("div");
102        
103                this.setBoxStyle_();
104        
105                if (typeof this.content_.nodeType === "undefined") {
106                    this.div_.innerHTML = this.getCloseBoxImg_() + this.content_;
107                } else {
108                    this.div_.innerHTML = this.getCloseBoxImg_();
109                    this.div_.appendChild(this.content_);
110                }
111        
112                // Add the InfoBox DIV to the DOM
113                this.getPanes()[this.pane_].appendChild(this.div_);
114        
115                this.addClickHandler_();
116        
117                if (this.div_.style.width) {
118        
119                    this.fixedWidthSet_ = true;
120        
121                } else {
122        
123                    if (this.maxWidth_ !== 0 && this.div_.offsetWidth > this.maxWidth_) {
124        
125                        this.div_.style.width = this.maxWidth_;
126                        this.div_.style.overflow = "auto";
127                        this.fixedWidthSet_ = true;
128        
129                    } else { // The following code is needed to overcome problems with MSIE
130        
131                        bw = this.getBoxWidths_();
132        
133                        this.div_.style.width = (this.div_.offsetWidth - bw.left - bw.right) + "px";
134                        this.fixedWidthSet_ = false;
135                    }
136                }
137        
138                this.panBox_(this.disableAutoPan_);
139        
140                if (!this.enableEventPropagation_) {
141        
142                    this.eventListeners_ = [];
143        
144                    // Cancel event propagation.
145                    //
146                    // Note: mousemove not included (to resolve Issue 152)
147                    events = ["mousedown", "mouseover", "mouseout", "mouseup",
148                        "click", "dblclick", "touchstart", "touchend", "touchmove"
149                    ];
150        
151                    for (i = 0; i < events.length; i++) {
152        
153                        this.eventListeners_.push(google.maps.event.addDomListener(this.div_, events[i], cancelHandler));
154                    }
155        
156                    // Workaround for Google bug that causes the cursor to change to a pointer
157                    // when the mouse moves over a marker underneath InfoBox.
158                    this.eventListeners_.push(google.maps.event.addDomListener(this.div_, "mouseover", function(e) {
159                        this.style.cursor = "default";
160                    }));
161                }
162        
163                this.contextListener_ = google.maps.event.addDomListener(this.div_, "contextmenu", ignoreHandler);
164        
165                /**
166                 * This event is fired when the DIV containing the InfoBox's content is attached to the DOM.
167                 * @name InfoBox#domready
168                 * @event
169                 */
170                google.maps.event.trigger(this, "domready");
171            }
172        };
173        
174        /**
175         * Returns the HTML <IMG> tag for the close box.
176         * @private
177         */
178        InfoBox.prototype.getCloseBoxImg_ = function() {
179        
180            var img = "";
181        
182            if (this.closeBoxURL_ !== "") {
183        
184                img = "<img";
185                img += " src='" + this.closeBoxURL_ + "'";
186                img += " align=right"; // Do this because Opera chokes on style='float: right;'
187                img += " title='" + this.closeBoxTitle_ + "'";
188                img += " style='";
189                img += " position: relative;"; // Required by MSIE
190                img += " cursor: pointer;";
191                img += " margin: " + this.closeBoxMargin_ + ";";
192                img += "'>";
193            }
194        
195            return img;
196        };
197        
198        /**
199         * Adds the click handler to the InfoBox close box.
200         * @private
201         */
202        InfoBox.prototype.addClickHandler_ = function() {
203        
204            var closeBox;
205        
206            if (this.closeBoxURL_ !== "") {
207        
208                closeBox = this.div_.firstChild;
209                this.closeListener_ = google.maps.event.addDomListener(closeBox, "click", this.getCloseClickHandler_());
210        
211            } else {
212        
213                this.closeListener_ = null;
214            }
215        };
216        
217        /**
218         * Returns the function to call when the user clicks the close box of an InfoBox.
219         * @private
220         */
221        InfoBox.prototype.getCloseClickHandler_ = function() {
222        
223            var me = this;
224        
225            return function(e) {
226        
227                // 1.0.3 fix: Always prevent propagation of a close box click to the map:
228                e.cancelBubble = true;
229        
230                if (e.stopPropagation) {
231        
232                    e.stopPropagation();
233                }
234        
235                /**
236                 * This event is fired when the InfoBox's close box is clicked.
237                 * @name InfoBox#closeclick
238                 * @event
239                 */
240                google.maps.event.trigger(me, "closeclick");
241        
242                me.close();
243            };
244        };
245        
246        /**
247         * Pans the map so that the InfoBox appears entirely within the map's visible area.
248         * @private
249         */
250        InfoBox.prototype.panBox_ = function(disablePan) {
251        
252            var map;
253            var bounds;
254            var xOffset = 0,
255                yOffset = 0;
256        
257            if (!disablePan) {
258        
259                map = this.getMap();
260        
261                if (map instanceof google.maps.Map) { // Only pan if attached to map, not panorama
262        
263                    if (!map.getBounds().contains(this.position_)) {
264                        // Marker not in visible area of map, so set center
265                        // of map to the marker position first.
266                        map.setCenter(this.position_);
267                    }
268        
269                    var iwOffsetX = this.pixelOffset_.width;
270                    var iwOffsetY = this.pixelOffset_.height;
271                    var iwWidth = this.div_.offsetWidth;
272                    var iwHeight = this.div_.offsetHeight;
273                    var padX = this.infoBoxClearance_.width;
274                    var padY = this.infoBoxClearance_.height;
275        
276                    if (map.panToBounds.length == 2) {
277                        // Using projection.fromLatLngToContainerPixel to compute the infowindow position
278                        // does not work correctly anymore for JS Maps API v3.32 and above if there is a
279                        // previous synchronous call that causes the map to animate (e.g. setCenter when
280                        // the position is not within bounds). Hence, we are using panToBounds with
281                        // padding instead, which works synchronously.
282                        var padding = {
283                            left: 0,
284                            right: 0,
285                            top: 0,
286                            bottom: 0
287                        };
288                        padding.left = -iwOffsetX + padX;
289                        padding.right = iwOffsetX + iwWidth + padX;
290                        if (this.alignBottom_) {
291                            padding.top = -iwOffsetY + padY + iwHeight;
292                            padding.bottom = iwOffsetY + padY;
293                        } else {
294                            padding.top = -iwOffsetY + padY;
295                            padding.bottom = iwOffsetY + iwHeight + padY;
296                        }
297                        map.panToBounds(new google.maps.LatLngBounds(this.position_), padding);
298                    } else {
299                        var mapDiv = map.getDiv();
300                        var mapWidth = mapDiv.offsetWidth;
301                        var mapHeight = mapDiv.offsetHeight;
302                        var pixPosition = this.getProjection().fromLatLngToContainerPixel(this.position_);
303        
304                        if (pixPosition.x < (-iwOffsetX + padX)) {
305                            xOffset = pixPosition.x + iwOffsetX - padX;
306                        } else if ((pixPosition.x + iwWidth + iwOffsetX + padX) > mapWidth) {
307                            xOffset = pixPosition.x + iwWidth + iwOffsetX + padX - mapWidth;
308                        }
309                        if (this.alignBottom_) {
310                            if (pixPosition.y < (-iwOffsetY + padY + iwHeight)) {
311                                yOffset = pixPosition.y + iwOffsetY - padY - iwHeight;
312                            } else if ((pixPosition.y + iwOffsetY + padY) > mapHeight) {
313                                yOffset = pixPosition.y + iwOffsetY + padY - mapHeight;
314                            }
315                        } else {
316                            if (pixPosition.y < (-iwOffsetY + padY)) {
317                                yOffset = pixPosition.y + iwOffsetY - padY;
318                            } else if ((pixPosition.y + iwHeight + iwOffsetY + padY) > mapHeight) {
319                                yOffset = pixPosition.y + iwHeight + iwOffsetY + padY - mapHeight;
320                            }
321                        }
322        
323                        if (!(xOffset === 0 && yOffset === 0)) {
324        
325                            // Move the map to the shifted center.
326                            //
327                            var c = map.getCenter();
328                            map.panBy(xOffset, yOffset);
329                        }
330                    }
331                }
332            }
333        };
334        
335        /**
336         * Sets the style of the InfoBox by setting the style sheet and applying
337         * other specific styles requested.
338         * @private
339         */
340        InfoBox.prototype.setBoxStyle_ = function() {
341        
342            var i, boxStyle;
343        
344            if (this.div_) {
345        
346                // Apply style values from the style sheet defined in the boxClass parameter:
347                this.div_.className = this.boxClass_;
348        
349                // Clear existing inline style values:
350                this.div_.style.cssText = "";
351        
352                // Apply style values defined in the boxStyle parameter:
353                boxStyle = this.boxStyle_;
354                for (i in boxStyle) {
355        
356                    if (boxStyle.hasOwnProperty(i)) {
357        
358                        this.div_.style[i] = boxStyle[i];
359                    }
360                }
361        
362                // Fix for iOS disappearing InfoBox problem.
363                // See http://stackoverflow.com/questions/9229535/google-maps-markers-disappear-at-certain-zoom-level-only-on-iphone-ipad
364                // Required: use "matrix" technique to specify transforms in order to avoid this bug.
365                if ((typeof this.div_.style.WebkitTransform === "undefined") || (this.div_.style.WebkitTransform.indexOf("translateZ") === -1 && this.div_.style.WebkitTransform.indexOf("matrix") === -1)) {
366        
367                    this.div_.style.WebkitTransform = "translateZ(0)";
368                }
369        
vendor: 12,352 bytes, lines 370-737
370                // Fix up opacity style for benefit of MSIE:
371                //
372                if (typeof this.div_.style.opacity !== "undefined" && this.div_.style.opacity !== "") {
373                    // See http://www.quirksmode.org/css/opacity.html
374                    this.div_.style.MsFilter = "\"progid:DXImageTransform.Microsoft.Alpha(Opacity=" + (this.div_.style.opacity * 100) + ")\"";
375                    this.div_.style.filter = "alpha(opacity=" + (this.div_.style.opacity * 100) + ")";
376                }
377        
378                // Apply required styles:
379                //
380                this.div_.style.position = "absolute";
381                this.div_.style.visibility = 'hidden';
382                if (this.zIndex_ !== null) {
383        
384                    this.div_.style.zIndex = this.zIndex_;
385                }
386            }
387        };
388        
389        /**
390         * Get the widths of the borders of the InfoBox.
391         * @private
392         * @return {Object} widths object (top, bottom left, right)
393         */
394        InfoBox.prototype.getBoxWidths_ = function() {
395        
396            var computedStyle;
397            var bw = {
398                top: 0,
399                bottom: 0,
400                left: 0,
401                right: 0
402            };
403            var box = this.div_;
404        
405            if (document.defaultView && document.defaultView.getComputedStyle) {
406        
407                computedStyle = box.ownerDocument.defaultView.getComputedStyle(box, "");
408        
409                if (computedStyle) {
410        
411                    // The computed styles are always in pixel units (good!)
412                    bw.top = parseInt(computedStyle.borderTopWidth, 10) || 0;
413                    bw.bottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
414                    bw.left = parseInt(computedStyle.borderLeftWidth, 10) || 0;
415                    bw.right = parseInt(computedStyle.borderRightWidth, 10) || 0;
416                }
417        
418            } else if (document.documentElement.currentStyle) { // MSIE
419        
420                if (box.currentStyle) {
421        
422                    // The current styles may not be in pixel units, but assume they are (bad!)
423                    bw.top = parseInt(box.currentStyle.borderTopWidth, 10) || 0;
424                    bw.bottom = parseInt(box.currentStyle.borderBottomWidth, 10) || 0;
425                    bw.left = parseInt(box.currentStyle.borderLeftWidth, 10) || 0;
426                    bw.right = parseInt(box.currentStyle.borderRightWidth, 10) || 0;
427                }
428            }
429        
430            return bw;
431        };
432        
433        /**
434         * Invoked when <tt>close</tt> is called. Do not call it directly.
435         */
436        InfoBox.prototype.onRemove = function() {
437        
438            if (this.div_) {
439        
440                this.div_.parentNode.removeChild(this.div_);
441                this.div_ = null;
442            }
443        };
444        
445        /**
446         * Draws the InfoBox based on the current map projection and zoom level.
447         */
448        InfoBox.prototype.draw = function() {
449        
450            this.createInfoBoxDiv_();
451        
452            var pixPosition = this.getProjection().fromLatLngToDivPixel(this.position_);
453        
454            this.div_.style.left = (pixPosition.x + this.pixelOffset_.width) + "px";
455        
456            if (this.alignBottom_) {
457                this.div_.style.bottom = -(pixPosition.y + this.pixelOffset_.height) + "px";
458            } else {
459                this.div_.style.top = (pixPosition.y + this.pixelOffset_.height) + "px";
460            }
461        
462            if (this.isHidden_) {
463        
464                this.div_.style.visibility = "hidden";
465        
466            } else {
467        
468                this.div_.style.visibility = "visible";
469            }
470        };
471        
472        /**
473         * Sets the options for the InfoBox. Note that changes to the <tt>maxWidth</tt>,
474         *  <tt>closeBoxMargin</tt>, <tt>closeBoxTitle</tt>, <tt>closeBoxURL</tt>, and
475         *  <tt>enableEventPropagation</tt> properties have no affect until the current
476         *  InfoBox is <tt>close</tt>d and a new one is <tt>open</tt>ed.
477         * @param {InfoBoxOptions} opt_opts
478         */
479        InfoBox.prototype.setOptions = function(opt_opts) {
480            if (typeof opt_opts.boxClass !== "undefined") { // Must be first
481        
482                this.boxClass_ = opt_opts.boxClass;
483                this.setBoxStyle_();
484            }
485            if (typeof opt_opts.boxStyle !== "undefined") { // Must be second
486        
487                this.boxStyle_ = opt_opts.boxStyle;
488                this.setBoxStyle_();
489            }
490            if (typeof opt_opts.content !== "undefined") {
491        
492                this.setContent(opt_opts.content);
493            }
494            if (typeof opt_opts.disableAutoPan !== "undefined") {
495        
496                this.disableAutoPan_ = opt_opts.disableAutoPan;
497            }
498            if (typeof opt_opts.maxWidth !== "undefined") {
499        
500                this.maxWidth_ = opt_opts.maxWidth;
501            }
502            if (typeof opt_opts.pixelOffset !== "undefined") {
503        
504                this.pixelOffset_ = opt_opts.pixelOffset;
505            }
506            if (typeof opt_opts.alignBottom !== "undefined") {
507        
508                this.alignBottom_ = opt_opts.alignBottom;
509            }
510            if (typeof opt_opts.position !== "undefined") {
511        
512                this.setPosition(opt_opts.position);
513            }
514            if (typeof opt_opts.zIndex !== "undefined") {
515        
516                this.setZIndex(opt_opts.zIndex);
517            }
518            if (typeof opt_opts.closeBoxMargin !== "undefined") {
519        
520                this.closeBoxMargin_ = opt_opts.closeBoxMargin;
521            }
522            if (typeof opt_opts.closeBoxURL !== "undefined") {
523        
524                this.closeBoxURL_ = opt_opts.closeBoxURL;
525            }
526            if (typeof opt_opts.closeBoxTitle !== "undefined") {
527        
528                this.closeBoxTitle_ = opt_opts.closeBoxTitle;
529            }
530            if (typeof opt_opts.infoBoxClearance !== "undefined") {
531        
532                this.infoBoxClearance_ = opt_opts.infoBoxClearance;
533            }
534            if (typeof opt_opts.isHidden !== "undefined") {
535        
536                this.isHidden_ = opt_opts.isHidden;
537            }
538            if (typeof opt_opts.visible !== "undefined") {
539        
540                this.isHidden_ = !opt_opts.visible;
541            }
542            if (typeof opt_opts.enableEventPropagation !== "undefined") {
543        
544                this.enableEventPropagation_ = opt_opts.enableEventPropagation;
545            }
546        
547            if (this.div_) {
548        
549                this.draw();
550            }
551        };
552        
553        /**
554         * Sets the content of the InfoBox.
555         *  The content can be plain text or an HTML DOM node.
556         * @param {string|Node} content
557         */
558        InfoBox.prototype.setContent = function(content) {
559            this.content_ = content;
560        
561            if (this.div_) {
562        
563                if (this.closeListener_) {
564        
565                    google.maps.event.removeListener(this.closeListener_);
566                    this.closeListener_ = null;
567                }
568        
569                // Odd code required to make things work with MSIE.
570                //
571                if (!this.fixedWidthSet_) {
572        
573                    this.div_.style.width = "";
574                }
575        
576                if (typeof content.nodeType === "undefined") {
577                    this.div_.innerHTML = this.getCloseBoxImg_() + content;
578                } else {
579                    this.div_.innerHTML = this.getCloseBoxImg_();
580                    this.div_.appendChild(content);
581                }
582        
583                // Perverse code required to make things work with MSIE.
584                // (Ensures the close box does, in fact, float to the right.)
585                //
586                if (!this.fixedWidthSet_) {
587                    this.div_.style.width = this.div_.offsetWidth + "px";
588                    if (typeof content.nodeType === "undefined") {
589                        this.div_.innerHTML = this.getCloseBoxImg_() + content;
590                    } else {
591                        this.div_.innerHTML = this.getCloseBoxImg_();
592                        this.div_.appendChild(content);
593                    }
594                }
595        
596                this.addClickHandler_();
597            }
598        
599            /**
600             * This event is fired when the content of the InfoBox changes.
601             * @name InfoBox#content_changed
602             * @event
603             */
604            google.maps.event.trigger(this, "content_changed");
605        };
606        
607        /**
608         * Sets the geographic location of the InfoBox.
609         * @param {LatLng} latlng
610         */
611        InfoBox.prototype.setPosition = function(latlng) {
612        
613            this.position_ = latlng;
614        
615            if (this.div_) {
616        
617                this.draw();
618            }
619        
620            /**
621             * This event is fired when the position of the InfoBox changes.
622             * @name InfoBox#position_changed
623             * @event
624             */
625            google.maps.event.trigger(this, "position_changed");
626        };
627        
628        /**
629         * Sets the zIndex style for the InfoBox.
630         * @param {number} index
631         */
632        InfoBox.prototype.setZIndex = function(index) {
633        
634            this.zIndex_ = index;
635        
636            if (this.div_) {
637        
638                this.div_.style.zIndex = index;
639            }
640        
641            /**
642             * This event is fired when the zIndex of the InfoBox changes.
643             * @name InfoBox#zindex_changed
644             * @event
645             */
646            google.maps.event.trigger(this, "zindex_changed");
647        };
648        
649        /**
650         * Sets the visibility of the InfoBox.
651         * @param {boolean} isVisible
652         */
653        InfoBox.prototype.setVisible = function(isVisible) {
654        
655            this.isHidden_ = !isVisible;
656            if (this.div_) {
657                this.div_.style.visibility = (this.isHidden_ ? "hidden" : "visible");
658            }
659        };
660        
661        /**
662         * Returns the content of the InfoBox.
663         * @returns {string}
664         */
665        InfoBox.prototype.getContent = function() {
666        
667            return this.content_;
668        };
669        
670        /**
671         * Returns the geographic location of the InfoBox.
672         * @returns {LatLng}
673         */
674        InfoBox.prototype.getPosition = function() {
675        
676            return this.position_;
677        };
678        
679        /**
680         * Returns the zIndex for the InfoBox.
681         * @returns {number}
682         */
683        InfoBox.prototype.getZIndex = function() {
684        
685            return this.zIndex_;
686        };
687        
688        /**
689         * Returns a flag indicating whether the InfoBox is visible.
690         * @returns {boolean}
691         */
692        InfoBox.prototype.getVisible = function() {
693        
694            var isVisible;
695        
696            if ((typeof this.getMap() === "undefined") || (this.getMap() === null)) {
697                isVisible = false;
698            } else {
699                isVisible = !this.isHidden_;
700            }
701            return isVisible;
702        };
703        
704        /**
705         * Returns the width of the InfoBox in pixels.
706         * @returns {number}
707         */
708        InfoBox.prototype.getWidth = function() {
709            var width = null;
710        
711            if (this.div_) {
712                width = this.div_.offsetWidth;
713            }
714        
715            return width;
716        };
717        
718        /**
719         * Returns the height of the InfoBox in pixels.
720         * @returns {number}
721         */
722        InfoBox.prototype.getHeight = function() {
723            var height = null;
724        
725            if (this.div_) {
726                height = this.div_.offsetHeight;
727            }
728        
729            return height;
730        };
731        
732        /**
733         * Shows the InfoBox. [Deprecated; use <tt>setVisible</tt> instead.]
734         */
735        InfoBox.prototype.show = function() {
736        
737            this.isHidden_ = false;
738            if (this.div_) {
739                this.div_.style.visibility = "visible";
740            }
741        };
742        
743        /**
744         * Hides the InfoBox. [Deprecated; use <tt>setVisible</tt> instead.]
745         */
746        InfoBox.prototype.hide = function() {
747        
748            this.isHidden_ = true;
749            if (this.div_) {
750                this.div_.style.visibility = "hidden";
751            }
752        };
753        
754        /**
755         * Adds the InfoBox to the specified map or Street View panorama. If <tt>anchor</tt>
756         *  (usually a <tt>google.maps.Marker</tt>) is specified, the position
757         *  of the InfoBox is set to the position of the <tt>anchor</tt>. If the
758         *  anchor is dragged to a new location, the InfoBox moves as well.
759         * @param {Map|StreetViewPanorama} map
760         * @param {MVCObject} [anchor]
761         */
762        InfoBox.prototype.open = function(map, anchor) {
763        
764            var me = this;
765        
766            if (anchor) {
767        
768                this.setPosition(anchor.getPosition()); // BUG FIX 2/17/2018: needed for v3.32
769                this.moveListener_ = google.maps.event.addListener(anchor, "position_changed", function() {
770                    me.setPosition(this.getPosition());
771                });
772            }
773        
774            this.setMap(map);
775        
776            if (this.div_) {
777        
778                this.panBox_(this.disableAutoPan_); // BUG FIX 2/17/2018: add missing parameter
779            }
780        };
781        
782        /**
783         * Removes the InfoBox from the map.
784         */
785        InfoBox.prototype.close = function() {
786        
787            var i;
788        
789            if (this.closeListener_) {
790        
791                google.maps.event.removeListener(this.closeListener_);
792                this.closeListener_ = null;
793            }
794        
795            if (this.eventListeners_) {
796        
797                for (i = 0; i < this.eventListeners_.length; i++) {
798        
799                    google.maps.event.removeListener(this.eventListeners_[i]);
800                }
801                this.eventListeners_ = null;
802            }
803        
804            if (this.moveListener_) {
805        
806                google.maps.event.removeListener(this.moveListener_);
807                this.moveListener_ = null;
808            }
809        
810            if (this.contextListener_) {
811        
812                google.maps.event.removeListener(this.contextListener_);
813                this.contextListener_ = null;
814            }
815        
816            this.setMap(null);
817        };
818
819        return new InfoBox();
820        
821        }
822    function GoogleMaps(element, map_data) {
823        var options;
824        this.element = element;
825        map_data = JSON.parse(atob(map_data));
826        this.map_data = $.extend({}, {}, map_data);
827        options = this.map_data.map_options;
828        this.settings = $.extend({
829            "zoom": "5",
830            "map_type_id": "ROADMAP",
831            "scroll_wheel": true,
832            "map_visual_refresh": false,
833            "full_screen_control": false,
834            "full_screen_control_position": "BOTTOM_RIGHT",
835            "zoom_control": true,
836            "zoom_control_style": "SMALL",
837            "zoom_control_position": "TOP_LEFT",
838            "map_type_control": true,
839            "map_type_control_style": "HORIZONTAL_BAR",
840            "map_type_control_position": "RIGHT_TOP",
841            "scale_control": true,
842            "street_view_control": true,
843            "street_view_control_position": "TOP_LEFT",
844            "overview_map_control": true,
845            "center_lat": "40.6153983",
846            "center_lng": "-74.2535216",
847            "draggable": true
848        }, {}, options);
849        this.container = $("div[rel='" + $(this.element).attr("id") + "']");
850        $(document).find(".wpgmp_map_container_placeholder").remove();
851        $(document).find(".wpgmp_hide_map_container").removeClass("wpgmp_hide_map_container");
852
853        var suppress_markers = false;
854        if (this.map_data.map_tabs && this.map_data.map_tabs.direction_tab) {
855            suppress_markers = this.map_data.map_tabs.direction_tab.suppress_markers;
856        }
857        this.directionsService = new google.maps.DirectionsService();
858        this.directionsDisplay = new google.maps.DirectionsRenderer({
859            suppressMarkers: suppress_markers,
860        });
861        this.drawingmanager = {};
862        this.geocoder = new google.maps.Geocoder();
863        this.places = [];
864        this.show_places = [];
865        this.categories = {};
866        this.tabs = [];
867        this.all_shapes = [];
868        this.wpgmp_polylines = [];
869        this.wpgmp_polygons = [];
870        this.wpgmp_circles = [];
871        this.wpgmp_shape_events = [];
872        this.wpgmp_rectangles = [];
873        this.per_page_value = 0;
874        this.current_amenities = [];
875        this.route_directions = [];
876        this.search_area = '';
877        this.infobox = wpgmpInitializeInfoBox();
878        this.markerClusterer = null;
879        this.infowindow_marker = new google.maps.InfoWindow();
880        this.init();
881    }
882
883    GoogleMaps.prototype = {
884
885        init: function() {
886            var map_obj = this;
887            if (map_obj.map_data.map_property && map_obj.map_data.map_property.debug_mode == true) {
888                console.log('*********WPGMP Debug Mode Output*********');
889                console.log('Map ID =' + map_obj.map_data.map_property.map_id);
890                if (map_obj.map_data.places) {
891                    console.log('Total Locations=' + map_obj.map_data.places.length);
892                }
893                console.log('WPGMP Object=');
894                console.log(map_obj.map_data);
895                console.log('*********WPGMP Debug Mode End Output*********');
896            }
897            var center = new google.maps.LatLng(map_obj.settings.center_lat, map_obj.settings.center_lng);
898            map_obj.map = new google.maps.Map(map_obj.element, {
899                zoom: parseInt(map_obj.settings.zoom),
900                center: center,
901                disableDoubleClickZoom: (map_obj.settings.scroll_wheel != 'false'),
902                scrollwheel: map_obj.settings.scroll_wheel,
903                zoomControl: (map_obj.settings.zoom_control === true),
904                fullscreenControl: (map_obj.settings.full_screen_control === true),
905                fullscreenControlOptions: {
906                    position: eval("google.maps.ControlPosition." + map_obj.settings.full_screen_control_position)
907                },
908                zoomControlOptions: {
909                    style: eval("google.maps.ZoomControlStyle." + map_obj.settings.zoom_control_style),
910                    position: eval("google.maps.ControlPosition." + map_obj.settings.zoom_control_position)
911                },
912                mapTypeControl: (map_obj.settings.map_type_control == true),
913                mapTypeControlOptions: {
914                    style: eval("google.maps.MapTypeControlStyle." + map_obj.settings.map_type_control_style),
915                    position: eval("google.maps.ControlPosition." + map_obj.settings.map_type_control_position)
916                },
917                scaleControl: (map_obj.settings.scale_control == true),
918                streetViewControl: (map_obj.settings.street_view_control == true),
919                streetViewControlOptions: {
920                    position: eval("google.maps.ControlPosition." + map_obj.settings.street_view_control_position)
921                },
922                overviewMapControl: (map_obj.settings.overview_map_control == true),
923                overviewMapControlOptions: {
924                    opened: map_obj.settings.overview_map_control
925                },
926                draggable: map_obj.settings.draggable,
927                mapTypeId: eval("google.maps.MapTypeId." + map_obj.settings.map_type_id
927),
928                styles: eval(map_obj.map_data.styles)
929            });
930
931            map_obj.map_loaded();
932            map_obj.responsive_map();
933            map_obj.create_markers();
934            map_obj.display_markers();
935            if (typeof map_obj.settings.google_fonts !== 'undefined') {
936                map_obj.load_google_fonts(map_obj.settings.google_fonts);
937            }
938            
939            if ( map_obj.map_data.street_view ) {
940                map_obj.set_streetview(center);
941            }
942
943            if ( map_obj.map_data.bicyle_layer) {
944                map_obj.set_bicyle_layer();
945            }
946
947            if ( map_obj.map_data.traffic_layer) {
948                map_obj.set_traffic_layer();
949            }
950
951            if (map_obj.map_data.transit_layer) {
952                map_obj.set_transit_layer();
953            }
954
955            if ( map_obj.map_data.panoramio_layer ) {
956                map_obj.set_panoramic_layer();
957            }
958
959            if (map_obj.settings.display_45_imagery == '45') {
960                map_obj.set_45_imagery();
961            }
962
963            if (typeof map_obj.map_data.map_visual_refresh === true) {
964                map_obj.set_visual_refresh();
965            }     
966
967
968            if (map_obj.map_data.marker_cluster) {
969                map_obj.set_marker_cluster();
970            }      
971       
972            if (map_obj.settings.search_control == true) {
973                map_obj.show_search_control();
974            }
975                 
976            if (map_obj.map_data.listing) {
977
978                    $(map_obj.container).on('click', '.categories_filter_reset_btn', function() {
979
980                        $(map_obj.container).find('.wpgmp_filter_wrappers select').each(function() {
981                            $(this).find('option:first').attr('selected', 'selected');
982                        });
983                        $('.wpgmp_search_input').val('');
984                        map_obj.update_filters();
985                        
986                    });
987
988
989                    $(map_obj.container).on('change', '[data-filter="dropdown"]', function() {
990                        map_obj.update_filters();
991                    });
992
993                    $(map_obj.container).on('click', '[data-filter="checklist"]', function() {
994                        map_obj.update_filters();
995                    });
996
997                    $(map_obj.container).on('click', '[data-filter="list"]', function() {
998
999                        if ($(this).hasClass('fc_selected')) {
1000                            $(this).removeClass('fc_selected');
1001                        } else {
1002                            $(this).addClass('fc_selected');
1003                        }
1004
1005                        map_obj.update_filters();
1006                    });
1007                    
1008                    map_obj.display_filters_listing();
1009
1010                    $.each(map_obj.map_data.listing.filters, function(key, filter) {
1011
1012                        $(map_obj.container).find('select[name="' + filter + '"]').on('change', function() {
1013                            map_obj.update_filters();
1014                        });
1015
1016                    });                    
1017
1018                    $(map_obj.container).find('[data-name="radius"]').on('change', function() {
1019
1020                        var search_data = $(map_obj.container).find('[data-input="wpgmp-search-text"]').val();
1021                        if (search_data.length >= 2 && $(this).val() != '') {
1022                            map_obj.geocoder.geocode({
1023                                "address": search_data
1024                            }, function(results, status) {
1025
1026                                if (status == google.maps.GeocoderStatus.OK) {
1027                                    map_obj.search_area = results[0].geometry.location;
1028                                    map_obj.update_filters();
1029                                }
1030
1031                            });
1032                        } else {
1033                            map_obj.search_area = '';
1034                            map_obj.update_filters();
1035                        }
1036
1037
1038                    });
1039
1040                    $(map_obj.container).find('[data-filter="map-perpage-location-sorting"]').on('change', function() {
1041
1042                        map_obj.per_page_value = $(this).val();
1043                        map_obj.update_filters();
1044
1045                    });
1046
1047                    $(map_obj.container).find('[data-input="wpgmp-search-text"]').on('keyup', function() {
1048                        var search_data = $(this).val();
1049                        $(map_obj.container).find('[data-filter="map-radius"]').val('');
1050                        map_obj.search_area = '';
1051                        // Apply default radius
1052                        if (search_data.length >
1052= 2 && map_obj.map_data.listing.apply_default_radius == true) {
1053                            if (search_data.length >= 2) {
1054                                map_obj.geocoder.geocode({
1055                                    "address": search_data
1056                                }, function(results, status) {
1057
1058                                    if (status == google.maps.GeocoderStatus.OK) {
1059                                        map_obj.search_area = results[0].geometry.location;
1060                                        map_obj.update_filters();
1061                                    }
1062
1063                                });
1064                            }
1065
1066                        } else {
1067                            map_obj.update_filters();
1068                        }
1069
1070
1071                    });
1072
1073            }
1074                
1075            $("body").on("click", ".wpgmp_marker_link", function() {
1076                map_obj.open_infowindow($(this).data("marker"));
1077                $('html, body').animate({
1078                    scrollTop: $(map_obj.container).offset().top - 150
1079                }, 500);
1080            });
1081
1082            $(map_obj.container).on("click", "a[data-marker]", function() {
1083                map_obj.open_infowindow($(this).data("marker"));
1084                $('html, body').animate({
1085                    scrollTop: $(map_obj.container).offset().top - 150
1086                }, 500);
1087            });
1088
1089            $(map_obj.container).on("click", "a[data-marker]", function() {
1090                map_obj.open_infowindow($(this).data("marker"));
1091            });
1092
1093            // REGISTER AUTO SUGGEST
1094            map_obj.google_auto_suggest($(".wpgmp_auto_suggest"));
1095
1096            if (map_obj.settings.fit_bounds === true) {
1097                map_obj.fit_bounds();
1098            }
1099
1100        },
1101        load_google_fonts: function(fonts) {
1102            if (fonts && fonts.length > 0) {
1103                $.each(fonts, function(k, font) {
1104                    if (font.indexOf(',') >= 0) {
1105                        font = font.split(",");
1106                        font = font[0];
1107                    }
1108                    if (font.indexOf('"') >= 0) {
1109                        font = font.replace('"', '');
1110                        font = font.replace('"', '');
1111                    }
1112                    WebFont.load({
1113                        google: {
1114                            families: [font]
1115                        }
1116                    });
1117                });
1118            }
1119        },
1120
1121        createMarker: function(place) {
1122            var map_obj = this;
1123            var map = map_obj.map;
1124            var placeLoc = place.geometry.location;
1125            var image = {
1126                url: place.icon,
1127                size: new google.maps.Size(25, 25),
1128                scaledSize: new google.maps.Size(25, 25)
1129            };
1130
1131            place.marker = new google.maps.Marker({
1132                map: map,
1133                position: place.geometry.location,
1134                icon: image
1135            });
1136
1137            google.maps.event.addListener(place.marker, 'click', function() {
1138                 if (map_obj.settings.map_infowindow_customisations === true)
1139                    map_obj.amenity_infowindow.setContent('<div class="wpgmp_infowindow"><div class="wpgmp_iw_content">' + place.name + '</div></div>');
1140                else
1141                    map_obj.amenity_infowindow.setContent(place.name);
1142                map_obj.amenity_infowindow.open(map, this);
1143            });
1144            map_obj.current_amenities.push(place);
1145        },
1146       
1147        marker_bind: function(marker) {
1148
1149            var map_obj = this;
1150
1151            google.maps.event.addListener(marker, 'drag', function() {
1152
1153                var position = marker.getPosition();
1154
1155                map_obj.geocoder.geocode({
1156                    latLng: position
1157                }, function(results, status) {
1158
1159                    if (status == google.maps.GeocoderStatus.OK) {
1160
1161                        $("#googlemap_address").val(results[0].formatted_address);
1162
1163                        $(".google_city").val(map_obj.wpgmp_finddata(results[0], 'administrative_area_level_3') || map_obj.wpgmp_finddata(results[0], 'locality'));
1164                        $(".google_state").val(map_obj.wpgmp_finddata(results[0], "administrative_area_level_1"));
1165                        $(".google_country").val(map_obj.wpgmp_finddata(results[0], "country"));
1166
1167                        if (results[0].address_components) {
1168                            for (var i = 0; i < results[0].address_components.length; i++) {
1169                                for (var j = 0; j < results[0].address_components[i].types.length; j++) {
1170                                    if (results[0].address_components[i].types[j] == "postal_code") {
1171                                        var wpgmp_zip_code = results[0].address_components[i].long_name;
1172                                        $(".google_postal_code").val(wpgmp_zip_code);
1173                                    }
1174                                }
1175                            }
1176                        }
1177                    }
1178                });
1179
1180                $(".google_latitude").val(position.lat());
1181                $(".google_longitude").val(position.lng());
1182            });
1183
1184        },
1185
1186        google_auto_suggest: function(obj) {
1187
1188            var map_obj = this;
1189
1190            obj.each(function() {
1191                var current_input = this;
1192                var autocomplete = new google.maps.places.Autocomplete(this);
1193
1194                autocomplete.bindTo('bounds', map_obj.map);
1195
1196                if ($(this).attr("name") == 'location_address') {
1197                    var infowindow = map_obj.infowindow_marker;
1198                    var marker = new google.maps.Marker({
1199                        map: map_obj.map,
1200                        draggable: true,
1201                        anchorPoint: new google.maps.Point(0, -29)
1202                    });
1203
1204                    map_obj.marker_bind(marker);
1205
1206                    google.maps.event.addListener(autocomplete, 'place_changed', function() {
1207
1208                        var place = autocomplete.getPlace();
1209                        if (!place.geometry) {
1210                            return;
1211                        }
1212
1213                        // If the place has a geometry, then present it on a map.
1214                        if (place.geometry.viewport) {
1215                            map_obj.map.fitBounds(place.geometry.viewport);
1216                        } else {
1217                            map_obj.map.setCenter(place.geometry.location);
1218                            map_obj.map.setZoom(17);
1219                        }
1220
1221                        $(".google_latitude").val(place.geometry.location.lat());
1222                        $(".google_longitude").val(place.geometry.location.lng());
1223                        $(".google_city").val(map_obj.wpgmp_finddata(place, 'administrative_area_level_3') || map_obj.wpgmp_finddata(place, 'locality'));
1224                        $(".google_state").val(map_obj.wpgmp_finddata(place, "administrative_area_level_1"));
1225                        $(".google_country").val(map_obj.wpgmp_finddata(place, "country"));
1226                        if (place.address_components) {
1227                            for (var i = 0; i < place.address_components.length; i++) {
1228                                for (var j = 0; j < place.address_components[i].types.length; j++) {
1229                                    if (place.address_components[i].types[j] == "postal_code") {
1230                                        var wpgmp_zip_code = place.address_components[i].long_name;
1231                                        $(".google_postal_code").val(wpgmp_zip_code);
1232                                    }
1233                                }
1234                            }
1235                        }
1236
1237                        marker.setPosition(place.geometry.location);
1238                        marker.setVisible(true);
1239                    });
1240                } else {
1241
1242                    google.maps.event.addListener(autocomplete, 'place_changed', function() {
1243
1244                        var place = autocomplete.getPlace();
1245                        if (!place.geometry) {
1246                            return;
1247                        }
1248
1249                        $().val(place.geometry.location.lat());
1250                        $(current_input).data('longitude', place.geometry.location.lng());
1251                        $(current_input).data('latitude', place.geometry.location.lat());
1252
1253                    });
1254                }
1255            });
1256        },
1257
1258        wpgmp_finddata: function(result, type) {
1259            var component_name = "";
1260            for (var i = 0; i < result.address_components.length; ++i) {
1261                var component = result.address_components[i];
1262                $.each(component.types, function(index, value) {
1263                    if (value == type) {
1264                        component_name = component.long_name;
1265                    }
1266                });
1267
1268
1269            }
1270            return component_name;
1271        },
1272
1273        open_infowindow: function(current_place) {
1274            var map_obj = this;
1275
1276            $.each(this.map_data.places, function(key, place) {
1277                if (parseInt(place.id) == parseInt(current_place) && place.marker.visible === true) {
1278                   map_obj.openInfoWindow(place);
1279                }
1280            });
1281        },
1282
1283        place_info: function(place_id) {
1284
1285            var place_obj;
1286
1287            $.each(this.places, function(index, place) {
1288
1289                if (parseInt(place.id) == parseInt(place_id)) {
1290                    place_obj = place;
1291                }
1292            });
1293
1294            return place_obj;
1295        },
1296
1297        event_listener: function(obj, type, func) {
1298            google.maps.event.addListener(obj, type, func);
1299        },
1300
1301        set_visual_refresh: function() {
1302
1303            google.maps.visualRefresh = true;
1304        },
1305
1306        set_45_imagery: function() {
1307            this.map.setTilt(45);
1308        },
1309
1310        set_bicyle_layer: function() {
1311
1312            var bikeLayer = new google.maps.BicyclingLayer();
1313            bikeLayer.setMap(this.map);
1314        },
1315
1316        set_traffic_layer: function() {
1317
1318            var traffic_layer = new google.maps.TrafficLayer();
1319            traffic_layer.setMap(this.map);
1320        },
1321
1322        set_panoramic_layer: function() {
1323
1324            var panoramic_layer = new google.maps.panoramio.PanoramioLayer();
1325            panoramic_layer.setMap(this.map);
1326        },
1327
1328        set_transit_layer: function() {
1329
1330            var transit_layer = new google.maps.TransitLayer();
1331            transit_layer.setMap(this.map);
1332        },
1333
1334        set_streetview: function(latlng) {
1335
1336            var panoOptions = {
1337                position: latlng,
1338                addressControlOptions: {
1339                    position: google.maps.ControlPosition.BOTTOM_CENTER
1340                },
1341                linksControl: this.map_data.street_view.links_control,
1342                panControl: this.map_data.street_view.street_view_pan_control,
1343                zoomControlOptions: {
1344                    style: google.maps.ZoomControlStyle.SMALL
1345                },
1346                enableCloseButton: this.map_data.street_view.street_view_close_button
1347            };
1348            if (this.map_data.street_view.pov_heading && this.map_data.street_view.pov_pitch) {
1349                panoOptions['pov'] = {
1350                    heading: parseInt(this.map_data.street_view.pov_heading),
1351                    pitch: parseInt(this.map_data.street_view.pov_pitch)
1352                };
1353            }
1354            var panorama = new google.maps.StreetViewPanorama(this.element, panoOptions);
1355        },
1356
1357        set_marker_cluster: function() {
1358            var map_obj = this;
1359            var markers = [];
1360            var clusterStyles = [{
1361                textColor: 'black',
1362                url: map_obj.map_data.marker_cluster.icon,
1363                height: 32,
1364                width: 33
1365            }];
1366            $.each(this.places, function(index, place) {
1367                if (place.marker.visible == true) {
1368                    markers.push(place.marker);
1369                }
1370
1371            });
1372
1373            if (map_obj.map_data.marker_cluster.apply_style === true) {
1374                if (!map_obj.markerClusterer) {
1375                    map_obj.markerClusterer = new MarkerClusterer(map_obj.map, {}, {
1376                        gridSize: parseInt(map_obj.map_data.marker_cluster.grid),
1377                        maxZoom: parseInt(map_obj.map_data.marker_cluster.max_zoom),
1378                        styles: clusterStyles
1379
1380                    });
1381                }
1382
1383                map_obj.markerClusterer.clearMarkers();
1384                map_obj.markerClusterer.addMarkers(markers);
1385
1386                google.maps.event.addListener(map_obj.markerClusterer, 'mouseover', function(c) {
1387
1388                    c.clusterIcon_.div_.firstChild.src = map_obj.map_data.marker_cluster.hover_icon
1389                });
1390
1391                google.maps.event.addListener(map_obj.markerClusterer, 'mouseout', function(c) {
1392                    c.clusterIcon_.div_.firstChild.src = map_obj.map_data.marker_cluster.icon
1393                });
1394
1395            } else {
1396                if (!map_obj.markerClusterer) {
1397                    map_obj.markerClusterer = new MarkerClusterer(map_obj.map, {}, {
1398                        gridSize: parseInt(map_obj.map_data.marker_cluster.grid),
1399                        maxZoom: parseInt(map_obj.map_data.marker_cluster.max_zoom),
1400                        imagePath: map_obj.map_data.marker_cluster.image_path,
1401                    });
1402                }
1403
1404                map_obj.markerClusterer.clearMarkers();
1405                map_obj.markerClusterer.addMarkers(markers);
1406
1407
1408            }
1409
1410        },
1411
1412        sortByPlace: function(order_by, data_type) {
1413
1414            return function(a, b) {
1415
1416                if (b[order_by] && a[order_by]) {
1417
1418                    if (a[order_by] && b[order_by]) {
1419                        var a_val = a[order_by].toLowerCase();
1420                        var b_val = b[order_by].toLowerCase();
1421                        if (data_type == 'num') {
1422                            a_val = parseInt(a_val);
1423                            b_val = parseInt(b_val);
1424                        }
1425                        return ((a_val < b_val) ? -1 : ((a_val > b_val) ? 1 : 0));
1426                    }
1427
1428                }
1429            }
1430
1431        },       
1432
1433        sort_object_by_keyvalue: function(options, by, type, in_order) {
1434
1435            var sortable = [];
1436            for (var key in options) {
1437                sortable.push(options[key]);
1438            }
1439
1440            sortable.sort(this.sortByPlace(by, type));
1441
1442            if (in_order == 'desc') {
1443                sortable.reverse();
1444            }
1445
1446            return sortable;
1447        },     
1448
1449        create_filters: function() {
1450            var map_obj = this;
1451            var options = '';
1452            var filters = {};
1453            var places = this.map_data.places;
1454            var wpgmp_listing_filter = this.map_data.listing;
1455
1456            $.each(places, function(index, place) {
1457                if (typeof place.categories == 'undefined') {
1458                 place.categories = {}; 
1459                }
1460
1461                $.each(place.categories, function(cat_index, category) {
1462                    if (typeof filters[category.type] == 'undefined') {
1463                        filters[category.type] = {};
1464                    }
1465
1466                    if (category.name) { 
1467                        if (category.extension_fields && category.extension_fields.cat_order) {
1468
1469                            filters[category.type][category.name] = {
1470                                'id': category.id,
1471                                'order': category.extension_fields.cat_order,
1472                                'name': category.name
1473                            };
1474                        } else { 
1475                            filters[category.type][category.name] = {
1476                            'id': category.id,
1477                            'order': 0,
1478                            'name': category.name
1479                            };
1480                        }
1481                    }
1482
1483                });
1484            });
1485            // now create select boxes
1486
1487            var content = '',
1488            by = 'name',
1489            type = '',
1490            inorder = 'asc';
1491
1492            if (map_obj.map_data.listing) {  
1493                if (map_obj.map_data.listing.default_sorting) {  
1494                    if (map_obj.map_data.listing.default_sorting.orderby == 'listorder') {
1495                        by = 'order';
1496                        type = 'num';
1497                        inorder = map_obj.map_data.listing.default_sorting.inorder;
1498                    }
1499                  inorder = map_obj.map_data.listing.default_sorting.inorder;
1500                }
1501            }
1502
1503            $.each(filters, function(index, options) {  
1504                if (wpgmp_listing_filter.display_category_filter === true && index == "category") {
1505                    content += '<select data-filter="dropdown" data-name="category" name="place_' + index + '">';
1506                    content += '<option value="">'+ wpgmp_local.select_category +'</option>';
1507                    options = map_obj.sort_object_by_keyvalue(options, by, type, inorder);
1508                    $.each(options, function(name, value) {
1509                         content += "<option value='" + value.id + "'>" + value.name + "</option>";
1510                    });
1511                    content += '</select>';
1512
1513                }
1514
1515            });
1516
1517            return content;
1518        },
1519
1520        update_filters: function() {
1521            var map_obj = this;
1522            var filters = {};
1523
1524            var all_dropdowns = $(map_obj.container).find('[data-filter="dropdown"]');
1525            var all_checkboxes = $(map_obj.container).find('[data-filter="checklist"]:checked');
1526            var all_list = $(map_obj.container).find('[data-filter="list"].fc_selected');
1527
1528            $.each(all_dropdowns, function(index, element) {
1529                if ($(this).val() != '') {
1530
1531                    if (typeof filters[$(this).data('name')] == 'undefined') {
1532                        filters[$(this).data('name')] = [];
1533                    }
1534
1535                    filters[$(this).data('name')].push($(this).val());
1536                }
1537
1538            });
1539
1540            $.each(all_checkboxes, function(index, element) {
1541
1542                if (typeof filters[$(this).data('name')] == 'undefined') {
1543                    filters[$(this).data('name')] = [];
1544                }
1545
1546                filters[$(this).data('name')].push($(this).val());
1547
1548            });
1549
1550            $.each(all_list, function(index, element) {
1551
1552                if (typeof filters[$(this).data('name')] == 'undefined') {
1553                    filters[$(this).data('name')] = [];
1554                }
1555
1556                filters[$(this).data('name')].push($(this).data('value').toString());
1557
1558            });
1559            this.apply_filters(filters);
1560
1561        },
1562        
1563        apply_filters: function(filters) {
1564
1565            var map_obj = this;
1566            var showAll = true;
1567            var show = true;
1568            map_obj.show_places = [];
1569
1570            var enable_search_term = false;
1571            // Filter by search box.
1572            if ($(map_obj.container).find('[data-input="wpgmp-search-text"]').length > 0) {
1573                var search_term = $(map_obj.container).find('[data-input="wpgmp-search-text"]').val();
1574                search_term = search_term.toLowerCase();
1575                if (search_term.length > 0) {
1576                    enable_search_term = true;
1577                }
1578            }
1579
1580            if (((map_obj.map_data.map_tabs && map_obj.map_data.map_tabs.category_tab && map_obj.map_data.map_tabs.category_tab.cat_tab === true) || $(map_obj.container).find('input[data-marker-category]').length > 0)) {
1581                var all_selected_category_sel = $(map_obj.container).find('input[data-marker-category]:checked');
1582                var all_selected_category = [];
1583                var all_not_selected_location = [];
1584                if (all_selected_category_sel.length > 0) {
1585                    $.each(all_selected_category_sel, function(index, selected_category) {
1586                        all_selected_category.push($(selected_category).data("marker-category"));
1587                        var all_not_selected_location_sel = $(selected_category).closest('[data-container="wpgmp-category-tab-item"]').find('input[data-marker-location]:not(:checked)');
1588                        if (all_not_selected_location_sel.length > 0) {
1589                            $.each(all_not_selected_location_sel, function(index, not_selected_location) {
1590                                all_not_selected_location.push($(not_selected_location).data("marker-location"));
1591                            });
1592                        }
1593                    });
1594                }
1595                var all_selected_location_sel = $(map_obj.container).find('[data-container="wpgmp-category-tab-item"]').find('input[data-marker-location]:checked');
1596                var all_selected_location = [];
1597                if (all_selected_location_sel.length > 0) {
1598                    $.each(all_selected_location_sel, function(index, selected_location) {
1599                        all_selected_location.push($(selected_location).data("marker-location"));
1600                    });
1601                }
1602            }
1603
1604
1605
1606            if (typeof map_obj.map_data.places != 'undefined') {
1607                $.each(map_obj.map_data.places, function(place_key, place) {
1608
1609                    show = true;
1610
1611                    if (typeof filters != 'undefined') {
1612                        $.each(filters, function(filter_key, filter_values) {
1613
1614                            var in_fields = false;
1615
1616                            if ($.isArray(filter_values)) {
1617
1618                                if (typeof place.categories != 'undefined' && filter_key == "category") {
1619
1620                                    $.each(place.categories, function(cat_index, category) {
1621                                        if ($.inArray(category.id, filter_values) > -1) {
1622                                            in_fields = true;
1623                                        }
1624                                    });
1625                                }
1626
1627                                if (typeof place[filter_key] != 'undefined') {
1628                                    if ($.inArray(place[filter_key], filter_values) > -1) {
1629                                        in_fields = true;
1630                                    }
1631                                } else if (typeof place.location[filter_key] != 'undefined') {
1632                                    if ($.inArray(place.location[filter_key], filter_values) > -1) {
1633                                        in_fields = true;
1634
1635                                    }
1636                                } else if (place.location.extra_fields && typeof place.location.extra_fields[filter_key] != 'undefined') {
1637
1638                                    var dropdown_value = filter_values[0];
1639                                    if (place.location.extra_fields[filter_key] && place.location.extra_fields[filter_key].indexOf(dropdown_value) > -1) {
1640                                        in_fields = true;
1641                                    } else if ($.inArray(place.location.extra_fields[filter_key], filter_values) > -1) {
1642                                        in_fields = true;
1643                                    }
1644
1645                                }
1646
1647                                if (in_fields == false)
1648                                    show = false;
1649
1650                            } else {
1651                                filter_values.val = "";
1652                            }
1653                        });
1654                    }
1655
1656                    //Apply Search Filter.
1657                    if (enable_search_term === true && show === true) {
1658
1659                        if (place.title != undefined && place.title.toLowerCase().indexOf(search_term) >= 0) {
1660                            show = true;
1661
1662                        } else if (place.content != undefined && place.content.toLowerCase().indexOf(search_term) >= 0) {
1663                            show = true;
1664
1665                        } else if (place.location.lat.toLowerCase().indexOf(search_term) >= 0) {
1666                            show = true;
1667
1668                        } else if (place.location.lng.toLowerCase().indexOf(search_term) >= 0) {
1669                            show = true;
1670
1671                        } else if (place.address && place.address.toLowerCase().indexOf(search_term) >= 0) {
1672                            show = true;
1673                        } else if (place.location.state && place.location.state.toLowerCase().indexOf(search_term) >= 0) {
1674                            show = true;
1675
1676                        } else if (place.location.country && place.location.country.toLowerCase().indexOf(search_term) >= 0) {
1677                            show = true;
1678
1679                        } else if (place.location.postal_code && place.location.postal_code.toLowerCase().indexOf(search_term) >= 0) {
1680                            show = true;
1681
1682                        } else if (place.location.city && place.location.city.toLowerCase().indexOf(search_term) >= 0) {
1683                            show = true;
1684                        } else if (typeof map_obj.search_area != 'undefined' && map_obj.search_area != '' && map_obj.wpgmp_within_radius(place, map_obj.search_area) === true) {
1685                            show = true;
1686                        } else {
1687                            show = false;
1688                        }
1689
1690                        if (typeof place.location.extra_fields != 'undefined') {
1691                            $.each(place.location.extra_fields, function(field, value) {
1692
1693                                if (value) {
1694                                    value = value.toString();
1695                                    if (value && value.toLowerCase().indexOf(search_term) >= 0)
1696                                        show = true;
1697                                }
1698
1699
1700                            });
1701                        }
1702
1703                    }
1704
1705                    //Exclude locations without category if location filters are choosed by user
1706                    if ((place.categories.length == undefined || place.categories.length == 'undefined') && all_selected_category && (all_selected_category.length > 0) && ($(map_obj.container).find('input[name="wpgmp_select_all"]').is(":checked") == false) && show) {
1707                        show = false;
1708                    }
1709
1710                    // if checked category
1711                    if (all_selected_category && show != false && place.categories.length != undefined) {
1712
1713                        var in_checked_category = false;
1714
1715                        if (all_selected_category.length === 0) {
1716                            // means no any category selected so show those location without categories.
1717                            if (typeof place.categories != 'undefined') {
1718                                $.each(place.categories, function(cat_index, category) {
1719                                    if (category.id === '')
1720                                        in_checked_category = true;
1721                                });
1722                            }
1723                        } else {
1724                            if (typeof place.categories != 'undefined') {
1725                                $.each(place.categories, function(cat_index, category) {
1726                                    if (category.id === '')
1727                                        in_checked_category = true;
1728                                    else if ($.inArray(parseInt(category.id), all_selected_category) > -1) {
1729                                        in_checked_category = true;
1730                                        place.marker.setIcon(category.icon);
1731                                    }
1732
1733                                });
1734                            }
1735                        }
1736
1737                        //Hide unchecked  locations.
1738                        if (all_not_selected_location.length !== 0) {
1739                            if ($.inArray(parseInt(place.id), all_not_selected_location) > -1) {
1740                                in_checked_category = false;
1741                            }
1742                        }
1743
1744                        //var checked_categories = $(map_obj.container).find('input[data-marker-category]:checked').length;
1745                        if (in_checked_category === false)
1746                            show = false;
1747                        else
1748                            show = true;
1749
1750
1751
1752                        //Show Here checked location.
1753                        if (all_selected_location.length !== 0) {
1754                            if ($.inArray(parseInt(place.id), all_selected_location) > -1) {
1755                                show = true;
1756                            }
1757                        }
1758
1759                    }
1760
1761
1762                    place.marker.visible = show;
1763                    place.marker.setVisible(show);
1764                    if (show == false) {
1765                        place.infowindow.close();
1766                    }
1767                    place.marker.setAnimation(null);
1768                    if (show === true)
1769                        map_obj.show_places.push(place);
1770                });
1771            }
1772
1773
1774            if (typeof map_obj.map_data.map_options.bound_map_after_filter !== typeof undefined &&
1775                map_obj.map_data.map_options.bound_map_after_filter === true) {
1776
1777                var after_filter_bounds = new google.maps.LatLngBounds();
1778
1779                for (var j = 0; j < map_obj.show_places.length; j++) {
1780                    var markerInResult = new google.maps.LatLng(map_obj.show_places[j]['location']['lat'], map_obj.show_places[j]['location']['lng']);
1781                    after_filter_bounds.extend(markerInResult);
1782                }
1783
1784                map_obj.map.fitBounds(after_filter_bounds);
1785
1786            }
1787
1788            if (map_obj.map_data.listing) {
1789
1790                if ($(map_obj.container).find('[data-filter="map-sorting"]').val()) {
1791                    var order_data = $(map_obj.container).find('[data-filter="map-sorting"]').val().split("__");
1792                    var data_type = '';
1793                    if (order_data[0] !== '' && order_data[1] !== '') {
1794
1795                        if (typeof order_data[2] != 'undefined') {
1796                            data_type = order_data[2];
1797                        }
1798                        map_obj.sorting(order_data[0], order_data[1], data_type);
1799                    }
1800                } else {
1801                    if (map_obj.map_data.listing.default_sorting) {
1802                        var data_type = '';
1803                        if (map_obj.map_data.listing.default_sorting.orderby == 'listorder') {
1804                            data_type = 'num';
1805                        }
1806                        map_obj.sorting(map_obj.map_data.listing.default_sorting.orderby, map_obj.map_data.listing.default_sorting.inorder, data_type);
1807                    }
1808                }
1809
1810            }
1811
1812            if (map_obj.map_data.marker_cluster) {
1813                map_obj.set_marker_cluster();
1814            }
1815
1816        },
1817         
1818        display_filters_listing: function() {
1819
1820            if (this.map_data.listing) {
1821               
1822                var filter_content = '<div class="wpgmp_filter_wrappers">' + this.display_filters() + '</div>';
1823                $(this.container).find(".wpgmp_map_parent").after(filter_content);
1824
1825            }
1826
1827        },
1828
1829        display_filters: function() {
1830
1831            var hide_locations = this.map_data.listing.hide_locations;
1832
1833            var content = '';
1834            content += '<div class="wpgmp_before_listing">' + this.map_data.listing.listing_header + '</div>';
1835
1836            content += '<div class="categories_filter">' + this.create_filters() + '<div data-container="wpgmp-filters-container"></div>';
1837            content += '</div>';
1838
1839            return content;
1840        },
1841
1842        map_loaded: function() {
1843
1844            var map_obj = this;
1845
1846            var gmap = map_obj.map;
1847
1848            google.maps.event.addListenerOnce(gmap, 'idle', function() {
1849
1850                var center = gmap.getCenter();
1851                google.maps.event.trigger(gmap, 'resize');
1852                gmap.setCenter(center);
1853
1854            });
1855
1856            if (map_obj.settings.center_by_nearest === true) {
1857                map_obj.center_by_nearest();
1858            }
1859            if (map_obj.settings.close_infowindow_on_map_click === true) {
1860                google.maps.event.addListener(gmap, "click", function(event) {
1861                    $.each(map_obj.places, function(key, place) {
1862                        place.infowindow.close();
1863                        place.marker.setAnimation(null);
1864                    });
1865                });
1866            }
1867
1868            //for infowindow skins
1869            google.maps.event.addListener(map_obj.infobox, 'domready', function() {
1870                var wpgmp_iwOuter = $(map_obj.container).find('.infoBox');
1871
1872                if (wpgmp_iwOuter.find('.fc-infowindow-default').length == 0 && wpgmp_iwOuter.find('.fc-item-default').length == 0 && wpgmp_iwOuter.find('.wpgmp_infowindow').length > 0) {
1873                   
1874                    wpgmp_iwOuter.find('.wpgmp_infowindow').prepend('<div class="infowindow-close"></div>');
1875                    $('.infowindow-close').click(function(e) {
1876                        e.preventDefault();
1877                        $.each(map_obj.places, function(key, place) {
1878                            place.infowindow.close();
1879                            place.marker.setAnimation(null);
1880                        });
1881                    });
1882
1883                    //accordian
1884                    $(wpgmp_iwOuter).on('click', ".fc-accordion-tab", function() {
1885                        if ($(this).hasClass('active')) {
1886                            $(this).removeClass('active');
1887                            var acc_child = $(this).next().removeClass('active');
1888                        } else {
1889                            $(".fc-accordion-tab").removeClass('active');
1890                            $(".fc-accordion dd").removeClass('active');
1891                            $(this).addClass('active');
1892                            var acc_child = $(this).next().addClass('active');
1893                        }
1894                    });
1895                    if (wpgmp_iwOuter.find('.fc-infowindow-fano').length == 0 && wpgmp_iwOuter.find('.fc-item-fano').length == 0) {
1896                        wpgmp_iwOuter.addClass('infoBoxTail');
1897                    } else {
1898                        wpgmp_iwOuter.removeClass('infoBoxTail');
1899                    }
1900
1901                }
1902            });
1903
1904            if (map_obj.settings.map_infowindow_customisations === true) {
1905                google.maps.event.addListener(map_obj.infowindow_marker, 'domready', function() {
1906
1907                    var wpgmp_iwOuter = $(map_obj.container).find('.gm-style-iw');
1908
1909                    wpgmp_iwOuter.parent().css({
1910                        'width': '0px',
1911                        'height': '0px'
1912                    });
1913                    var wpgmp_iwCloseBtn = wpgmp_iwOuter.next();
1914                    wpgmp_iwCloseBtn.css('display', 'none');
1915
1916                    var wpgmp_iwBackground = wpgmp_iwOuter.prev();
1917
1918                    wpgmp_iwBackground.children(':nth-child(2)').css({
1919                        'display': 'none'
1920                    });
1921
1922                    wpgmp_iwBackground.children(':nth-child(3)').css({
1923                        'background-color': '#000;',
1924                    });
1925
1926                    wpgmp_iwBackground.children(':nth-child(4)').css({
1927                        'display': 'none'
1928                    });
1929                    var height = wpgmp_iwOuter.outerHeight() ;
1930                    wpgmp_iwBackground.children(':nth-child(3)').css({
1931                        'top':(height+18)+'px'
1932                    });
1933                    wpgmp_iwBackground.children(':nth-child(1)').css({
1934                        'top':(height+10)+'px'
1935                    });
1936                    wpgmp_iwBackground.children(':nth-child(3)').find('div').children().css({
1937                        'box-shadow': map_obj.settings.infowindow_border_color + ' 0px 1px 6px',
1938                        'border': '1px solid ' + map_obj.settings.infowindow_border_color,
1939                        'border-top': '',
1940                        'z-index': '1',
1941                        'background-color': map_obj.settings.infowindow_bg_color
1942                    });
1943                    wpgmp_iwOuter.find('.wpgmp_infowindow').prepend('<div class="infowindow-close"></div>');
1944                    wpgmp_iwOuter.on('click', '.infowindow-close', function(event){
1945                        $.each(map_obj.places, function(key, place) {
1946                            place.infowindow.close();
1947                            place.marker.setAnimation(null);
1948                        });
1949                    });
1950                });
1951            }
1952
1953        },
1954
1955        resize_map: function() {
1956            var map_obj = this;
1957            var gmap = map_obj.map;
1958            var zoom = gmap.getZoom();
1959            var center = gmap.getCenter();
1960            google.maps.event.trigger(this.map, 'resize');
1961            gmap.setZoom(zoom);
1962            gmap.setCenter(center);
1963        },
1964        responsive_map: function() {
1965
1966            var map_obj = this;
1967
1968            var gmap = map_obj.map;
1969
1970            window.addEventListener("resize", function() {
1971
1972                var zoom = gmap.getZoom();
1973                var center = gmap.getCenter();
1974                google.maps.event.trigger(gmap, "resize");
1975                gmap.setZoom(zoom);
1976                gmap.setCenter(center);
1977                gmap.getBounds();
1978
1979            } );
1980
1981        },
1982
1983
1984        show_search_control: function() {
1985            var map_obj = this;
1986            var input = $(map_obj.container).find('[data-input="map-search-control"]')[0];
1987
1988            if (input !== undefined) {
1989                var searchBox = new google.maps.places.Autocomplete(input);
1990
1991                if (wpgmp_local.wpgmp_country_specific && wpgmp_local.wpgmp_country_specific == true) {
1992                    searchBox.setComponentRestrictions({
1993                        'country': wpgmp_local.wpgmp_countries
1994                    });
1995                }
1996
1997                map_obj.map.controls[eval("google.maps.ControlPosition." + map_obj.settings.search_control_position)].push(input);
1998                searchBox.bindTo('bounds', map_obj.map);
1999                google.maps.event.addListener(searchBox, 'place_changed', function() {
2000                    var place = searchBox.getPlace();
2001                    map_obj.map.setCenter(place.geometry.location);
2002                    map_obj.map.setZoom(parseInt(map_obj.map_data.map_options.map_zoom_after_search));
2003               });
2004            }  
2005        },
2006
2007        fit_bounds: function() {
2008            var map_obj = this;
2009            var places = map_obj.map_data.places;
2010            var bounds = new google.maps.LatLngBounds();
2011
2012            if (places !== undefined) {
2013                places.forEach(function(place) {
2014
2015                    if (place.location.lat && place.location.lng) {
2016                        bounds.extend(new google.maps.LatLng(
2017                            parseFloat(place.location.lat),
2018                            parseFloat(place.location.lng)
2019                        ));
2020                    }
2021
2022                });
2023            }
2024            map_obj.map.fitBounds(bounds);
2025
2026        },
2027
2028        create_markers: function() {
2029
2030            var map_obj = this;
2031            var places = map_obj.map_data.places;
2032            var temp_listing_placeholder;
2033            var replaceData;
2034            var remove_keys = [];
2035            
2036            $.each(places, function(key, place) {
2037				
2038                if (place.location.lat && place.location.lng) {
2039                    if (typeof place.categories == 'undefined') {
2040                        place.categories = {};
2041                    }
2042                    place.marker = new google.maps.Marker({
2043                        position: new google.maps.LatLng(
2044                            parseFloat(place.location.lat),
2045                            parseFloat(place.location.lng)
2046                        ),
2047                        icon: place.location.icon,
2048                        url: place.url,
2049                        draggable: place.location.draggable,
2050                        map: map_obj.map,
2051                        clickable: place.location.infowindow_disable,
2052                    });
2053
2054                    if (map_obj.settings.infowindow_drop_animation === true) {
2055                        place.marker.setAnimation(google.maps.Animation.DROP);
2056                    }
2057
2058                    if (map_obj.settings.infowindow_filter_only === true) {
2059                        place.marker.visible = false;
2060                        place.marker.setVisible(false);
2061                    }
2062
2063
2064                    // bind event to marker
2065                    if (map_obj.map_data.page == 'edit_location')
2066                        map_obj.marker_bind(place.marker);
2067                    var location_categories = [];
2068                    if (typeof place.categories != 'undefined') {
2069                        for (var cat in place.categories) {
2070                            location_categories.push(place.categories[cat].name);
2071                        }
2072                    }
2073                    var content = '';
2074                     // replace infowindow content.
2075                    var marker_image = '';
2076                   
2077                     if( place.source == 'post' ) { 
2078                        marker_image = place.location.extra_fields.post_featured_image; 
2079                    } else {
2080                        marker_image = place.location.marker_image;
2081                    }
2082
2083                    var temp_listing_placeholder = '';
2084                    if( place.source == 'post' ) { 
2085                        temp_listing_placeholder = map_obj.settings.infowindow_geotags_setting;
2086                    } else {
2087                        temp_listing_placeholder = map_obj.settings.infowindow_setting;
2088                    }
2089
2090                    var temp_listing_placeholder = '';
2091                    var post_info_class = 'fc-infowindow-';
2092                    if (place.source == 'post') {
2093                        temp_listing_placeholder = map_obj.settings.infowindow_geotags_setting;
2094                        post_info_class = 'wpgmp_infowindow_post fc-item-' + map_obj.settings.infowindow_post_skin.name;
2095                    } else {
2096                        temp_listing_placeholder = map_obj.settings.infowindow_setting;
2097                        if (map_obj.map_data.page != 'edit_location' && map_obj.settings.infowindow_skin)
2098                        post_info_class = 'fc-infowindow-' + map_obj.settings.infowindow_skin.name;
2099                    }
2100
2101                    if( typeof temp_listing_placeholder == 'undefined' ) {
2102                                temp_listing_placeholder = place.content;
2103                    }
2104
2105                        replaceData = {
2106                            "{marker_id}": place.id,
2107                            "{marker_title}": place.title,
2108                            "{marker_address}": place.address,
2109                            "{marker_latitude}": place.location.lat,
2110                            "{marker_longitude}": place.location.lng,
2111                            "{marker_city}": place.location.city,
2112                            "{marker_state}": place.location.state,
2113                            "{marker_country}": place.location.country,
2114                            "{marker_postal_code}": place.location.postal_code,
2115                            "{marker_zoom}": place.location.zoom,
2116                            "{marker_icon}": place.location.icon,
2117                            "{marker_category}": location_categories.join(','),
2118                            "{marker_message}": place.content,
2119                            "{marker_image}": marker_image,
2120                            "{get_directions_link}": 'http://www.google.com/maps/place/' + parseFloat(place.location.lat) + ',' + parseFloat(place.location.lng),
2121                        };
2122
2123                        //Add extra fields of locations
2124                        if (typeof place.location.extra_fields != 'undefined') {
2125                            for (var extra in place.location.extra_fields) {
2126                                if (!place.location.extra_fields[extra]) {
2127                                    replaceData['{' + extra + '}'] = '';
2128                                } else {
2129                                    replaceData['{' + extra + '}'] = place.location.extra_fields[extra];
2130                                }
2131                            }
2132                        }
2133                        temp_listing_placeholder = temp_listing_placeholder.replace(/{#if (.*?)}([\s\S]*?){\/if}/g, function(match, p1, p2) {
2134                            return replaceData['{' + p1 + '}'] ? p2 : '';
2135                        });
2136
2137                        temp_listing_placeholder = temp_listing_placeholder.replace(/{[^{}]+}/g, function(match) {
2138                            if (match in replaceData) {
2139                                return (replaceData[match]);
2140                            } else {
2141                                return ("");
2142                            }
2143                        });
2144
2145                    content = temp_listing_placeholder;
2146
2147                    if(map_obj.map_data.map_options.infowindow_skin == '' ){
2148                        var wpgmp_infowindow_class = '';
2149                        var wpgmp_iw_content = '';
2150                    }else if(map_obj.map_data.map_options.infowindow_skin && map_obj.map_data.map_options.infowindow_skin.name && map_obj.map_data.map_options.infowindow_skin.name == 'basic'){
2151                        var wpgmp_infowindow_class = '';
2152                        var wpgmp_iw_content = '';
2153                    }else{
2154                        var wpgmp_infowindow_class = 'class="wpgmp_infowindow '+post_info_class+'"';
2155                        var wpgmp_iw_content = 'class="wpgmp_iw_content"';
2156                    }
2157                  
2158                    
2159                    if (content === "") {
2160                        if (map_obj.settings.map_infowindow_customisations === true && map_obj.settings.show_infowindow_header === true)
2161                            content = '<div '+wpgmp_infowindow_class+'><div class="wpgmp_iw_head"><div class="wpgmp_iw_head_content">' + place.title + '</div></div><div class="wpgmp_iw_content">' + place.content + '</div></div>';
2162                        else
2163                            content = '<div '+wpgmp_infowindow_class+'><div '+wpgmp_iw_content+'>' + place.content + '</div></div>';
2164                    } else {
2165                        if (map_obj.settings.map_infowindow_customisations === true && map_obj.settings.show_infowindow_header === true)
2166                            content = '<div '+wpgmp_infowindow_class+'><div class="wpgmp_iw_head"><div class="wpgmp_iw_head_content">' + place.title + '</div></div><div class="wpgmp_iw_content">' + content + '</div></div>';
2167                        else
2168                            content = '<div '+wpgmp_infowindow_class+'><div '+wpgmp_iw_content+'>' + content + '</div></div>';
2169            
2170                    }
2171                    place.infowindow_data = content;
2172                    place.infowindow = map_obj.infowindow_marker;
2173
2174                    if (place.location.infowindow_default_open === true) {
2175                        map_obj.openInfoWindow(place);
2176                    } else if (map_obj.settings.default_infowindow_open === true) {
2177                        map_obj.openInfoWindow(place);
2178                    }
2179                    var on_event = map_obj.settings.infowindow_open_event;
2180                    var bounce_on_event = map_obj.settings.infowindow_bounce_animation;
2181                    map_obj.event_listener(place.marker, on_event, function() {
2182                        $.each(map_obj.places, function(key, prev_place) {
2183                            prev_place.infowindow.close();
2184                            prev_place.marker.setAnimation(null);
2185                        });
2186                        map_obj.openInfoWindow(place);
2187                        if (bounce_on_event == 'click') {
2188                            map_obj.toggle_bounce(place.marker);
2189                        }
2190                    });
2191                    if (bounce_on_event == 'mouseover' && on_event != 'mouseover') {
2192                        map_obj.event_listener(place.marker, 'mouseover', function() {
2193                            place.marker.setAnimation(google.maps.Animation.BOUNCE);
2194                        });
2195
2196                        map_obj.event_listener(place.marker, 'mouseout', function() {
2197                            place.marker.setAnimation(null);
2198                        });
2199                    }
2200
2201                    if (bounce_on_event != '') {
2202                        google.maps.event.addListener(place.infowindow, 'closeclick', function() {
2203                            place.marker.setAnimation(null);
2204                        });
2205                    }
2206
2207                    map_obj.places.push(place);
2208                } else {
2209                    remove_keys.push(key);
2210                }
2211            });
2212            $.each(remove_keys, function(index, value) {
2213                places.splice(value, 1);
2214            });
2215
2216        },
2217
2218        toggle_bounce: function(marker) {
2219            if (marker.getAnimation() !== null) {
2220                marker.setAnimation(null);
2221            } else {
2222                marker.setAnimation(google.maps.Animation.BOUNCE);
2223            }
2224        },
2225        display_markers: function() {
2226/*
2227            var map_obj = this;
2228            map_obj.show_places = [];
2229            map_obj.categories = [];
2230            var categories = {};
2231            for (var i = 0; i < map_obj.places.length; i++) {
2232                map_obj.places[i].marker.setMap(map_obj.map);
2233                if (map_obj.places[i].marker.visible === true) {
2234                    map_obj.show_places.push(this.places[i]);
2235                }
2236
2237                if (typeof map_obj.places[i].categories != 'undefined') {
2238                    $.each(map_obj.places[i].categories, function(index, category) {
2239
2240                        if (typeof categories[category.name] == 'undefined') {
2241                            categories[category.name] = category;
2242                        }
2243                    });
2244                }
2245            }
2246
2247            this.categories = categories;
2248*/
2249            var map_obj = this;
2250            map_obj.show_places = [];
2251            map_obj.categories = [];
2252            var categories = {};
2253			
2254			// !!! ------------------------
2255			var mycount = 0;
2256			var mylist = '',
2257				temp_title = '';
2258			var mapMarkers= {}; // создаю объект, в который буду добавлять маркеры по айди
2259			
2260			var arrru = new Array ('я','ю','ч','ш','щ','ж','а','б','в','г','д','е','ё','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','х','ц','ы','ь','ъ','э');
2261			var arren = new Array ('ya','yu','ch','sh','sh','zh','a','b','v','g','d','e','e','z','i','j','k','l','m','n','o','p','r','s','t','u','f','h','c','i','','','e');
2262			
2263			function cyrill_to_latin(text){
2264				text = text.replace(/[^a-zA-Zа-яА-ЯёЁ]/g, '').toLowerCase();
2265				for(var i=0; i<arrru.length; i++){
2266					var reg = new RegExp(arrru[i], "g");
2267					text = text.replace(reg, arren[i]);
2268				}
2269				return text;
2270			}
2271			// !!! ------------------------
2272			
2273            for (var i = 0; i < map_obj.places.length; i++) {
2274                map_obj.places[i].marker.setMap(map_obj.map);
2275                if (map_obj.places[i].marker.visible === true) {
2276                    map_obj.show_places.push(this.places[i]);
2277					
2278					// !!! ------------------------
2279					mapMarkers[mycount] = map_obj.places[i].marker;
2280					temp_title = map_obj.places[i].title;
2281					mylist += '<span class="name_map_place '+ cyrill_to_latin(temp_title) +'" data-id="'+ mycount +'">'+ temp_title +'</span>';	
2282					mycount++;
2283					// !!! ------------------------
2284					
2285                }
2286
2287                if (typeof map_obj.places[i].categories != 'undefined') {
2288                    $.each(map_obj.places[i].categories, function(index, category) {
2289
2290                        if (typeof categories[category.name] == 'undefined') {
2291                            categories[category.name] = category;
2292                        }
2293                    });
2294                }
2295            }
2296			
2297			// !!! ---------------------------------------------
2298			var courent_map = $(this.element).attr("id"); // текущая карта
2299			var div_for_mylist = 'my'+courent_map;
2300			
2301			$(this.element).after('<div id="'+div_for_mylist+'" class="my_markers_list"></div>');
2302			
2303			$('#'+div_for_mylist).html(mylist);
2304			
2305			$(".name_map_place").on("click", function() {
2306				var link = $(this).data('id');
2307				var marker = mapMarkers[link];
2308				if (marker) {
2309					google.maps.event.trigger(marker, "click");
2310				}
2311			});
2312			// !!! ---------------------------------------------
2313
2314            this.categories = categories;
2315
2316 
2317 },
2318
2319        get_current_location: function(success_func, error_func) {
2320
2321            var map = this;
2322
2323            if (typeof map.user_location == 'undefined') {
2324
2325                navigator.geolocation.getCurrentPosition(function(position) {
2326                    map.user_location = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
2327
2328                    if (success_func)
2329                        success_func(map.user_location);
2330
2331                }, function(ErrorPosition) {
2332
2333                    if (error_func)
2334                        error_func(ErrorPosition);
2335
2336                }, {
2337                    enableHighAccuracy: true,
2338                    timeout: 5000,
2339                    maximumAge: 0
2340                });
2341            } else {
2342                if (success_func)
2343                    success_func(map.user_location);
2344            }
2345        },
2346
2347        openInfoWindow: function(place) {
2348            var map_obj = this;
2349            var skin = 'default';
2350            if (place.source == 'post') {
2351                skin = map_obj.settings.infowindow_post_skin.name;
2352            } else if (map_obj.map_data.page != 'edit_location' && map_obj.settings.infowindow_skin) {
2353                skin = map_obj.settings.infowindow_skin.name;
2354            }
2355
2356            if (skin != 'default' && skin != 'basic') {
2357                var infoboxText = document.createElement("div");
2358                infoboxText.className = 'wpgmp_infobox'
2359                
2360                var infoboxOptions = {
2361                    content: infoboxText,
2362                    disableAutoPan: false,
2363                    alignBottom: true,
2364                    maxWidth: 0,
2365                    pixelOffset: (skin == 'fano') ? new google.maps.Size(-150, -40) : new google.maps.Size(-150, -55),
2366                    zIndex: null,
2367                    boxStyle: {
2368                        width: "300px"
2369                    },
2370                    closeBoxMargin: "0",
2371                    closeBoxURL: "",
2372                    infoBoxClearance: new google.maps.Size(25, 25),
2373                    isHidden: false,
2374                    pane: "floatPane",
2375                    enableEventPropagation: false,
2376                };
2377                
2378                place.infowindow = map_obj.infobox;
2379
2380                place.infowindow.setOptions(infoboxOptions);
2381                infoboxText.innerHTML = place.infowindow_data;
2382            } else {
2383                place.infowindow = map_obj.infowindow_marker;
2384                place.infowindow.setContent(place.infowindow_data);
2385            }
2386
2387            if (place.location.onclick_action == "post") {
2388                if (place.location.open_new_tab == 'yes')
2389                    window.open(place.location.redirect_permalink, '_blank');
2390                else
2391                    window.open(place.location.redirect_permalink, '_self');
2392            } else if (place.location.onclick_action == "custom_link") {
2393                if (place.location.open_new_tab == 'yes')
2394                    window.open(place.location.redirect_custom_link, '_blank');
2395                else
2396                    window.open(place.location.redirect_custom_link, '_self');
2397            } else {
2398
2399                place.infowindow.open(this.map, place.marker);
2400
2401                if (typeof map_obj.settings.infowindow_open_event != 'undefined' && map_obj.settings.infowindow_open_event == 'click' && typeof map_obj.settings.infowindow_click_change_center != 'undefined' && map_obj.settings.infowindow_click_change_center == true) {
2402                    map_obj.map.setCenter(place.marker.getPosition());
2403                }
2404                if (typeof map_obj.settings.infowindow_open_event != 'undefined' && map_obj.settings.infowindow_open_event == 'click' && typeof map_obj.settings.infowindow_click_change_zoom != 'undefined' && map_obj.settings.infowindow_click_change_zoom > 0) {
2405                    map_obj.map.setZoom(map_obj.settings.infowindow_click_change_zoom);
2406                }
2407                if (this.map_data.map_tabs && this.map_data.map_tabs.direction_tab && this.map_data.map_tabs.direction_tab.dir_tab === true) {
2408                    $(this.container).find('.start_point').val(place.address);
2409                }
2410            }
2411            $(map_obj.container).find(".wpgmp_extra_field:contains('wpgmp_empty')").remove();
2412            $(map_obj.container).find(".wpgmp_empty").prev().remove();
2413            $(map_obj.container).find(".wpgmp_empty").remove();
2414			
2415			//map_obj.map.setCenter(place.marker.getPosition()); // !!! выбранный маркер по центру карты
2416			map_obj.map.panTo(place.marker.getPosition()); // !!!
2417
2418        },
2419    };
2420
2421    $.fn.maps = function(options, places) {
2422
2423        this.each(function() {
2424
2425            if (!$.data(this, "wpgmp_maps")) {
2426                $.data(this, "wpgmp_maps", new GoogleMaps(this, options, places));
2427            }
2428
2429        });
2430        // chain jQuery functions
2431        return this;
2432    };
2433
2434}(jQuery, window, document));
2435
2436function wpgmpInitMap() {
2437
2438    jQuery(document).ready(function($) {
2439
2440        if ($.fn.maps) {
2441            
2442            $(".wpgmp_map").each(function() {
2443
2444                var mapId = $(this).data("map-id");
2445                var mapVarName = 'mapdata' + mapId;
2446                var mapData = window.wpgmp && window.wpgmp[mapVarName];
2447                if (mapData) {
2448                    $("#map" + mapId).maps(mapData).data("wpgmp_maps");
2449                } else {
2450                    console.warn("Map data missing for map : " + mapId);
2451                }
2452
2453            });
2454        }
2455    });
2456}
2457

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.