diff --git a/Layout/default/Preorder/Index.php b/Layout/default/Preorder/Index.php
index e776eafb8..629b80f37 100644
--- a/Layout/default/Preorder/Index.php
+++ b/Layout/default/Preorder/Index.php
@@ -140,7 +140,7 @@
-
+
@@ -309,6 +309,8 @@
var markers = [];
var markerState = true;
var mapCenterPos = [=TT_PLACEHOLDER_GPS_LAT?>, =TT_PLACEHOLDER_GPS_LONG?>];
+ var tileLayers = [];
+ var tilesets = ["mapbox/streets-v12", "mapbox/satellite-streets-v12"];
var currentTileset = "mapbox/streets-v12";
function toggleTileset() {
@@ -343,16 +345,26 @@
preorderMap = L.map('preorder-map').setView([=TT_PLACEHOLDER_GPS_LAT?>, =TT_PLACEHOLDER_GPS_LONG?>], 12);
}
- L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
- attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox',
- minZoom: 4,
- maxZoom: 22,
- //id: 'mapbox/streets-v12',
- //id: 'mapbox/satellite-streets-v12',
- id: currentTileset,
- accessToken: '=TT_MAPBOX_TILE_API_TOKEN?>'
- }).addTo(preorderMap);
-
+ if(!(currentTileset in tileLayers)) {
+ tileLayers[currentTileset] = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
+ attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox',
+ minZoom: 6,
+ maxZoom: 22,
+ id: currentTileset,
+ accessToken: '=TT_MAPBOX_TILE_API_TOKEN?>'
+ });
+ }
+
+
+ tileLayers[currentTileset].addTo(preorderMap);
+ // remove previous tileset from map
+ tilesets.forEach(function(t) {
+ if(t != currentTileset && preorderMap.hasLayer(tileLayers[t])) {
+ // remove all tilesets not currently wanted
+ preorderMap.removeLayer(tileLayers[t]);
+ }
+ });
+
L.MakiMarkers.accessToken = '=TT_MAPBOX_TILE_API_TOKEN?>';
if(!tilesetChangeOnly) {