Skip to content

Commit 47db5f6

Browse files
committed
Fixed inline directions null bug, updated processForm method
1 parent b662f35 commit 47db5f6

File tree

6 files changed

+98
-57
lines changed

6 files changed

+98
-57
lines changed

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

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

@@ -1031,7 +1031,7 @@
10311031
* @returns {string} formatted address
10321032
*/
10331033
getAddressByMarker: function(markerID) {
1034-
var formattedAddress = null;
1034+
var formattedAddress = "";
10351035
// Set up formatted address
10361036
if(locationset[markerID].address){ formattedAddress += locationset[markerID].address + ' '; }
10371037
if(locationset[markerID].address2){ formattedAddress += locationset[markerID].address2 + ' '; }
@@ -1138,28 +1138,32 @@
11381138
e.preventDefault();
11391139
}
11401140

1141-
// Get the distance if set
1142-
if (this.settings.maxDistance === true) {
1143-
distance = $('#' + this.settings.maxDistanceID).val();
1144-
}
1145-
1141+
// Query string parameters
11461142
if(this.settings.querystringParams === true) {
1147-
11481143
// Check for query string parameters
1149-
if(this.getQueryString(this.settings.addressID) || this.getQueryString(this.settings.searchID)){
1144+
if(this.getQueryString(this.settings.addressID) || this.getQueryString(this.settings.searchID) || this.getQueryString(this.settings.maxDistanceID)){
11501145
addressInput = this.getQueryString(this.settings.addressID);
11511146
searchInput = this.getQueryString(this.settings.searchID);
1147+
distance = this.getQueryString(this.settings.maxDistanceID);
11521148
}
11531149
else{
11541150
// Get the user input and use it
11551151
addressInput = $('#' + this.settings.addressID).val();
11561152
searchInput = $('#' + this.settings.searchID).val();
1153+
// Get the distance if set
1154+
if (this.settings.maxDistance === true) {
1155+
distance = $('#' + this.settings.maxDistanceID).val();
1156+
}
11571157
}
11581158
}
11591159
else {
11601160
// Get the user input and use it
11611161
addressInput = $('#' + this.settings.addressID).val();
11621162
searchInput = $('#' + this.settings.searchID).val();
1163+
// Get the distance if set
1164+
if (this.settings.maxDistance === true) {
1165+
distance = $('#' + this.settings.maxDistanceID).val();
1166+
}
11631167
}
11641168

11651169
// Get the region setting if set
@@ -1169,24 +1173,37 @@
11691173
this._start();
11701174
}
11711175
else if(addressInput !== '') {
1172-
var g = new this.googleGeocode(this);
1173-
g.geocode({'address': addressInput, 'region': region}, function (data) {
1174-
if (data !== null) {
1175-
olat = data.latitude;
1176-
olng = data.longitude;
1177-
1178-
// Run the mapping function
1179-
mappingObj.lat = olat;
1180-
mappingObj.lng = olng;
1181-
mappingObj.origin = addressInput;
1182-
mappingObj.name = searchInput;
1183-
mappingObj.distance = distance;
1184-
_this.mapping(mappingObj);
1185-
} else {
1186-
// Unable to geocode
1187-
_this.notify(_this.settings.addressErrorAlert);
1188-
}
1189-
});
1176+
1177+
// Geocode the origin if needed
1178+
if(typeof originalOrigin !== 'undefined' && typeof olat !== 'undefined' && typeof olng !== 'undefined' && (addressInput === originalOrigin)) {
1179+
// Run the mapping function
1180+
mappingObj.lat = olat;
1181+
mappingObj.lng = olng;
1182+
mappingObj.origin = addressInput;
1183+
mappingObj.name = searchInput;
1184+
mappingObj.distance = distance;
1185+
_this.mapping(mappingObj);
1186+
}
1187+
else {
1188+
var g = new this.googleGeocode(this);
1189+
g.geocode({'address': addressInput, 'region': region}, function (data) {
1190+
if (data !== null) {
1191+
olat = data.latitude;
1192+
olng = data.longitude;
1193+
1194+
// Run the mapping function
1195+
mappingObj.lat = olat;
1196+
mappingObj.lng = olng;
1197+
mappingObj.origin = addressInput;
1198+
mappingObj.name = searchInput;
1199+
mappingObj.distance = distance;
1200+
_this.mapping(mappingObj);
1201+
} else {
1202+
// Unable to geocode
1203+
_this.notify(_this.settings.addressErrorAlert);
1204+
}
1205+
});
1206+
}
11901207
}
11911208
else if(searchInput !== '') {
11921209
mappingObj.name = searchInput;

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.

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.7",
3+
"version": "2.0.8",
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ for even faster loading.
2727

2828
## Changelog
2929

30+
### Version 2.0.8
31+
32+
* Fixed issue with inline directions where "null" was prepended to the destination address.
33+
* Updated processForm method to accept max distance query string parameter.
34+
* Updated processForm method to use existing origin data if it's presenta and matches to avoid unecessary geocode
35+
requests.
36+
3037
### Version 2.0.7
3138

3239
* Fixed bug where reverse geocoding wasn't passing the origin to the templates (autogeocode and default location),

src/js/jquery.storelocator.js

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@
10291029
* @returns {string} formatted address
10301030
*/
10311031
getAddressByMarker: function(markerID) {
1032-
var formattedAddress = null;
1032+
var formattedAddress = "";
10331033
// Set up formatted address
10341034
if(locationset[markerID].address){ formattedAddress += locationset[markerID].address + ' '; }
10351035
if(locationset[markerID].address2){ formattedAddress += locationset[markerID].address2 + ' '; }
@@ -1136,28 +1136,32 @@
11361136
e.preventDefault();
11371137
}
11381138

1139-
// Get the distance if set
1140-
if (this.settings.maxDistance === true) {
1141-
distance = $('#' + this.settings.maxDistanceID).val();
1142-
}
1143-
1139+
// Query string parameters
11441140
if(this.settings.querystringParams === true) {
1145-
11461141
// Check for query string parameters
1147-
if(this.getQueryString(this.settings.addressID) || this.getQueryString(this.settings.searchID)){
1142+
if(this.getQueryString(this.settings.addressID) || this.getQueryString(this.settings.searchID) || this.getQueryString(this.settings.maxDistanceID)){
11481143
addressInput = this.getQueryString(this.settings.addressID);
11491144
searchInput = this.getQueryString(this.settings.searchID);
1145+
distance = this.getQueryString(this.settings.maxDistanceID);
11501146
}
11511147
else{
11521148
// Get the user input and use it
11531149
addressInput = $('#' + this.settings.addressID).val();
11541150
searchInput = $('#' + this.settings.searchID).val();
1151+
// Get the distance if set
1152+
if (this.settings.maxDistance === true) {
1153+
distance = $('#' + this.settings.maxDistanceID).val();
1154+
}
11551155
}
11561156
}
11571157
else {
11581158
// Get the user input and use it
11591159
addressInput = $('#' + this.settings.addressID).val();
11601160
searchInput = $('#' + this.settings.searchID).val();
1161+
// Get the distance if set
1162+
if (this.settings.maxDistance === true) {
1163+
distance = $('#' + this.settings.maxDistanceID).val();
1164+
}
11611165
}
11621166

11631167
// Get the region setting if set
@@ -1167,24 +1171,37 @@
11671171
this._start();
11681172
}
11691173
else if(addressInput !== '') {
1170-
var g = new this.googleGeocode(this);
1171-
g.geocode({'address': addressInput, 'region': region}, function (data) {
1172-
if (data !== null) {
1173-
olat = data.latitude;
1174-
olng = data.longitude;
1175-
1176-
// Run the mapping function
1177-
mappingObj.lat = olat;
1178-
mappingObj.lng = olng;
1179-
mappingObj.origin = addressInput;
1180-
mappingObj.name = searchInput;
1181-
mappingObj.distance = distance;
1182-
_this.mapping(mappingObj);
1183-
} else {
1184-
// Unable to geocode
1185-
_this.notify(_this.settings.addressErrorAlert);
1186-
}
1187-
});
1174+
1175+
// Geocode the origin if needed
1176+
if(typeof originalOrigin !== 'undefined' && typeof olat !== 'undefined' && typeof olng !== 'undefined' && (addressInput === originalOrigin)) {
1177+
// Run the mapping function
1178+
mappingObj.lat = olat;
1179+
mappingObj.lng = olng;
1180+
mappingObj.origin = addressInput;
1181+
mappingObj.name = searchInput;
1182+
mappingObj.distance = distance;
1183+
_this.mapping(mappingObj);
1184+
}
1185+
else {
1186+
var g = new this.googleGeocode(this);
1187+
g.geocode({'address': addressInput, 'region': region}, function (data) {
1188+
if (data !== null) {
1189+
olat = data.latitude;
1190+
olng = data.longitude;
1191+
1192+
// Run the mapping function
1193+
mappingObj.lat = olat;
1194+
mappingObj.lng = olng;
1195+
mappingObj.origin = addressInput;
1196+
mappingObj.name = searchInput;
1197+
mappingObj.distance = distance;
1198+
_this.mapping(mappingObj);
1199+
} else {
1200+
// Unable to geocode
1201+
_this.notify(_this.settings.addressErrorAlert);
1202+
}
1203+
});
1204+
}
11881205
}
11891206
else if(searchInput !== '') {
11901207
mappingObj.name = searchInput;

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

0 commit comments

Comments
 (0)