|
1 |
| -/*! jQuery Google Maps Store Locator - v1.4.9 - 2014-10-19 |
| 1 | +/*! jQuery Google Maps Store Locator - v2.0.0 - 2014-10-19 |
2 | 2 | * http://www.bjornblog.com/web/jquery-store-locator-plugin
|
3 | 3 | * Copyright (c) 2014 Bjorn Holine; Licensed MIT */
|
4 | 4 |
|
|
15 | 15 | }
|
16 | 16 |
|
17 | 17 | // Variables used across multiple methods
|
18 |
| - var $this, listTemplate, infowindowTemplate, dataTypeRead, originalData, originalDataRequest, originalZoom, searchInput, addressInput, olat, olng, storeNum, directionsDisplay, directionsService; |
| 18 | + var $this, listTemplate, infowindowTemplate, dataTypeRead, originalOrigin, originalData, originalDataRequest, originalZoom, searchInput, addressInput, olat, olng, storeNum, directionsDisplay, directionsService; |
19 | 19 | var featuredset = [], locationset = [], normalset = [], markers = [];
|
20 | 20 | var filters = {}, locationData = {}, GeoCodeCalc = {}, mappingObj = {};
|
21 | 21 |
|
|
262 | 262 | },
|
263 | 263 |
|
264 | 264 | /**
|
265 |
| - * Load templates via Handlebars templates in /templates or inline via IDs |
| 265 | + * Load templates via Handlebars templates in /templates or inline via IDs - private |
266 | 266 | */
|
267 | 267 | _loadTemplates: function () {
|
268 | 268 | var source;
|
|
434 | 434 |
|
435 | 435 | /**
|
436 | 436 | * Check for existing filter selections
|
| 437 | + * |
437 | 438 | */
|
438 | 439 | checkFilters: function () {
|
439 | 440 | $.each(this.settings.taxonomyFilters, function (k, v) {
|
|
1193 | 1194 | // Setup the origin point
|
1194 | 1195 | var originPoint = new google.maps.LatLng(orig_lat, orig_lng);
|
1195 | 1196 |
|
1196 |
| - // Do the initial data request - doing this in mapping so the lat/lng and address can be passed over and used if needed |
1197 |
| - originalDataRequest = _this._getData(olat, olng, origin); |
| 1197 | + // If the origin hasn't changed use the existing data so we aren't making unneeded AJAX requests |
| 1198 | + if((typeof originalOrigin !== 'undefined') && (origin === originalOrigin) && (typeof originalData !== 'undefined')) { |
| 1199 | + origin = originalOrigin; |
| 1200 | + originalDataRequest = originalData; |
| 1201 | + } |
| 1202 | + else { |
| 1203 | + // Do the data request - doing this in mapping so the lat/lng and address can be passed over and used if needed |
| 1204 | + originalDataRequest = _this._getData(olat, olng, origin); |
| 1205 | + } |
1198 | 1206 | }
|
1199 | 1207 |
|
1200 | 1208 | /**
|
|
1205 | 1213 | // Get the length unit
|
1206 | 1214 | var distUnit = (_this.settings.lengthUnit === 'km') ? _this.settings.kilometersLang : _this.settings.milesLang;
|
1207 | 1215 |
|
1208 |
| - // Save data separately so we can avoid multiple AJAX requests |
1209 |
| - originalData = data; |
| 1216 | + // Save data and origin separately so we can potentially avoid multiple AJAX requests |
| 1217 | + originalData = originalDataRequest; |
| 1218 | + originalOrigin = origin; |
1210 | 1219 |
|
1211 | 1220 | // Callback
|
1212 | 1221 | if (_this.settings.callbackSuccess) {
|
|
1661 | 1670 | // Add ids to the filter arrays as they are checked
|
1662 | 1671 | filters[filterKey].push(filterId);
|
1663 | 1672 | if ($('#' + _this.settings.mapID).hasClass('bh-sl-map-open') === true) {
|
1664 |
| - _this.reset(); |
1665 | 1673 | if ((olat) && (olng)) {
|
1666 | 1674 | _this.settings.mapSettings.zoom = 0;
|
1667 | 1675 | _this.processForm();
|
|
1677 | 1685 | if (filterIndex > -1) {
|
1678 | 1686 | filters[filterKey].splice(filterIndex, 1);
|
1679 | 1687 | if ($('#' + _this.settings.mapID).hasClass('bh-sl-map-open') === true) {
|
1680 |
| - _this.reset(); |
1681 | 1688 | if ((olat) && (olng)) {
|
1682 | 1689 | if (_this.countFilters() === 0) {
|
1683 | 1690 | _this.settings.mapSettings.zoom = originalZoom;
|
|
1709 | 1716 | if (filterKey) {
|
1710 | 1717 | filters[filterKey] = [filterId];
|
1711 | 1718 | if ($('#' + _this.settings.mapID).hasClass('bh-sl-map-open') === true) {
|
1712 |
| - _this.reset(); |
1713 | 1719 | if ((olat) && (olng)) {
|
1714 | 1720 | _this.settings.mapSettings.zoom = 0;
|
1715 | 1721 | _this.processForm();
|
|
0 commit comments