Skip to content

Commit effeddc

Browse files
committed
Changed distance error functionality so map centers and zooms automatically and displays all locations along after notification
1 parent 45e64a9 commit effeddc

File tree

4 files changed

+22
-14
lines changed

4 files changed

+22
-14
lines changed

dist/assets/js/plugins/storeLocator/jquery.storelocator.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@
15391539
processData: function (mappingObject, originPoint, data, page) {
15401540
var _this = this;
15411541
var i = 0;
1542-
var orig_lat, orig_lng, origin, name, maxDistance, firstRun, marker, bounds, storeStart, storeNumToShow, myOptions, noResults;
1542+
var orig_lat, orig_lng, origin, name, maxDistance, firstRun, marker, bounds, storeStart, storeNumToShow, myOptions, noResults, distError;
15431543
if (!this.isEmptyObject(mappingObject)) {
15441544
orig_lat = mappingObject.lat;
15451545
orig_lng = mappingObject.lng;
@@ -1709,6 +1709,7 @@
17091709
else {
17101710
if (_this.settings.distanceAlert !== -1 && locationset[0].distance > _this.settings.distanceAlert) {
17111711
_this.notify(_this.settings.distanceErrorAlert + _this.settings.distanceAlert + ' ' + distUnit);
1712+
distError = true;
17121713
}
17131714
}
17141715

@@ -1773,7 +1774,7 @@
17731774
}
17741775

17751776
// Google maps settings
1776-
if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) {
1777+
if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) {
17771778
myOptions = _this.settings.mapSettings;
17781779
bounds = new google.maps.LatLngBounds();
17791780
}
@@ -1798,7 +1799,7 @@
17981799
// Create the map
17991800
var map = new google.maps.Map(document.getElementById(_this.settings.mapID), myOptions);
18001801

1801-
// Re-center the map when the browser is resized
1802+
// Re-center the map when the browser is re-sized
18021803
google.maps.event.addDomListener(window, 'resize', function() {
18031804
var center = map.getCenter();
18041805
google.maps.event.trigger(map, 'resize');
@@ -1879,15 +1880,15 @@
18791880
marker = _this.createMarker(point, locationset[y].name, locationset[y].address, letter, map, locationset[y].category);
18801881
marker.set('id', y);
18811882
markers[y] = marker;
1882-
if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) {
1883+
if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) {
18831884
bounds.extend(point);
18841885
}
18851886
// Pass variables to the pop-up infowindows
18861887
_this.createInfowindow(marker, null, infowindow, storeStart, page);
18871888
}
18881889

1889-
// Center and zoom if no origin or zoom was provided
1890-
if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined')) {
1890+
// Center and zoom if no origin or zoom was provided, or distance of first marker is greater than distanceAlert
1891+
if ((_this.settings.fullMapStart === true && firstRun === true) || (_this.settings.mapSettings.zoom === 0) || (typeof origin === 'undefined') || (distError === true)) {
18911892
map.fitBounds(bounds);
18921893
}
18931894

0 commit comments

Comments
 (0)