Skip to content

Commit 6ffd2af

Browse files
committed
Merge remote-tracking branch 'origin/development'
2 parents 2642b42 + 51fa5a6 commit 6ffd2af

12 files changed

+299
-84
lines changed

bower.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "jquery-storelocator-plugin",
3+
"version": "2.0.8",
4+
"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.",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/bjorn2404/jQuery-Store-Locator-Plugin.git"
8+
},
9+
"keywords": ["jquery-plugin","locator","store", "location","locations","maps","map","stores","find","finder"],
10+
"authors": [
11+
"Bjorn Holine <bjorn2404@gmail.com> (http://www.bjornblog.com)"
12+
],
13+
"license": "MIT",
14+
"dependencies": {
15+
"jquery": ">=1.7",
16+
"handlebars": ">=1.0"
17+
},
18+
"devDependencies": {
19+
"grunt-contrib-jshint": "~0.6.0",
20+
"grunt-contrib-qunit": "~0.2.0",
21+
"grunt-contrib-concat": "~0.3.0",
22+
"grunt-contrib-uglify": "~0.2.0",
23+
"grunt-contrib-watch": "~0.4.0",
24+
"grunt-contrib-clean": "~0.4.0",
25+
"grunt-contrib-less": "~0.11.0",
26+
"grunt": "~0.4.4",
27+
"grunt-banner": "~0.2.2",
28+
"grunt-contrib-cssmin": "~0.9.0"
29+
}
30+
}

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

+77-38
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-07-19
22
* http://www.bjornblog.com/web/jquery-store-locator-plugin
33
* Copyright (c) 2015 Bjorn Holine; Licensed MIT */
44

@@ -372,7 +372,7 @@
372372
$(document).on('click.'+pluginName, '.' + this.settings.formContainer + ' button', function (e) {
373373
_this.processForm(e);
374374
});
375-
$(document).on('keyup.'+pluginName, function (e) {
375+
$(document).on('keydown.'+pluginName, function (e) {
376376
if (e.keyCode === 13 && $('#' + _this.settings.addressID).is(':focus')) {
377377
_this.processForm(e);
378378
}
@@ -472,7 +472,7 @@
472472

473473
// If show full map option is true
474474
if (this.settings.fullMapStart === true) {
475-
if(this.settings.querystringParams === true && this.getQueryString(this.settings.addressID) || this.getQueryString(this.settings.searchID)) {
475+
if((this.settings.querystringParams === true && this.getQueryString(this.settings.addressID)) || (this.settings.querystringParams === true && this.getQueryString(this.settings.searchID)) || (this.settings.querystringParams === true && this.getQueryString(this.settings.maxDistanceID))) {
476476
this.processForm(null);
477477
}
478478
else {
@@ -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 + ' '; }
@@ -1132,34 +1132,52 @@
11321132
processForm: function (e) {
11331133
var _this = this;
11341134
var distance = null;
1135+
var $addressInput = $('#' + this.settings.addressID);
1136+
var $searchInput = $('#' + this.settings.searchID);
1137+
var $distanceInput = $('#' + this.settings.maxDistanceID);
11351138

11361139
// Stop the form submission
11371140
if(typeof e !== 'undefined' && e !== null) {
11381141
e.preventDefault();
11391142
}
11401143

1141-
// Get the distance if set
1142-
if (this.settings.maxDistance === true) {
1143-
distance = $('#' + this.settings.maxDistanceID).val();
1144-
}
1145-
1144+
// Query string parameters
11461145
if(this.settings.querystringParams === true) {
1147-
11481146
// Check for query string parameters
1149-
if(this.getQueryString(this.settings.addressID) || this.getQueryString(this.settings.searchID)){
1147+
if(this.getQueryString(this.settings.addressID) || this.getQueryString(this.settings.searchID) || this.getQueryString(this.settings.maxDistanceID)){
11501148
addressInput = this.getQueryString(this.settings.addressID);
11511149
searchInput = this.getQueryString(this.settings.searchID);
1150+
distance = this.getQueryString(this.settings.maxDistanceID);
1151+
1152+
// The form should override the query string parameters
1153+
if($('#' + this.settings.addressID).val() !== '') {
1154+
addressInput = $addressInput.val();
1155+
}
1156+
if($searchInput.val() !== '') {
1157+
searchInput = $searchInput.val();
1158+
}
1159+
if($distanceInput.val() !== '') {
1160+
distance = $distanceInput.val();
1161+
}
11521162
}
11531163
else{
11541164
// Get the user input and use it
1155-
addressInput = $('#' + this.settings.addressID).val();
1156-
searchInput = $('#' + this.settings.searchID).val();
1165+
addressInput = $addressInput.val();
1166+
searchInput = $searchInput.val();
1167+
// Get the distance if set
1168+
if (this.settings.maxDistance === true) {
1169+
distance = $distanceInput.val();
1170+
}
11571171
}
11581172
}
11591173
else {
11601174
// Get the user input and use it
1161-
addressInput = $('#' + this.settings.addressID).val();
1162-
searchInput = $('#' + this.settings.searchID).val();
1175+
addressInput = $addressInput.val();
1176+
searchInput = $searchInput.val();
1177+
// Get the distance if set
1178+
if (this.settings.maxDistance === true) {
1179+
distance = $distanceInput.val();
1180+
}
11631181
}
11641182

11651183
// Get the region setting if set
@@ -1169,24 +1187,37 @@
11691187
this._start();
11701188
}
11711189
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-
});
1190+
1191+
// Geocode the origin if needed
1192+
if(typeof originalOrigin !== 'undefined' && typeof olat !== 'undefined' && typeof olng !== 'undefined' && (addressInput === originalOrigin)) {
1193+
// Run the mapping function
1194+
mappingObj.lat = olat;
1195+
mappingObj.lng = olng;
1196+
mappingObj.origin = addressInput;
1197+
mappingObj.name = searchInput;
1198+
mappingObj.distance = distance;
1199+
_this.mapping(mappingObj);
1200+
}
1201+
else {
1202+
var g = new this.googleGeocode(this);
1203+
g.geocode({'address': addressInput, 'region': region}, function (data) {
1204+
if (data !== null) {
1205+
olat = data.latitude;
1206+
olng = data.longitude;
1207+
1208+
// Run the mapping function
1209+
mappingObj.lat = olat;
1210+
mappingObj.lng = olng;
1211+
mappingObj.origin = addressInput;
1212+
mappingObj.name = searchInput;
1213+
mappingObj.distance = distance;
1214+
_this.mapping(mappingObj);
1215+
} else {
1216+
// Unable to geocode
1217+
_this.notify(_this.settings.addressErrorAlert);
1218+
}
1219+
});
1220+
}
11901221
}
11911222
else if(searchInput !== '') {
11921223
mappingObj.name = searchInput;
@@ -1213,7 +1244,15 @@
12131244

12141245
// Create the array
12151246
if (this.settings.maxDistance === true && firstRun !== true && typeof maxDistance !== 'undefined' && maxDistance !== null) {
1216-
if (data.distance < maxDistance) {
1247+
if (data.distance <= maxDistance) {
1248+
locationset.push( data );
1249+
}
1250+
else {
1251+
return;
1252+
}
1253+
}
1254+
else if(this.settings.maxDistance === true && this.settings.querystringParams === true && this.settings.maxDistance === true && typeof maxDistance !== 'undefined' && maxDistance !== null) {
1255+
if (data.distance <= maxDistance) {
12171256
locationset.push( data );
12181257
}
12191258
else {
@@ -1857,11 +1896,11 @@
18571896
e.preventDefault();
18581897
var locID = $(this).closest('li').attr('data-markerid');
18591898
_this.directionsRequest(origin, locID, map);
1860-
});
18611899

1862-
// Close directions
1863-
$(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' .bh-sl-close-icon', function () {
1864-
_this.closeDirections();
1900+
// Close directions
1901+
$(document).on('click.'+pluginName, '.' + _this.settings.locationList + ' .bh-sl-close-icon', function () {
1902+
_this.closeDirections();
1903+
});
18651904
});
18661905
}
18671906

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

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/assets/js/plugins/storeLocator/templates/infowindow-description.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="loc-name">{{name}}</div>
33
<div>{{address}}</div>
44
<div>{{address2}}</div>
5-
<div>{{city}}{{#if state}},{{/if}} {{state}} {{postal}}</div>
5+
<div>{{city}}{{#if city}},{{/if}} {{state}} {{postal}}</div>
66
<div>{{hours1}}</div>
77
<div>{{hours2}}</div>
88
<div>{{hours3}}</div>

dist/assets/js/plugins/storeLocator/templates/location-list-description.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<div class="loc-name">{{name}}</div>
77
<div class="loc-addr">{{address}}</div>
88
<div class="loc-addr2">{{address2}}</div>
9-
<div class="loc-addr3">{{city}}{{#if state}},{{/if}} {{state}} {{postal}}</div>
9+
<div class="loc-addr3">{{city}}{{#if city}},{{/if}} {{state}} {{postal}}</div>
1010
<div class="loc-phone">{{phone}}</div>
1111
<div class="loc-web"><a href="{{web}}" target="_blank">{{niceURL web}}</a></div>
1212
{{#if distance}}<div class="loc-dist">{{distance}} {{length}}</div>

dist/query-string-example/index.html

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Map Example</title>
5+
<meta charset="UTF-8">
6+
<link rel="stylesheet" type="text/css" href="../assets/css/storelocator.css" />
7+
</head>
8+
9+
<body>
10+
11+
<div class="bh-sl-container">
12+
<div id="page-header">
13+
<h1>Using Chipotle as an Example</h1>
14+
<p>I used locations around Minneapolis and the southwest suburbs. So, for example, Edina, Plymouth, Eden Prarie, etc. would be good for testing the functionality.
15+
You can use just the city as the address - ex: Edina, MN.</p>
16+
</div>
17+
18+
<div class="bh-sl-form-container">
19+
<form id="bh-sl-user-location" method="get" action="submit.html">
20+
<div class="form-input">
21+
<label for="bh-sl-address">Enter Address or Zip Code:</label>
22+
<input type="text" id="bh-sl-address" name="bh-sl-address" />
23+
</div>
24+
25+
<button id="bh-sl-submit" type="submit">Submit</button>
26+
</form>
27+
</div>
28+
29+
<div id="map-container" class="bh-sl-map-container">
30+
<div class="bh-sl-loc-list">
31+
<ul class="list"></ul>
32+
</div>
33+
<div id="bh-sl-map" class="bh-sl-map"></div>
34+
</div>
35+
</div>
36+
37+
</body>
38+
</html>

dist/query-string-example/submit.html

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Map Example</title>
5+
<meta charset="UTF-8">
6+
<link rel="stylesheet" type="text/css" href="../assets/css/storelocator.css" />
7+
</head>
8+
9+
<body>
10+
11+
<div class="bh-sl-container">
12+
<div id="page-header">
13+
<h1>Using Chipotle as an Example</h1>
14+
<p>I used locations around Minneapolis and the southwest suburbs. So, for example, Edina, Plymouth, Eden Prarie, etc. would be good for testing the functionality.
15+
You can use just the city as the address - ex: Edina, MN.</p>
16+
</div>
17+
18+
<div class="bh-sl-form-container">
19+
<form id="bh-sl-user-location" method="post" action="#">
20+
<div class="form-input">
21+
<label for="bh-sl-address">Enter Address or Zip Code:</label>
22+
<input type="text" id="bh-sl-address" name="bh-sl-address" />
23+
</div>
24+
25+
<button id="bh-sl-submit" type="submit">Submit</button>
26+
</form>
27+
</div>
28+
29+
<div id="map-container" class="bh-sl-map-container">
30+
<div class="bh-sl-loc-list">
31+
<ul class="list"></ul>
32+
</div>
33+
<div id="bh-sl-map" class="bh-sl-map"></div>
34+
</div>
35+
</div>
36+
37+
<script src="http://code.jquery.com/jquery-1.11.2.min.js"></script>
38+
<script src="../assets/js/libs/handlebars.min.js"></script>
39+
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
40+
<script src="../assets/js/plugins/storeLocator/jquery.storelocator.js"></script>
41+
<script>
42+
$(function() {
43+
$('#map-container').storeLocator({
44+
'querystringParams' : true,
45+
'fullMapStart': true,
46+
// The following paths are set because this example is in a subdirectory
47+
'dataLocation': '../data/locations.xml',
48+
'infowindowTemplatePath': '../assets/js/plugins/storeLocator/templates/infowindow-description.html',
49+
'listTemplatePath': '../assets/js/plugins/storeLocator/templates/location-list-description.html'
50+
});
51+
});
52+
</script>
53+
54+
</body>
55+
</html>

options.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
| formContainer | 'bh-sl-form-container' | Class of the container around the form. |
66
| formID | 'bh-sl-user-location' | ID of the input form. |
77
| addressID | 'bh-sl-address' | ID of the address input form field. |
8-
| regionID | 'bh-sl-region' | ID of the region input form field for country region biasing select field. |
9-
| mapSettings | { zoom : 12, mapTypeId: google.maps.MapTypeId.ROADMAP } | Google maps settings object. Add all settings including zoom and map type if overriding. |
8+
| regionID | 'bh-sl-region' | ID of the region select form field for country region biasing. |
9+
| mapSettings | { zoom : 12, mapTypeId: google.maps.MapTypeId.ROADMAP } | Google maps settings object. Add all settings including zoom and map type if overriding. Set zoom to 0 to automatically center and zoom to show all display markers on the map |
1010
| markerImg | null | Replacement marker image used for all locations |
1111
| markerDim | null | Replacement marker dimensions object - ex value: { height: 20, width: 20 } |
1212
| catMarkers | null | Multiple replacement marker images based on categories object. Value should be array with image path followed by dimensions - ex value: catMarkers : {'Restaurant' : ['img/red-marker.svg', 32, 32]}
@@ -34,7 +34,7 @@
3434
| defaultLng | null | If using defaultLoc, set this to the default location longitude. |
3535
| autoGeocode | false | Set to true if you want to use the HTML5 geolocation API (good for mobile) to geocode the user's location. |
3636
| maxDistance | false | Set to true if you want to give users an option to limit the distance from their location to the markers. |
37-
| maxDistanceID | 'maxdistance' | ID of the select element for the maximum distance options. |
37+
| maxDistanceID | 'bh-sl-maxdistance' | ID of the select element for the maximum distance options. |
3838
| fullMapStart | false | Set to true if you want to immediately show a map of all locations. The map will center and zoom automatically. |
3939
| noForm | false | Set to true if you aren't able to use form tags (ASP.net WebForms). |
4040
| loading | false | Set to true to display a loading animated gif next to the submit button. |

package.json

+1-1
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

+14
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ for even faster loading.
2727

2828
## Changelog
2929

30+
### Version 2.0.8
31+
32+
* Changed infowindow and location list templates so that the comma is added if the city is available.
33+
* Fixed issue with inline directions where "null" was prepended to the destination address.
34+
* Fixed close directions bug where close icon couldn't be clicked more than two times.
35+
* Fixed bug where form wasn't overriding query string parameters.
36+
* Updated processForm method to accept max distance query string parameter.
37+
* Updated processForm method to use existing origin data if it's present and matches to avoid unnecessary geocode
38+
requests.
39+
* Updated max distance check to less than or equal to the selected distance vs. just less than.
40+
* Updated regionID description in options.md for clarity.
41+
* Updated formEventHandler method to prevent ASP.net form submission on keydown instead of keyup.
42+
* Updated mapSettings description in options.md to highlight that zoom can be set to 0 for automatic centering and zooming.
43+
3044
### Version 2.0.7
3145

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

0 commit comments

Comments
 (0)