Skip to content

Commit 4fa0327

Browse files
committed
Autocomplete options
1 parent 940bd18 commit 4fa0327

File tree

4 files changed

+34
-31
lines changed

4 files changed

+34
-31
lines changed

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

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

@@ -58,6 +58,7 @@
5858
'defaultLat' : null,
5959
'defaultLng' : null,
6060
'autoComplete' : false,
61+
'autoCompleteOptions' : {},
6162
'autoGeocode' : false,
6263
'geocodeID' : null,
6364
'maxDistance' : false,
@@ -190,7 +191,7 @@
190191
// Set up Google Places autocomplete if it's set to true
191192
if (this.settings.autoComplete === true) {
192193
var searchInput = document.getElementById(this.settings.addressID);
193-
var autoPlaces = new google.maps.places.Autocomplete(searchInput);
194+
var autoPlaces = new google.maps.places.Autocomplete(searchInput, this.settings.autoCompleteOptions);
194195
}
195196

196197
// Load the templates and continue from there
@@ -470,7 +471,7 @@
470471
else {
471472
return [];
472473
}
473-
474+
474475
}
475476
}
476477
// Remote data
@@ -518,14 +519,14 @@
518519
doAutoGeo = this.settings.autoGeocode,
519520
latlng,
520521
originAddress;
521-
522+
522523
// Full map blank start
523524
if (_this.settings.fullMapStartBlank !== false) {
524525
var $mapDiv = $('#' + _this.settings.mapID);
525526
$mapDiv.addClass('bh-sl-map-open');
526527
var myOptions = _this.settings.mapSettings;
527528
myOptions.zoom = _this.settings.fullMapStartBlank;
528-
529+
529530
latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
530531
myOptions.center = latlng;
531532

@@ -1067,7 +1068,7 @@
10671068

10681069
/**
10691070
* Change the selected marker image
1070-
*
1071+
*
10711072
* @param marker {Object} Google Maps marker object
10721073
*/
10731074
changeSelectedMarker: function (marker) {
@@ -1125,7 +1126,7 @@
11251126
// Focus on the list
11261127
var markerId = marker.get('id');
11271128
var $selectedLocation = $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']');
1128-
1129+
11291130
if ($selectedLocation.length > 0) {
11301131
// Marker click callback
11311132
if (_this.settings.callbackMarkerClick) {
@@ -1309,14 +1310,14 @@
13091310
clearMarkers: function() {
13101311
this.writeDebug('clearMarkers');
13111312
var locationsLimit = null;
1312-
1313+
13131314
if (locationset.length < this.settings.storeLimit) {
13141315
locationsLimit = locationset.length;
13151316
}
13161317
else {
13171318
locationsLimit = this.settings.storeLimit;
13181319
}
1319-
1320+
13201321
for (var i = 0; i < locationsLimit; i++) {
13211322
markers[i].setMap(null);
13221323
}
@@ -1344,7 +1345,7 @@
13441345
$('.' + this.settings.locationList + ' ul').hide();
13451346
// Remove the markers
13461347
this.clearMarkers();
1347-
1348+
13481349
// Clear the previous directions request
13491350
if(directionsDisplay !== null && typeof directionsDisplay !== 'undefined') {
13501351
directionsDisplay.setMap(null);
@@ -1353,7 +1354,7 @@
13531354

13541355
directionsDisplay = new google.maps.DirectionsRenderer();
13551356
directionsService = new google.maps.DirectionsService();
1356-
1357+
13571358
// Directions request
13581359
directionsDisplay.setMap(map);
13591360
directionsDisplay.setPanel($('.bh-sl-directions-panel').get(0));
@@ -1388,7 +1389,7 @@
13881389

13891390
// Remove the close icon, remove the directions, add the list back
13901391
this.reset();
1391-
1392+
13921393
if ((olat) && (olng)) {
13931394
if (this.countFilters() === 0) {
13941395
this.settings.mapSettings.zoom = originalZoom;
@@ -1886,7 +1887,7 @@
18861887
origin = mappingObject.origin;
18871888
page = mappingObject.page;
18881889
}
1889-
1890+
18901891
// Set the initial page to zero if not set
18911892
if ( _this.settings.pagination === true ) {
18921893
if (typeof page === 'undefined' || originalOrigin !== addressInput ) {
@@ -2390,7 +2391,7 @@
23902391

23912392
/**
23922393
* console.log helper function
2393-
*
2394+
*
23942395
* http://www.briangrinstead.com/blog/console-log-helper-function
23952396
*/
23962397
writeDebug: function () {

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.

options.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
| defaultLat | null | If using defaultLoc, set this to the default location latitude. |
3737
| defaultLng | null | If using defaultLoc, set this to the default location longitude. |
3838
| autoComplete | false | Set to true to enable Google Places autocomplete. Note the slight markup differences in the example file. |
39+
| autoCompleteOptions | {} | Google Places autocomplete [options object](https://developers.google.com/maps/documentation/javascript/places-autocomplete#add_autocomplete). |
3940
| autoGeocode | false | Set to true if you want to use the HTML5 geolocation API (good for mobile) to geocode the user's location. |
4041
| geocodeID | null | Set to the ID of an element to connect the HTML5 geolocation API to a button instead of firing automatically. |
4142
| maxDistance | false | Set to true if you want to give users an option to limit the distance from their location to the markers. |
@@ -92,4 +93,4 @@
9293
| noResultsTitle | 'No results' | Language setting |
9394
| noResultsDesc | 'No locations were found with the given criteria. Please modify your selections or input.' | Language setting |
9495
| nextPage | 'Next &raquo;' | Language setting |
95-
| prevPage | '&laquo; Prev' | Language setting |
96+
| prevPage | '&laquo; Prev' | Language setting |

src/js/jquery.storelocator.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
'defaultLat' : null,
5656
'defaultLng' : null,
5757
'autoComplete' : false,
58+
'autoCompleteOptions' : {},
5859
'autoGeocode' : false,
5960
'geocodeID' : null,
6061
'maxDistance' : false,
@@ -187,7 +188,7 @@
187188
// Set up Google Places autocomplete if it's set to true
188189
if (this.settings.autoComplete === true) {
189190
var searchInput = document.getElementById(this.settings.addressID);
190-
var autoPlaces = new google.maps.places.Autocomplete(searchInput);
191+
var autoPlaces = new google.maps.places.Autocomplete(searchInput, this.settings.autoCompleteOptions);
191192
}
192193

193194
// Load the templates and continue from there
@@ -467,7 +468,7 @@
467468
else {
468469
return [];
469470
}
470-
471+
471472
}
472473
}
473474
// Remote data
@@ -515,14 +516,14 @@
515516
doAutoGeo = this.settings.autoGeocode,
516517
latlng,
517518
originAddress;
518-
519+
519520
// Full map blank start
520521
if (_this.settings.fullMapStartBlank !== false) {
521522
var $mapDiv = $('#' + _this.settings.mapID);
522523
$mapDiv.addClass('bh-sl-map-open');
523524
var myOptions = _this.settings.mapSettings;
524525
myOptions.zoom = _this.settings.fullMapStartBlank;
525-
526+
526527
latlng = new google.maps.LatLng(this.settings.defaultLat, this.settings.defaultLng);
527528
myOptions.center = latlng;
528529

@@ -1064,7 +1065,7 @@
10641065

10651066
/**
10661067
* Change the selected marker image
1067-
*
1068+
*
10681069
* @param marker {Object} Google Maps marker object
10691070
*/
10701071
changeSelectedMarker: function (marker) {
@@ -1122,7 +1123,7 @@
11221123
// Focus on the list
11231124
var markerId = marker.get('id');
11241125
var $selectedLocation = $('.' + _this.settings.locationList + ' li[data-markerid=' + markerId + ']');
1125-
1126+
11261127
if ($selectedLocation.length > 0) {
11271128
// Marker click callback
11281129
if (_this.settings.callbackMarkerClick) {
@@ -1306,14 +1307,14 @@
13061307
clearMarkers: function() {
13071308
this.writeDebug('clearMarkers');
13081309
var locationsLimit = null;
1309-
1310+
13101311
if (locationset.length < this.settings.storeLimit) {
13111312
locationsLimit = locationset.length;
13121313
}
13131314
else {
13141315
locationsLimit = this.settings.storeLimit;
13151316
}
1316-
1317+
13171318
for (var i = 0; i < locationsLimit; i++) {
13181319
markers[i].setMap(null);
13191320
}
@@ -1341,7 +1342,7 @@
13411342
$('.' + this.settings.locationList + ' ul').hide();
13421343
// Remove the markers
13431344
this.clearMarkers();
1344-
1345+
13451346
// Clear the previous directions request
13461347
if(directionsDisplay !== null && typeof directionsDisplay !== 'undefined') {
13471348
directionsDisplay.setMap(null);
@@ -1350,7 +1351,7 @@
13501351

13511352
directionsDisplay = new google.maps.DirectionsRenderer();
13521353
directionsService = new google.maps.DirectionsService();
1353-
1354+
13541355
// Directions request
13551356
directionsDisplay.setMap(map);
13561357
directionsDisplay.setPanel($('.bh-sl-directions-panel').get(0));
@@ -1385,7 +1386,7 @@
13851386

13861387
// Remove the close icon, remove the directions, add the list back
13871388
this.reset();
1388-
1389+
13891390
if ((olat) && (olng)) {
13901391
if (this.countFilters() === 0) {
13911392
this.settings.mapSettings.zoom = originalZoom;
@@ -1883,7 +1884,7 @@
18831884
origin = mappingObject.origin;
18841885
page = mappingObject.page;
18851886
}
1886-
1887+
18871888
// Set the initial page to zero if not set
18881889
if ( _this.settings.pagination === true ) {
18891890
if (typeof page === 'undefined' || originalOrigin !== addressInput ) {
@@ -2387,7 +2388,7 @@
23872388

23882389
/**
23892390
* console.log helper function
2390-
*
2391+
*
23912392
* http://www.briangrinstead.com/blog/console-log-helper-function
23922393
*/
23932394
writeDebug: function () {

0 commit comments

Comments
 (0)