Skip to content

Commit 0362245

Browse files
committed
Fixed bug with maxDistance setting, removed testing line from maxdistance-example.html
1 parent fddd577 commit 0362245

File tree

7 files changed

+25
-21
lines changed

7 files changed

+25
-21
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! jQuery Google Maps Store Locator - v2.0.2 - 2014-12-07
1+
/*! jQuery Google Maps Store Locator - v2.0.3 - 2014-12-11
22
* http://www.bjornblog.com/web/jquery-store-locator-plugin
33
* Copyright (c) 2014 Bjorn Holine; Licensed MIT */
44

@@ -1158,7 +1158,7 @@
11581158
* @param origin {string} origin address
11591159
* @param maxDistance {number} maximum distance if set
11601160
*/
1161-
locationsSetup: function (data, l, lat, lng, firstRun, origin, maxDistance) {
1161+
locationsSetup: function (data, lat, lng, firstRun, origin, maxDistance) {
11621162
if (typeof origin !== 'undefined') {
11631163
if (!data.distance) {
11641164
data.distance = this.geoCodeCalcCalcDistance(lat, lng, data.lat, data.lng, GeoCodeCalc.EarthRadius);
@@ -1168,14 +1168,14 @@
11681168
// Create the array
11691169
if (this.settings.maxDistance === true && firstRun !== true && maxDistance !== null) {
11701170
if (data.distance < maxDistance) {
1171-
locationset[l] = data;
1171+
locationset.push( data );
11721172
}
11731173
else {
11741174
return;
11751175
}
11761176
}
11771177
else {
1178-
locationset[l] = data;
1178+
locationset.push( data );
11791179
}
11801180
},
11811181

@@ -1489,7 +1489,7 @@
14891489
}
14901490
}
14911491

1492-
_this.locationsSetup(locationData, i, orig_lat, orig_lng, firstRun, origin, maxDistance);
1492+
_this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance);
14931493

14941494
i++;
14951495
}
@@ -1504,7 +1504,7 @@
15041504
'description': $(this).find('description').text()
15051505
};
15061506

1507-
_this.locationsSetup(locationData, i, orig_lat, orig_lng, firstRun, origin, maxDistance);
1507+
_this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance);
15081508

15091509
i++;
15101510
});
@@ -1520,7 +1520,7 @@
15201520
}
15211521
}
15221522

1523-
_this.locationsSetup(locationData, i, orig_lat, orig_lng, firstRun, origin, maxDistance);
1523+
_this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance);
15241524

15251525
i++;
15261526
});
@@ -1651,7 +1651,7 @@
16511651
}
16521652

16531653
// Avoid error if number of locations is less than the default of 26
1654-
if (_this.settings.storeLimit === -1 || (locationset.length ) < _this.settings.storeLimit) {
1654+
if (_this.settings.storeLimit === -1 || locationset.length < _this.settings.storeLimit) {
16551655
storeNum = locationset.length;
16561656
}
16571657
else {

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

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/maxdistance-example.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ <h1>Using Chipotle as an Example</h1>
4040
</div>
4141
</div>
4242

43-
<div id="distances"></div>
44-
4543
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
4644
<script src="assets/js/libs/handlebars.min.js"></script>
4745
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery-storelocator-plugin",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "This jQuery plugin takes advantage of Google Maps API version 3 to create an easy to implement store locator. No back-end programming is required, you just need to feed it KML, XML, or JSON data with all the location information.",
55
"repository": {
66
"type": "git",

readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ for even faster loading.
2727

2828
## Changelog
2929

30+
### Version 2.0.3
31+
32+
* Fixed bug with maxDistance setting - updated locationsSetup method so that the locationset array uses array.push
33+
instead of incrementing via a passed in parameter, which was causing undefined array elements and causing errors.
34+
* Removed testing line from maxdistance-example.html that was left in.
35+
3036
### Version 2.0.2
3137

3238
* Updated the Handlebars.compile calls when using the inline template options to include the ID hash so that it's

src/js/jquery.storelocator.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@
11561156
* @param origin {string} origin address
11571157
* @param maxDistance {number} maximum distance if set
11581158
*/
1159-
locationsSetup: function (data, l, lat, lng, firstRun, origin, maxDistance) {
1159+
locationsSetup: function (data, lat, lng, firstRun, origin, maxDistance) {
11601160
if (typeof origin !== 'undefined') {
11611161
if (!data.distance) {
11621162
data.distance = this.geoCodeCalcCalcDistance(lat, lng, data.lat, data.lng, GeoCodeCalc.EarthRadius);
@@ -1166,14 +1166,14 @@
11661166
// Create the array
11671167
if (this.settings.maxDistance === true && firstRun !== true && maxDistance !== null) {
11681168
if (data.distance < maxDistance) {
1169-
locationset[l] = data;
1169+
locationset.push( data );
11701170
}
11711171
else {
11721172
return;
11731173
}
11741174
}
11751175
else {
1176-
locationset[l] = data;
1176+
locationset.push( data );
11771177
}
11781178
},
11791179

@@ -1487,7 +1487,7 @@
14871487
}
14881488
}
14891489

1490-
_this.locationsSetup(locationData, i, orig_lat, orig_lng, firstRun, origin, maxDistance);
1490+
_this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance);
14911491

14921492
i++;
14931493
}
@@ -1502,7 +1502,7 @@
15021502
'description': $(this).find('description').text()
15031503
};
15041504

1505-
_this.locationsSetup(locationData, i, orig_lat, orig_lng, firstRun, origin, maxDistance);
1505+
_this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance);
15061506

15071507
i++;
15081508
});
@@ -1518,7 +1518,7 @@
15181518
}
15191519
}
15201520

1521-
_this.locationsSetup(locationData, i, orig_lat, orig_lng, firstRun, origin, maxDistance);
1521+
_this.locationsSetup(locationData, orig_lat, orig_lng, firstRun, origin, maxDistance);
15221522

15231523
i++;
15241524
});
@@ -1649,7 +1649,7 @@
16491649
}
16501650

16511651
// Avoid error if number of locations is less than the default of 26
1652-
if (_this.settings.storeLimit === -1 || (locationset.length ) < _this.settings.storeLimit) {
1652+
if (_this.settings.storeLimit === -1 || locationset.length < _this.settings.storeLimit) {
16531653
storeNum = locationset.length;
16541654
}
16551655
else {

storelocator.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"title": "jQuery Google Maps Store Locator",
44
"description": "This jQuery plugin takes advantage of Google Maps API version 3 to create an easy to implement store locator. No back-end programming is required, you just need to feed it KML, XML, or JSON data with all the location information.",
55
"keywords": ["jquery","locator","store", "location", "locations", "maps", "map", "stores", "find"],
6-
"version": "2.0.2",
6+
"version": "2.0.3",
77
"author": {
88
"name": "Bjorn Holine",
99
"url": "http://www.bjornblog.com/"

0 commit comments

Comments
 (0)