|
1 |
| -/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-26 |
| 1 | +/*! jQuery Google Maps Store Locator - v2.0.6 - 2015-03-27 |
2 | 2 | * http://www.bjornblog.com/web/jquery-store-locator-plugin
|
3 | 3 | * Copyright (c) 2015 Bjorn Holine; Licensed MIT */
|
4 | 4 |
|
|
68 | 68 | 'nameSearch' : false,
|
69 | 69 | 'searchID' : 'bh-sl-search',
|
70 | 70 | 'nameAttribute' : 'name',
|
| 71 | + 'visibleMarkersList' : false, |
71 | 72 | 'infowindowTemplatePath' : 'assets/js/plugins/storeLocator/templates/infowindow-description.html',
|
72 | 73 | 'listTemplatePath' : 'assets/js/plugins/storeLocator/templates/location-list-description.html',
|
73 | 74 | 'KMLinfowindowTemplatePath': 'assets/js/plugins/storeLocator/templates/kml-infowindow-description.html',
|
|
1442 | 1443 | });
|
1443 | 1444 | },
|
1444 | 1445 |
|
| 1446 | + /** |
| 1447 | + * Updates the location list to reflect the markers that are displayed on the map |
| 1448 | + * |
| 1449 | + * @param markers {Object} Map markers |
| 1450 | + * @param map {Object} Google map |
| 1451 | + */ |
| 1452 | + checkVisibleMarkers: function(markers, map) { |
| 1453 | + var _this = this; |
| 1454 | + var locations, listHtml; |
| 1455 | + |
| 1456 | + // Empty the location list |
| 1457 | + $('.' + this.settings.locationList + ' ul').empty(); |
| 1458 | + |
| 1459 | + // Set up the new list |
| 1460 | + $(markers).each(function(x, marker){ |
| 1461 | + if(map.getBounds().contains(marker.getPosition())) { |
| 1462 | + // Define the location data |
| 1463 | + _this.listSetup(marker, 0, 0); |
| 1464 | + |
| 1465 | + // Set up the list template with the location data |
| 1466 | + listHtml = listTemplate(locations); |
| 1467 | + $('.' + _this.settings.locationList + ' ul').append(listHtml); |
| 1468 | + } |
| 1469 | + }); |
| 1470 | + }, |
| 1471 | + |
1445 | 1472 | /**
|
1446 | 1473 | * The primary mapping function that runs everything
|
1447 | 1474 | *
|
|
1916 | 1943 | $('.' + _this.settings.locationList + ' ul li:even').css('background', _this.settings.listColor1);
|
1917 | 1944 | $('.' + _this.settings.locationList + ' ul li:odd').css('background', _this.settings.listColor2);
|
1918 | 1945 |
|
| 1946 | + // Visible markers list |
| 1947 | + if(_this.settings.visibleMarkersList === true) { |
| 1948 | + // Add event listener to filter the list when the map is fully loaded |
| 1949 | + google.maps.event.addListenerOnce(map, 'idle', function(){ |
| 1950 | + _this.checkVisibleMarkers(markers, map); |
| 1951 | + }); |
| 1952 | + |
| 1953 | + // Add event listener for center change |
| 1954 | + google.maps.event.addListener(map, 'center_changed', function() { |
| 1955 | + _this.checkVisibleMarkers(markers, map); |
| 1956 | + }); |
| 1957 | + |
| 1958 | + // Add event listener for zoom change |
| 1959 | + google.maps.event.addListener(map, 'zoom_changed', function() { |
| 1960 | + _this.checkVisibleMarkers(markers, map); |
| 1961 | + }); |
| 1962 | + } |
| 1963 | + |
1919 | 1964 | // Modal ready callback
|
1920 | 1965 | if (_this.settings.modal === true && _this.settings.callbackModalReady) {
|
1921 | 1966 | _this.settings.callbackModalReady.call(this);
|
|
0 commit comments