Skip to content

Commit ef8cee5

Browse files
committed
Removed check from createMarker method that removed spaces from categories - created issues with categories that have spaces, Updated createMarker method to ensure custom category marker images are converted to integers if strings are passed for dimensions, Updated autoGeocode and default location functionality so that max distance is applied on initial load
1 parent 326c56f commit ef8cee5

File tree

7 files changed

+177
-53
lines changed

7 files changed

+177
-53
lines changed

bower.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.5.2",
3+
"version": "2.5.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",

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

Lines changed: 83 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! jQuery Google Maps Store Locator - v2.5.2 - 2016-03-16
1+
/*! jQuery Google Maps Store Locator - v2.5.2 - 2016-04-03
22
* http://www.bjornblog.com/web/jquery-store-locator-plugin
33
* Copyright (c) 2016 Bjorn Holine; Licensed MIT */
44

@@ -530,21 +530,7 @@
530530
else {
531531
// If a default location is set
532532
if (this.settings.defaultLoc === true) {
533-
// The address needs to be determined for the directions link
534-
var r = new this.reverseGoogleGeocode(this);
535-
latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
536-
r.geocode({'latLng': latlng}, function (data) {
537-
if (data !== null) {
538-
originAddress = addressInput = data.address;
539-
olat = mappingObj.lat = _this.settings.defaultLat;
540-
olng = mappingObj.lng = _this.settings.defaultLng;
541-
mappingObj.origin = originAddress;
542-
_this.mapping(mappingObj);
543-
} else {
544-
// Unable to geocode
545-
_this.notify(_this.settings.addressErrorAlert);
546-
}
547-
});
533+
this.defaultLocation();
548534
}
549535

550536
// If there is already have a value in the address bar
@@ -928,11 +914,6 @@
928914
var marker, markerImg, letterMarkerImg;
929915
var categories = [];
930916

931-
// Remove any spaces from category value
932-
if(typeof category !== 'undefined' && category.length) {
933-
category = category.replace(/\s+/g, '');
934-
}
935-
936917
// Custom multi-marker image override (different markers for different categories
937918
if(this.settings.catMarkers !== null) {
938919
if(typeof category !== 'undefined') {
@@ -943,14 +924,14 @@
943924
// With multiple categories the color will be determined by the last matched category in the data
944925
for(var i = 0; i < categories.length; i++) {
945926
if(categories[i] in this.settings.catMarkers) {
946-
markerImg = this.markerImage(this.settings.catMarkers[categories[i]][0], this.settings.catMarkers[categories[i]][1], this.settings.catMarkers[categories[i]][2]);
927+
markerImg = this.markerImage(this.settings.catMarkers[categories[i]][0], parseInt(this.settings.catMarkers[categories[i]][1]), parseInt(this.settings.catMarkers[categories[i]][2]));
947928
}
948929
}
949930
}
950931
// Single category
951932
else {
952933
if(category in this.settings.catMarkers) {
953-
markerImg = this.markerImage(this.settings.catMarkers[category][0], this.settings.catMarkers[category][1], this.settings.catMarkers[category][2]);
934+
markerImg = this.markerImage(this.settings.catMarkers[category][0], parseInt(this.settings.catMarkers[category][1]), parseInt(this.settings.catMarkers[category][2]));
954935
}
955936
}
956937
}
@@ -1160,8 +1141,33 @@
11601141
autoGeocodeQuery: function (position) {
11611142
this.writeDebug('autoGeocodeQuery',arguments);
11621143
var _this = this,
1144+
distance = null,
1145+
$distanceInput = $('#' + this.settings.maxDistanceID),
11631146
originAddress;
11641147

1148+
// Query string parameters
1149+
if(this.settings.querystringParams === true) {
1150+
// Check for distance query string parameters
1151+
if(this.getQueryString(this.settings.maxDistanceID)){
1152+
distance = this.getQueryString(this.settings.maxDistanceID);
1153+
1154+
if($distanceInput.val() !== '') {
1155+
distance = $distanceInput.val();
1156+
}
1157+
}
1158+
else{
1159+
// Get the distance if set
1160+
if (this.settings.maxDistance === true) {
1161+
distance = $distanceInput.val() || '';
1162+
}
1163+
}
1164+
}
1165+
else {
1166+
// Get the distance if set
1167+
if (this.settings.maxDistance === true) {
1168+
distance = $distanceInput.val() || '';
1169+
}
1170+
}
11651171

11661172
// The address needs to be determined for the directions link
11671173
var r = new this.reverseGoogleGeocode(this);
@@ -1172,6 +1178,7 @@
11721178
olat = mappingObj.lat = position.coords.latitude;
11731179
olng = mappingObj.lng = position.coords.longitude;
11741180
mappingObj.origin = originAddress;
1181+
mappingObj.distance = distance;
11751182
_this.mapping(mappingObj);
11761183
} else {
11771184
// Unable to geocode
@@ -1190,6 +1197,58 @@
11901197
this.notify(this.settings.autoGeocodeErrorAlert);
11911198
},
11921199

1200+
/**
1201+
* Default location method
1202+
*/
1203+
defaultLocation: function() {
1204+
this.writeDebug('defaultLocation');
1205+
var _this = this,
1206+
distance = null,
1207+
$distanceInput = $('#' + this.settings.maxDistanceID),
1208+
originAddress;
1209+
1210+
// Query string parameters
1211+
if(this.settings.querystringParams === true) {
1212+
// Check for distance query string parameters
1213+
if(this.getQueryString(this.settings.maxDistanceID)){
1214+
distance = this.getQueryString(this.settings.maxDistanceID);
1215+
1216+
if($distanceInput.val() !== '') {
1217+
distance = $distanceInput.val();
1218+
}
1219+
}
1220+
else{
1221+
// Get the distance if set
1222+
if (this.settings.maxDistance === true) {
1223+
distance = $distanceInput.val() || '';
1224+
}
1225+
}
1226+
}
1227+
else {
1228+
// Get the distance if set
1229+
if (this.settings.maxDistance === true) {
1230+
distance = $distanceInput.val() || '';
1231+
}
1232+
}
1233+
1234+
// The address needs to be determined for the directions link
1235+
var r = new this.reverseGoogleGeocode(this);
1236+
var latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
1237+
r.geocode({'latLng': latlng}, function (data) {
1238+
if (data !== null) {
1239+
originAddress = addressInput = data.address;
1240+
olat = mappingObj.lat = _this.settings.defaultLat;
1241+
olng = mappingObj.lng = _this.settings.defaultLng;
1242+
mappingObj.distance = distance;
1243+
mappingObj.origin = originAddress;
1244+
_this.mapping(mappingObj);
1245+
} else {
1246+
// Unable to geocode
1247+
_this.notify(_this.settings.addressErrorAlert);
1248+
}
1249+
});
1250+
},
1251+
11931252
/**
11941253
* Change the page
11951254
*
@@ -1446,7 +1505,7 @@
14461505
}
14471506

14481507
// Create the array
1449-
if (this.settings.maxDistance === true && firstRun !== true && typeof maxDistance !== 'undefined' && maxDistance !== null) {
1508+
if (this.settings.maxDistance === true && typeof maxDistance !== 'undefined' && maxDistance !== null) {
14501509
if (data.distance <= maxDistance) {
14511510
locationset.push( data );
14521511
}

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

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

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.5.2",
3+
"version": "2.5.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
@@ -35,6 +35,12 @@ filtering.
3535

3636
## Changelog
3737

38+
### Version 2.5.3
39+
40+
* Removed check from createMarker method that removed spaces from categories - created issues with categories that have spaces.
41+
* Updated createMarker method to ensure custom category marker images are converted to integers if strings are passed for dimensions.
42+
* Updated autoGeocode and default location functionality so that max distance is applied on initial load.
43+
3844
### Version 2.5.2
3945

4046
* Fixed pagination bubbling issue.

src/js/jquery.storelocator.js

Lines changed: 82 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -527,21 +527,7 @@
527527
else {
528528
// If a default location is set
529529
if (this.settings.defaultLoc === true) {
530-
// The address needs to be determined for the directions link
531-
var r = new this.reverseGoogleGeocode(this);
532-
latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
533-
r.geocode({'latLng': latlng}, function (data) {
534-
if (data !== null) {
535-
originAddress = addressInput = data.address;
536-
olat = mappingObj.lat = _this.settings.defaultLat;
537-
olng = mappingObj.lng = _this.settings.defaultLng;
538-
mappingObj.origin = originAddress;
539-
_this.mapping(mappingObj);
540-
} else {
541-
// Unable to geocode
542-
_this.notify(_this.settings.addressErrorAlert);
543-
}
544-
});
530+
this.defaultLocation();
545531
}
546532

547533
// If there is already have a value in the address bar
@@ -925,11 +911,6 @@
925911
var marker, markerImg, letterMarkerImg;
926912
var categories = [];
927913

928-
// Remove any spaces from category value
929-
if(typeof category !== 'undefined' && category.length) {
930-
category = category.replace(/\s+/g, '');
931-
}
932-
933914
// Custom multi-marker image override (different markers for different categories
934915
if(this.settings.catMarkers !== null) {
935916
if(typeof category !== 'undefined') {
@@ -940,14 +921,14 @@
940921
// With multiple categories the color will be determined by the last matched category in the data
941922
for(var i = 0; i < categories.length; i++) {
942923
if(categories[i] in this.settings.catMarkers) {
943-
markerImg = this.markerImage(this.settings.catMarkers[categories[i]][0], this.settings.catMarkers[categories[i]][1], this.settings.catMarkers[categories[i]][2]);
924+
markerImg = this.markerImage(this.settings.catMarkers[categories[i]][0], parseInt(this.settings.catMarkers[categories[i]][1]), parseInt(this.settings.catMarkers[categories[i]][2]));
944925
}
945926
}
946927
}
947928
// Single category
948929
else {
949930
if(category in this.settings.catMarkers) {
950-
markerImg = this.markerImage(this.settings.catMarkers[category][0], this.settings.catMarkers[category][1], this.settings.catMarkers[category][2]);
931+
markerImg = this.markerImage(this.settings.catMarkers[category][0], parseInt(this.settings.catMarkers[category][1]), parseInt(this.settings.catMarkers[category][2]));
951932
}
952933
}
953934
}
@@ -1157,8 +1138,33 @@
11571138
autoGeocodeQuery: function (position) {
11581139
this.writeDebug('autoGeocodeQuery',arguments);
11591140
var _this = this,
1141+
distance = null,
1142+
$distanceInput = $('#' + this.settings.maxDistanceID),
11601143
originAddress;
11611144

1145+
// Query string parameters
1146+
if(this.settings.querystringParams === true) {
1147+
// Check for distance query string parameters
1148+
if(this.getQueryString(this.settings.maxDistanceID)){
1149+
distance = this.getQueryString(this.settings.maxDistanceID);
1150+
1151+
if($distanceInput.val() !== '') {
1152+
distance = $distanceInput.val();
1153+
}
1154+
}
1155+
else{
1156+
// Get the distance if set
1157+
if (this.settings.maxDistance === true) {
1158+
distance = $distanceInput.val() || '';
1159+
}
1160+
}
1161+
}
1162+
else {
1163+
// Get the distance if set
1164+
if (this.settings.maxDistance === true) {
1165+
distance = $distanceInput.val() || '';
1166+
}
1167+
}
11621168

11631169
// The address needs to be determined for the directions link
11641170
var r = new this.reverseGoogleGeocode(this);
@@ -1169,6 +1175,7 @@
11691175
olat = mappingObj.lat = position.coords.latitude;
11701176
olng = mappingObj.lng = position.coords.longitude;
11711177
mappingObj.origin = originAddress;
1178+
mappingObj.distance = distance;
11721179
_this.mapping(mappingObj);
11731180
} else {
11741181
// Unable to geocode
@@ -1187,6 +1194,58 @@
11871194
this.notify(this.settings.autoGeocodeErrorAlert);
11881195
},
11891196

1197+
/**
1198+
* Default location method
1199+
*/
1200+
defaultLocation: function() {
1201+
this.writeDebug('defaultLocation');
1202+
var _this = this,
1203+
distance = null,
1204+
$distanceInput = $('#' + this.settings.maxDistanceID),
1205+
originAddress;
1206+
1207+
// Query string parameters
1208+
if(this.settings.querystringParams === true) {
1209+
// Check for distance query string parameters
1210+
if(this.getQueryString(this.settings.maxDistanceID)){
1211+
distance = this.getQueryString(this.settings.maxDistanceID);
1212+
1213+
if($distanceInput.val() !== '') {
1214+
distance = $distanceInput.val();
1215+
}
1216+
}
1217+
else{
1218+
// Get the distance if set
1219+
if (this.settings.maxDistance === true) {
1220+
distance = $distanceInput.val() || '';
1221+
}
1222+
}
1223+
}
1224+
else {
1225+
// Get the distance if set
1226+
if (this.settings.maxDistance === true) {
1227+
distance = $distanceInput.val() || '';
1228+
}
1229+
}
1230+
1231+
// The address needs to be determined for the directions link
1232+
var r = new this.reverseGoogleGeocode(this);
1233+
var latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
1234+
r.geocode({'latLng': latlng}, function (data) {
1235+
if (data !== null) {
1236+
originAddress = addressInput = data.address;
1237+
olat = mappingObj.lat = _this.settings.defaultLat;
1238+
olng = mappingObj.lng = _this.settings.defaultLng;
1239+
mappingObj.distance = distance;
1240+
mappingObj.origin = originAddress;
1241+
_this.mapping(mappingObj);
1242+
} else {
1243+
// Unable to geocode
1244+
_this.notify(_this.settings.addressErrorAlert);
1245+
}
1246+
});
1247+
},
1248+
11901249
/**
11911250
* Change the page
11921251
*
@@ -1443,7 +1502,7 @@
14431502
}
14441503

14451504
// Create the array
1446-
if (this.settings.maxDistance === true && firstRun !== true && typeof maxDistance !== 'undefined' && maxDistance !== null) {
1505+
if (this.settings.maxDistance === true && typeof maxDistance !== 'undefined' && maxDistance !== null) {
14471506
if (data.distance <= maxDistance) {
14481507
locationset.push( data );
14491508
}

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.5.2",
6+
"version": "2.5.3",
77
"author": {
88
"name": "Bjorn Holine",
99
"url": "http://www.bjornblog.com/"

0 commit comments

Comments
 (0)