Skip to content

Commit a28fcd6

Browse files
authored
Update jquery.storelocator.js
1 parent 45cb909 commit a28fcd6

File tree

1 file changed

+25
-27
lines changed

1 file changed

+25
-27
lines changed

src/js/jquery.storelocator.js

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111

1212
// Variables used across multiple methods
13-
var $this, listTemplate, infowindowTemplate, dataTypeRead, originalOrigin, originalData, originalZoom, dataRequest, searchInput, addressInput, olat, olng, storeNum, directionsDisplay, directionsService, prevSelectedMarkerBefore, prevSelectedMarkerAfter, firstRun;
13+
var $this, map, listTemplate, infowindowTemplate, dataTypeRead, originalOrigin, originalData, originalZoom, dataRequest, searchInput, addressInput, olat, olng, storeNum, directionsDisplay, directionsService, prevSelectedMarkerBefore, prevSelectedMarkerAfter, firstRun;
1414
var featuredset = [], locationset = [], normalset = [], markers = [];
1515
var filters = {}, locationData = {}, GeoCodeCalc = {}, mappingObj = {};
1616

@@ -382,9 +382,7 @@
382382
* @returns {Object} google.maps.Map instance
383383
*/
384384
getMap: function() {
385-
var myOptions = this.settings.mapSettings;
386-
var map = new google.maps.Map(document.getElementById(this.settings.mapID), myOptions);
387-
return map;
385+
return this.map;
388386
},
389387

390388
/**
@@ -610,13 +608,13 @@
610608
myOptions.center = latlng;
611609

612610
// Create the map
613-
var map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions);
611+
_this.map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions);
614612

615613
// Re-center the map when the browser is re-sized
616614
google.maps.event.addDomListener(window, 'resize', function() {
617-
var center = map.getCenter();
618-
google.maps.event.trigger(map, 'resize');
619-
map.setCenter(center);
615+
var center = _this.map.getCenter();
616+
google.maps.event.trigger(_this.map, 'resize');
617+
_this.map.setCenter(center);
620618
});
621619

622620
// Only do this once
@@ -1968,11 +1966,11 @@
19681966
noResults;
19691967

19701968
// Create the map
1971-
var map = new google.maps.Map(document.getElementById(this.settings.mapID), myOptions);
1969+
this.map = new google.maps.Map(document.getElementById(this.settings.mapID), myOptions);
19721970

19731971
// Callback
19741972
if (this.settings.callbackNoResults) {
1975-
this.settings.callbackNoResults.call(this, map, myOptions);
1973+
this.settings.callbackNoResults.call(this, this.map, myOptions);
19761974
}
19771975

19781976
// Empty the location list
@@ -1989,10 +1987,10 @@
19891987
center = new google.maps.LatLng(0, 0);
19901988
}
19911989

1992-
map.setCenter(center);
1990+
this.map.setCenter(center);
19931991

19941992
if (originalZoom) {
1995-
map.setZoom(originalZoom);
1993+
this.map.setZoom(originalZoom);
19961994
}
19971995
},
19981996

@@ -2510,35 +2508,35 @@
25102508
}
25112509

25122510
// Create the map
2513-
var map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions);
2511+
_this.map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions);
25142512

25152513
// Re-center the map when the browser is re-sized
25162514
google.maps.event.addDomListener(window, 'resize', function() {
2517-
var center = map.getCenter();
2518-
google.maps.event.trigger(map, 'resize');
2519-
map.setCenter(center);
2515+
var center = _this.map.getCenter();
2516+
google.maps.event.trigger(_this.map, 'resize');
2517+
_this.map.setCenter(center);
25202518
});
25212519

25222520

25232521
// Add map drag listener if setting is enabled and re-search on drag end
25242522
if (_this.settings.dragSearch === true ) {
2525-
map.addListener('dragend', function() {
2523+
_this.map.addListener('dragend', function() {
25262524
_this.dragSearch(map);
25272525
});
25282526
}
25292527

25302528
// Load the map
2531-
$this.data(_this.settings.mapID.replace('#', ''), map);
2529+
$this.data(_this.settings.mapID.replace('#', ''), _this.map);
25322530

25332531
// Map set callback.
25342532
if (_this.settings.callbackMapSet) {
2535-
_this.settings.callbackMapSet.call(this, map, originPoint, originalZoom, myOptions);
2533+
_this.settings.callbackMapSet.call(this, _this.map, originPoint, originalZoom, myOptions);
25362534
}
25372535

25382536
// Initialize the infowondow
25392537
if ( typeof InfoBubble !== 'undefined' && _this.settings.infoBubble !== null ) {
25402538
var infoBubbleSettings = _this.settings.infoBubble;
2541-
infoBubbleSettings.map = map;
2539+
infoBubbleSettings.map = _this.map;
25422540

25432541
infowindow = new InfoBubble(infoBubbleSettings);
25442542
} else {
@@ -2547,7 +2545,7 @@
25472545

25482546

25492547
// Add origin marker if the setting is set
2550-
_this.originMarker(origin,originPoint,map);
2548+
_this.originMarker(origin,originPoint,_this.map);
25512549

25522550
// Handle pagination
25532551
$(document).on('click.'+pluginName, '.bh-sl-pagination li', function (e) {
@@ -2557,7 +2555,7 @@
25572555
});
25582556

25592557
// Inline directions
2560-
_this.inlineDirections(map, origin);
2558+
_this.inlineDirections(_this.map, origin);
25612559

25622560
// Add markers and infowindows loop
25632561
for (var y = 0; y <= storeNumToShow - 1; y++) {
@@ -2571,7 +2569,7 @@
25712569
}
25722570

25732571
var point = new google.maps.LatLng(locationset[y].lat, locationset[y].lng);
2574-
marker = _this.createMarker(point, locationset[y].name, locationset[y].address, letter, map, locationset[y].category);
2572+
marker = _this.createMarker(point, locationset[y].name, locationset[y].address, letter, _this.map, locationset[y].category);
25752573
marker.set('id', y);
25762574
markers[y] = marker;
25772575
if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) {
@@ -2583,7 +2581,7 @@
25832581

25842582
// Center and zoom if no origin or zoom was provided, or distance of first marker is greater than distanceAlert
25852583
if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) {
2586-
map.fitBounds(bounds);
2584+
_this.map.fitBounds(bounds);
25872585
}
25882586

25892587
// Create the links that focus on the related marker
@@ -2605,18 +2603,18 @@
26052603

26062604
// MarkerClusterer setup
26072605
if ( typeof MarkerClusterer !== 'undefined' && _this.settings.markerCluster !== null ) {
2608-
var markerCluster = new MarkerClusterer(map, markers, _this.settings.markerCluster);
2606+
var markerCluster = new MarkerClusterer(_this.map, markers, _this.settings.markerCluster);
26092607
}
26102608

26112609
// Handle clicks from the list
2612-
_this.listClick(map, infowindow, storeStart, page);
2610+
_this.listClick(_this.map, infowindow, storeStart, page);
26132611

26142612
// Add the list li background colors - this wil be dropped in a future version in favor of CSS
26152613
$('.' + _this.settings.locationList + ' ul > li:even').css('background', _this.settings.listColor1);
26162614
$('.' + _this.settings.locationList + ' ul > li:odd').css('background', _this.settings.listColor2);
26172615

26182616
// Visible markers list
2619-
_this.visibleMarkersList(map, markers);
2617+
_this.visibleMarkersList(_this.map, markers);
26202618

26212619
// Modal ready callback
26222620
if (_this.settings.modal === true && _this.settings.callbackModalReady) {

0 commit comments

Comments
 (0)