PageSourceSearch

https://www.merrittchiro.com/plugins/smb/map/assets/js/ib-map.js?v.1.0.110

js merrittchiro.com collected 2026-09-28 09:14:58 UTC 33,319 bytes, 784 lines download raw bytes

1(function ($) {
2    "use strict";
3
4    /**
5     *
6     * @constructor
7     */
8    var WebManagerMap = function () {
9        this.confData = {};
10        this.selfCount = {};
11        this.mapInstance = {};
12        this.mapMarkers = {};
13        this.activeMap = null;
14
15        if ($(".js-mapComponent").length) {
16            this.initialize();
17        }
18    };
19
20    /**
21     *
22     * @param postcode
23     * @returns {string}
24     */
25    WebManagerMap.prototype.getAddressForPostcode = function (componentName, postcode, houseNum) {
26        var address = "",
27            locations = this.confData[componentName].locations;
28
29        for (var i = 0; i < locations.length; i++) {
30            if (locations[i].address.indexOf(postcode) !== -1) {
31                if (houseNum !== null) {
32                    if (locations[i].address.indexOf(houseNum) !== -1) {
33                        address = locations[i].address;
34                        break;
35                    }
36                } else {
37                    address = locations[i].address;
38                    break;
39                }
40            }
41        }
42        return address;
43    };
44
45    /**
46     * Set up map instance for the map elements on the page
47     */
48    WebManagerMap.prototype.initialize = function () {
49        var self = this;
50
51        // Factory Patch Helper — Leaflet 2.0-alpha dropped UMD-style factories.
52        // Recreate common factories so legacy L.* usage keeps working.
53        if (typeof L !== 'undefined' && L) {
54            // Map
55            if (!L.map && L.Map) L.map = (id, options) => new L.Map(id, options);
56
57            // Layers
58            if (!L.tileLayer && L.TileLayer) L.tileLayer = (url, options) => new L.TileLayer(url, options);
59            if (!L.marker && L.Marker) L.marker = (latlng, options) => new L.Marker(latlng, options);
60            if (!L.polygon && L.Polygon) L.polygon = (latlngs, options) => new L.Polygon(latlngs, options);
61            if (!L.polyline && L.Polyline) L.polyline = (latlngs, options) => new L.Polyline(latlngs, options);
62            if (!L.circle && L.Circle) L.circle = (latlng, radius, options) => new L.Circle(latlng, radius, options);
63            if (!L.circleMarker && L.CircleMarker) L.circleMarker = (latlng, options) => new L.CircleMarker(latlng, options);
64            if (!L.rectangle && L.Rectangle) L.rectangle = (latLngBounds, options) => new L.Rectangle(latLngBounds, options);
65            if (!L.featureGroup && L.FeatureGroup) L.featureGroup = (layers) => new L.FeatureGroup(layers);
66            if (!L.layerGroup && L.LayerGroup) L.layerGroup = (layers) => new L.LayerGroup(layers);
67            if (!L.geoJSON && L.GeoJSON) L.geoJSON = (geojson, options) => new L.GeoJSON(geojson, options);
68
69            // Overlays
70            if (!L.imageOverlay && L.ImageOverlay) L.imageOverlay = (url, bounds, options) => new L.ImageOverlay(url, bounds, options);
71            if (!L.videoOverlay && L.VideoOverlay) L.videoOverlay = (url, bounds, options) => new L.VideoOverlay(url, bounds, options);
72            if (!L.svgOverlay && L.SVGOverlay) L.svgOverlay = (el, bounds, options) => new L.SVGOverlay(el, bounds, options);
73
74            // Icons
75            if (!L.icon && L.Icon) L.icon = (options) => new L.Icon(options);
76            if (!L.divIcon && L.DivIcon) L.divIcon = (options) => new L.DivIcon(options);
77
78            // UI
79            L.control = L.control || {};
80            if (!L.control.zoom && L.Control?.Zoom) L.control.zoom = (options) => new L.Control.Zoom(options);
81            if (!L.control.layers && L.Control?.Layers) L.control.layers = (base, overlays, options) => new L.Control.Layers(base, overlays, options);
82            if (!L.control.scale && L.Control?.Scale) L.control.scale = (options) => new L.Control.Scale(options);
83            if (!L.control.attribution && L.Control?.Attribution) L.control.attribution = (options) => new L.Control.Attribution(options);
84
85            if (!L.popup && L.Popup) L.popup = (options, source) => new L.Popup(options, source);
86            if (!L.tooltip && L.Tooltip) L.tooltip = (options, source) => new L.Tooltip(options, source);
87
88            // Geometry helpers
89            if (!L.latLng && L.LatLng) {
90                L.latLng = (a, b) => Array.isArray(a) ? new L.LatLng(a[0], a[1], a[2]) : new L.LatLng(a, b);
91            }
92            if (!L.latLngBounds && L.LatLngBounds) {
93                L.latLngBounds = (a, b) => Array.isArray(a) ? new L.LatLngBounds(a[0], a[1] ?? a[0]) : new L.LatLngBounds(a, b);
94            }
95            if (!L.point && L.Point) {
96                L.point = (x, y, round) => Array.isArray(x) ? new L.Point(x[0], x[1], y) : new L.Point(x, y, round);
97            }
98            if (!L.bounds && L.Bounds) {
99                L.bounds = (a, b) => Array.isArray(a) ? new L.Bounds(a[0], a[1] ?? a[0]) : new L.Bounds(a, b);
100            }
101        }
102
103        // Get all the map elements with the same class.
104        var mapElements = $('.js-mapComponent');
105        var mapsUrl = '//smbmaps.ibsrv.net/world_tiles/{z}/{x}/{y}.png';
106
107        window.mapPopupTriggered = false;
108
109        // For each container that will hold a map.
110        mapElements.each(
111            function () {
112                // Get the component alias
113                var componentName = $(this).closest('[data-component-name]').data('componentName');
114
115                // Initialize a map
116                self.mapInstance[componentName] = L.map(this);
117
118                L.tileLayer(
119                    mapsUrl,
120                    {
121                        attribution: 'Map data provided by <a href="http://www.internetbrands.com/">Internet Brands</a>',
122                        maxZoom: 18
123                    }
124                ).addTo(self.mapInstance[componentName]);
125
126                self.mapInstance[componentName].scrollWheelZoom.disable();
127
128                self.confData[componentName] = JSON.parse($(this).closest('[data-component-name]').find('input[type=hidden]').val());
129
130                self.setupMap(self.mapInstance[componentName], self.confData[componentName]);
131
132                self.mapSize(this, self.confData[componentName], componentName);
133
134                self.attachEvents(this, self.confData[componentName], componentName);
135
136                var searchSubmit = false;
137                self.searchByZipCode(this, self.confData[componentName], self.mapInstance[componentName], componentName, searchSubmit);
138
139                var locations = self.confData[componentName].locations;
140                // have to make array reverse because the centered marker should be the first one in the listing
141                // of locations manager
142                if(locations.length > 1 && !self.confData[componentName].fitBounds){
143                    locations =  locations.reverse();
144                }
145
146                for (var i = 0; i < locations.length; i++) {
147
148                    // markup for the cta with icon
149                    if (locations[i].cta != null) {
150                        if (locations[i].cta.buttonStyle == 2) {
151                            locations[i].cta.iconHtm =
152                                '\n<span aria-label="' + locations[i].cta.iconClass.replace(/-/g, " ") + '">\n' +
153                                '<span class="' + locations[i].cta.iconClass + ' icon" aria-hidden="true"></span>\n</span>\n'
154                        }
155                        if (locations[i].cta.buttonStyle == 3) {
156                            locations[i].cta.iconHtm = '\n<span class="' + locations[i].cta.iconClass + ' icon" aria-hidden="true"></span>\n' + locations[i].cta.buttonText + '\n'
157                        }
158                    }
159
160                    //if there is latitude and longitude for the location
161                    if (locations[i].latitude != null && locations[i].longitude != null) {
162                        var json = [{
163                            "lat": locations[i].latitude,
164                            "lon": locations[i].longitude,
165                            "address": {
166                                "name": locations[i].address,
167                            }
168                        }];
169
170                        // create the marker
171                        self.applyData(json, componentName, this, i);
172                    }
173                    // if there is an address for the location
174                    else {
175                        //get the latitude for the current location
176                        self.geolocateLocation(locations[i], componentName, this);
177                    }
178                }
179
180                var xaxisPan = self.confData[componentName].xaxis,
181                yaxisPan = self.confData[componentName].yaxis;
182
183                // set map X/Y - Axis Offset for desktop resolution
184                if ($(window).width() > 768) {
185                    if(xaxisPan != 0 || yaxisPan != 0) self.mapInstance[componentName].panBy([xaxisPan, yaxisPan])
186                }
187            }
188        );
189
190        // Toggle map scrolling
191        $("body").click(function (e) {
192            if ($(e.target).hasClass("js-mapComponent")) {
193                var componentName = $(e.target).closest('[data-component-name]').data('componentName');
194                // Disable scroll on other map instance if already enabled
195                if (self.activeMap !== null) {
196                    self.mapInstance[self.activeMap].scrollWheelZoom.disable();
197                }
198                self.activeMap = componentName;
199
200                if(self.confData[componentName].zoomControl){
201                    self.mapInstance[componentName].scrollWheelZoom.enable();
202                }
203            } else {
204                if (self.activeMap !== null) {
205                    self.mapInstance[self.activeMap].scrollWheelZoom.disable();
206                    self.activeMap = null;
207                }
208            }
209        });
210    };
211    
212    /**
213     * Attach events
214     *
215     * @param map
216     * @param mapData
217     * @param componentName
218     */
219    WebManagerMap.prototype.attachEvents = function (map, mapData, componentName) {
220        var self = this,
221            winResizeTimer;
222        
223        $(window).resize(function () {
224            self.mapSize(map, mapData, componentName);
225            clearTimeout(winResizeTimer);
226            //Call mapCenter function when the resizing completely will stop/finish
227            winResizeTimer = setTimeout(function () {
228                if (self.mapMarkers[componentName].length > 1 && self.confData[componentName].fitBounds) {
229                    var markerGroup = L.featureGroup(self.mapMarkers[componentName]);
230                    self.mapCenter(componentName, markerGroup);
231                }
232            }, 250);
233        });
234    }
235
236    /**
237     *
238     * @param mapInstance
239     * @param mapData
240     */
241    WebManagerMap.prototype.setupMap = function (mapInstance, mapData) {
242        var zoomControl = mapData.zoomControl;
243
244        if (!zoomControl) {
245            // Drawing a square area to zoom
246            mapInstance.boxZoom.disable();
247
248            // The zoom on double click
249            mapInstance.doubleClickZoom.disable();
250
251            // Like when you hit the keys for + and -
252            mapInstance.keyboard.disable();
253
254            // The zoom with scroll
255            mapInstance.scrollWheelZoom.disable(); 
256
257            if (mapInstance.tap) {
258                mapInstance.tap.disable();
259            }
260
261            // The zoom via touch
262            mapInstance.touchZoom.disable();
263
264            // The + and - buttons
265            $(".leaflet-control-zoom").css("visibility", "hidden");
266        }
267    };
268
269    /**
270     * Set fit bound for map instance with multiple locations
271     * @param componentName Alias of the map component
272     * @param markerLayer   The layer containing all the markers
273     */
274    WebManagerMap.prototype.mapCenter = function (componentName, markerLayer) {
275        var self = this;
276
277        self.mapInstance[componentName].fitBounds(markerLayer.getBounds().pad(0.5));
278
279        if (self.confData[componentName].alwaysShowInfoWindow) {
280            if(self.mapMarkers[componentName][self.mapMarkers[componentName].length - 1].isPopupOpen()){
281                if (!window.mapPopupTriggered) {
282                    //TODO - mapCenter function triggers endless resize event
283                    //SMBWMGR-19261 - this does the trick, togglePopup does not help since need some timeout to correct the position
284                    self.mapMarkers[componentName][self.mapMarkers[componentName].length - 1].closePopup(); 
285                    self.mapMarkers[componentName][self.mapMarkers[componentName].length - 1].openPopup(); 
286                    window.mapPopupTriggered = true;
287                }
288           }
289       }
290    };
291
292
293    /**
294     * Calculates the size of the map based on the settings
295     * @param element Map instance
296     * @param mapData Settings for the map
297     */
298    WebManagerMap.prototype.mapSize = function (element, mapData, componentName) {
299        var self = this, parent = $(element).parent();
300
301        if (mapData.autoFit) {
302            var titleCaptionHeight, pleMapAwrapHeight;
303            (!self.confData[componentName].isPle) ? titleCaptionHeight = parent.children('.component__title-caption-wrap').outerHeight(true) : pleMapAwrapHeight = parent.find('.map__wrap').outerHeight(true);
304            
305            parent.css('height', '100%');
306            var elementHeight = parent.height();
307
308            // If there title or caption is shown in the component subtract it from the parent height
309            if (!self.confData[componentName].isPle && titleCaptionHeight !== null) {
310                elementHeight = elementHeight - titleCaptionHeight;
311            } else {
312                if ($(window).width() <= 768 && pleMapAwrapHeight !== null) {
313                    elementHeight = elementHeight - pleMapAwrapHeight;
314                }
315            }
316
317            // Resize the map and trigger map.resize event
318            $(element).css({width: parent.width(), height: elementHeight});
319            $(element).trigger('map.resize');
320
321        } else {
322            $(element).css({width: mapData.width, height: mapData.height});
323        }
324    };
325
326    /**
327     * Notice the param json_callback=jsonMapCallback
328     * Check more here: http://wiki.openstreetmap.org/wiki/Nominatim
329     * json_callback=<string> - Wrap json output in a callback function (JSONP) i.e. <string>(<json>)
330     * @type {string}
331     */
332    WebManagerMap.prototype.geocodeURL = "https://nominatim.openstreetmap.org/search?[QUERY]&format=json&polygon=1&addressdetails=1&limit=1";
333
334    /**
335     *
336     * @param location
337     */
338    WebManagerMap.prototype.geolocateLocation = function (location, componentName, mapElement) {
339        var self = this,
340            geocodeURL = this.geocodeURL;
341
342        geocodeURL = geocodeURL.replace("[QUERY]", location.query);
343
344        // Geocode the location and apply the response to the map instance
345        $.ajax({
346            url: geocodeURL,
347            dataType: "jsonp",
348            jsonp: 'json_callback',
349            success: function (json) {
350                self.applyData(json, componentName, mapElement);
351            }
352        });
353        // @todo: Maybe find another solution for this cross-domain query
354    };
355
356
357     /**
358     * Geocode the location, search by zip code or city
359     * @param map
360     * @param mapData
361     * @param mapInstance
362     * @param componentName
363     */
364     WebManagerMap.prototype.searchByZipCode = function (map, mapData, mapInstance, componentName, searchSubmit) {
365        var self = this,
366            geocodeURL = this.geocodeURL;
367
368        $("#location-zip").submit(function (event) {
369            event.preventDefault();
370
371            var zipCodeVal = $('#location-search').val();
372
373            if (!zipCodeVal || zipCodeVal == "Enter your zip code and state") {
374                alert("Please enter your current city or ZIP code.");
375                return;
376            }
377
378            geocodeURL = "https://nominatim.openstreetmap.org/search?q=" + zipCodeVal + "&format=json";
379
380            $.ajax({
381                url: geocodeURL,
382                dataType: "jsonp",
383                jsonp: 'json_callback',
384                success: function (json) {
385                    self.getDistance(json, mapData, mapInstance, componentName, searchSubmit);
386                }
387            });
388        });
389    };
390
391
392    /**
393    * Calculate the distance between the locations
394    * @param json
395    * @param mapData
396    * @param mapInstance
397    * @param componentName
398    */
399    WebManagerMap.prototype.getDistance = function (json, mapData, mapInstance, componentName, searchSubmit) {
400        var self = this;
401        self.markerTemp;
402    
403        if (Object.keys(json).length !== 0) {
404    
405            // get the coordinates
406            var location = mapData.locations,
407                lat = json[0].lat,
408                lon = json[0].lon;
409    
410            // create green icon for the new marker
411            var greenIcon = new L.Icon({
412                iconUrl: mapData.assetsPath + 'css/images/marker-icon-green.png',
413                shadowUrl: mapData.assetsPath + 'images/marker-shadow.png',
414                iconSize: [25, 41],
415                iconAnchor: [12, 41],
416                popupAnchor: [1, -34],
417                shadowSize: [41, 41]
418            });
419    
420            // create and attach the new marker to the map instace
421            var marker = L.marker([lat, lon], { icon: greenIcon });
422            marker.addTo(mapInstance);
423    
424            // set the view to the new marker
425            // mapInstance.setView([lat, lon], mapData.zoom, {animation: true});
426    
427            // remove the previous markers generated by the search
428            if (typeof (self.markerTemp) != "undefined") {
429                self.markerTemp.removeFrom(mapInstance);
430                this.mapMarkers[componentName].pop(marker);
431            }
432    
433            // keep in temp previous marker and push the new one
434            if (marker != null) self.markerTemp = marker;
435            this.mapMarkers[componentName].push(marker);
436    
437            // close all of the popups
438            mapInstance.closePopup();
439    
440            // set the view based on the grouped markers
441            var markerGroup = L.featureGroup(this.mapMarkers[componentName]).addTo(mapInstance);
442            mapInstance.fitBounds(markerGroup.getBounds().pad(0.5));
443    
444            // loop and set the miles values
445            for (var i = 0; i < location.length; i++) {
446    
447                if (location[i].latitude != null && location[i].longitude != null) {
448    
449                    var distanceMeters = L.latLng([location[i].latitude, location[i].longitude]).distanceTo([lat, lon]),
450                        // distanceTo returns meters, convert this to miles - 1m = 0.000621371
451                        distanceMiles = Math.round(distanceMeters * 0.000621371),
452                        $gmapLocTitle = $(".gmap-location b"),
453                        $gmapLocDistance = $(".gmap-location .gmap-distance");
454    
455                    for (var j = 0; j < $gmapLocTitle.length; j++) {
456    
457                        if ($gmapLocTitle[j].innerText.indexOf(location[i].title) !== -1) {
458                            $($gmapLocTitle[j]).closest('.gmap-location').data('distanceMiles', distanceMiles);
459                            
460                            distanceMiles = distanceMiles.toLocaleStr
460ing();
461                            $gmapLocDistance.show();
462                            $gmapLocDistance[j].innerHTML = distanceMiles + " mi";
463                        }
464                    }
465                }
466            }
467    
468            // order the location list by distance
469            $(".gmap-location-list li").sort(function (a, b) { return ($(b).data('distanceMiles')) < ($(a).data('distanceMiles')) ? 1 : -1; }).appendTo('.gmap-location-list');
470    
471            // trigger the click and change the location info
472            searchSubmit = true;
473            $(".gmap-location-list li").first().children().trigger('click',[ searchSubmit ]);
474    
475        } else {
476    
477            // clean up the distance data
478            var $gmapLocTitle = $(".gmap-location b"),
479                $locDistanceInfo = $(".map-search__location-distance > b"),
480                $gmapLocDistance = $(".gmap-location .gmap-distance");
481    
482            for (var i = 0; i < $gmapLocDistance.length; i++) {
483                $gmapLocDistance.show();
484                $gmapLocDistance[i].innerHTML = " -- mi";
485            }
486            for (var i = 0; i < $locDistanceInfo.length; i++) {
487                $locDistanceInfo.show();
488                $locDistanceInfo[i].innerHTML = " -- mi";
489            }
490            for (var i = 0; i < $gmapLocTitle.length; i++) {
491                $($gmapLocTitle[i]).closest('.gmap-location').data('distanceMiles', "--");
492            }
493        }
494    };
495
496
497    /**
498     * Apply the location data on the map instance
499     * @param json
500     * @param componentName
501     */
502    WebManagerMap.prototype.applyData = function (json, componentName, mapElement, index) {
503
504        var self = this;
505        if (json.length > 0) {
506            self.selfCount[componentName] = self.selfCount[componentName] || 0;
507
508            var data = json[0],
509                lat = data.lat,
510                lon = data.lon;
511
512            
513            self.mapInstance[componentName].setView([lat, lon], self.confData[componentName].zoom, {animation: true});
514            self.selfCount[componentName]++;
515
516            var markerOptions = [];
517            markerOptions['alt'] = 'Map Marker';
518
519            var assetsPath = self.confData[componentName].assetsPath;
520
521            if (self.confData[componentName].iconUrl) {
522                var iconUrl = self.confData[componentName].iconUrl,
523                    icon = new L.Icon({
524                        iconUrl: iconUrl,
525                        shadowUrl: assetsPath + 'images/marker-shadow.png',
526                        iconSize: [25, 41],
527                        iconAnchor: [12, 41],
528                        popupAnchor: [1, -34],
529                        shadowSize: [41, 41]
530                    });
531
532                markerOptions['icon'] = icon;
533            }
534
535            // var marker = L.marker([lat, lon], markerOptions).addTo(self.mapInstance[componentName]);
536            var marker = L.marker([lat, lon], markerOptions);
537
538            if (self.confData[componentName].alwaysShowInfoWindow || self.confData[componentName].showAddressOnHover) {
539                var location = data.display_name || null; // Default to display_name attribute or null
540                var addressFromPostcode = null;
541
542                if ('postcode' in data.address) {
543                    var houseNum = ('house_number' in data.address) ? data.address.house_number : null;
544
545                    addressFromPostcode = self.getAddressForPostcode(componentName, data.address.postcode, houseNum);
546                    location = (addressFromPostcode != '') ? addressFromPostcode : location;
547                }
548                else if (data.address.name) {
549                    location = data.address.name;
550                }
551
552                if (location) {
553                    marker.bindPopup(location);
554                }
555            }
556            self.mapMarkers[componentName] = self.mapMarkers[componentName] || [];
557            self.mapMarkers[componentName].push(marker);
558
559            // TODO: this needs to be in the map init section?
560            if (self.confData[componentName].hue) {
561                var hueObj = self.confData[componentName].hue,
562                    hueStylers = hueObj.stylers,
563                    // @todo: Maybe find a way to convert gama, lightness and the hue (rbg color by some reason) into a rgb?
564                    gama = hueStylers[0].gama,
565                    lightness = hueStylers[1].lightness,
566                    hue = hueStylers[2].hue;
567
568                if (hue !== "none") {
569                    $(mapElement).css("background-color", hue);
570                    $("div.leaflet-tile-pane", mapElement).css("opacity", "0.9");
571                }
572            }
573
574            // Add the markers to the map
575            if (self.selfCount[componentName] >= self.confData[componentName].locations.length) {
576                var markerGroup = L.featureGroup(self.mapMarkers[componentName]).addTo(self.mapInstance[componentName]);
577
578                // Center the map if more then one marker
579                if (self.mapMarkers[componentName].length > 1 && self.confData[componentName].fitBounds) {
580                    self.mapCenter(componentName, markerGroup);
581                }
582
583                // Open the info window if the setting is set
584                if (self.confData[componentName].alwaysShowInfoWindow) {
585                    //SMBWMGR-19261 - this does the trick, togglePopup does not help since need some timeout to correct the position
586                    self.mapMarkers[componentName][self.mapMarkers[componentName].length - 1].closePopup(); 
587                    self.mapMarkers[componentName][self.mapMarkers[componentName].length - 1].openPopup(); 
588                }
589            }
590        } else {
591            console.log("No data found.");
592        }
593    };
594
595    /**
596     * PLE specific to change text based on clicked location
597     */
598    function pleMap(){
599        var locationFields = [
600            {
601                selector: '.map-search__location-distance h3 b',
602                property: 'title',
603                type: 'text'
604            },
605            {
606                selector: '.map-search__location-address p',
607                property: 'address_format',
608                type: 'text'
609            },
610            {
611                selector: '.map-search__location-phone',
612                property: 'phone',
613                type: 'text'
614            },
615            {
616                selector: '.map-search__location-phone2',
617                property: 'phone2',
618                type: 'text'
619            },
620            {
621                selector: '.map-search__location-fax',
622                property: 'fax',
623                type: 'text'
624            },
625            {
626                selector: '.map-search__location-directions a',
627                property: ['cta','buttonText'],
628                type: 'text'
629            },
630            {
631                selector: '.map-search__location-directions a',
632                property: ['cta','linkPage'],
633                type: 'href'
634            },
635            {
636                selector: '.map-search__email',
637                property: 'email',
638                type: 'text'
639            }
640        ];
641
642        $('#gmap-location-list').on('click', '.gmap-location a', function (event, searchSubmit) {
643            event.preventDefault();
644            var componentName = $(this).closest('[data-component-name]').data('componentName');
645            var locations = window.webManagerMap.confData[componentName].locations;
646            var clickedID = $(this).parent().attr('id');
647            var location = locations.find(function(obj) {
648                return obj.ID === clickedID
649            });
650            var locMarker = window.webManagerMap.mapMarkers[componentName].find(function(obj) {
651                return (obj._latlng.lat == location.latitude && obj._latlng.lng == location.longitude);
652            });
653
654            // set the view to the clicked marker
655            if (typeof (searchSubmit) == "undefined") {
656                const mapInstance = window.webManagerMap.mapInstance[componentName];
657                const mapData = window.webManagerMap.confData[componentName];
658                const latlng = [location.latitude, location.longitude];
659
660                let xaxisPan = mapData.xaxis;
661                const yaxisPan = mapData.yaxis;
662
663                if (xaxisPan > -140) xaxisPan = -140;
664
665                mapInstance.invalidateSize();
666                mapInstance.stop();
667
668                function openPopup() {
669                    if (locMarker) locMarker.openPopup();
670                }
671
672                if (window.innerWidth > 768) {
673                    mapInstance.setView(latlng, mapData.zoom, { animate: false });
674                    mapInstance.panBy([xaxisPan, yaxisPan], { animate: true });
675                    mapInstance.once('moveend', function () {
676                        openPopup();
677                    });
678
679                } else {
680                    mapInstance.setView(latlng, mapData.zoom, { animate: false });
681                    openPopup();
682                }
683            }
684
685            // set the distance
686            var distance = $(this).closest('.gmap-location').data('distanceMiles'),
687                $locDistanceInfo = $('.map-search__location-distance > b');
688
689            if (typeof(distance) != "undefined") { 
690                $locDistanceInfo.show();
691                distance = distance.toLocaleString();
692                $locDistanceInfo[0].innerHTML = distance + " mi";
693            } else {
694                $locDistanceInfo[0].innerHTML = " -- mi";
695            }
696
697            locationFields.forEach(function (field, i) {
698                var loc = {};
699                var prop = field.property;
700
701                // manage cta buttons/links
702                if (field.selector == '.map-search__location-directions a') {
703                    var btnStyle = '';
704                    for (var i = 0; i <= 3; i++) {
705                        if (location.cta.buttonStyle == i) {
706                            //get the cta style class
707                            switch (location.cta.buttonStyle) {
708                                case '0':
709                                    btnStyle = 'cta__link component__link--';
710                                    break;
711                                case '1':
712                                    btnStyle = 'cta__button component__button--';
713                                    break;
714                                case '2':
715                                    btnStyle = 'cta__link--icon ';
716                                    break;
717                                case '3':
718                                    btnStyle = 'cta__button--icon component__button--';
719                                    break;
720                                default:
721                            }
722                            // set the cta markup
723                            location.cta.buttonStyle == 2 || location.cta.buttonStyle == 3 ? $(field.selector).html(location.cta.iconHtm) : $(field.selector).text(location.cta.buttonText);
724                            // set the cta style class
725                            $(field.selector).removeClass().addClass(btnStyle + location.cta.displayStyle);
726                            // set the href
727                            if (location.cta.linkType == 2) {
728                                $(field.selector).attr('href', '#');
729                            } else {
730                                location.cta.linkType == 1 ? $(field.selector).attr('href', location.cta.linkUrl) : $(field.selector).attr('href', location.cta.linkPage);
731                            }
732                            // set the target
733                            location.cta.openInNew ? $(field.selector).attr('target', '_blank') : $(field.selector).attr('target', '');
734                            // set the rel
735                            location.cta.openInNew && location.cta.linkType == 1 ? $(field.selector).attr('rel', 'noopener') : $(field.selector).attr('rel', '');
736                        }
737                    }
738                }
739                else {
740                    if (typeof prop === 'string' || prop instanceof String) {
741                        loc = location[prop]
742                    } else {
743                        var lc = location;
744                        prop.forEach(function (pr) {
745                            lc = lc[pr];
746                        });
747                        loc = lc;
748                    }
749                    if (typeof loc === 'string' || loc instanceof String) {
750                        if (field.type === 'text') {
751                            $(field.selector).text(loc);
752                            if (field.selector == '.map-search__location-phone' || field.selector == '.map-search__location-phone2') {
753                                $(field.selector).attr('href', 'tel:' + loc);
754                            }
755                        } else if (field.type === 'href') {
756                            $(field.selector).attr('href', loc);
757                            debugger;
758                        }
759                        if (loc.length > 0) {
760                            $(field.selector).show();
761                        } else {
762                            $(field.selector).hide();
763                        }
764                    } else {
765                        var vals = Object.values(Object.keys(location[prop]).map(function (e) {
766                            return location[prop][e];
767                        }));
768                        $(field.selector).html(vals.join("<br>"));
769                    }
770                }
771            });
772        });
773    }
774
775    $(document).ready(
776        function () {
777            window.webManagerMap = new WebManagerMap();
778
779            if($('.map-a').length > 0){
780                pleMap();
781            }
782        }
783    );
784})(window.jQuery);

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.