From 9743869e75e94f43bdaaee5ab41b6840cf3a5bb0 Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Sun, 8 Nov 2015 14:44:32 +0200 Subject: Layer zoom toggle works --- templates/index.html | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/templates/index.html b/templates/index.html index 614c8f1..d4d1c35 100644 --- a/templates/index.html +++ b/templates/index.html @@ -33,7 +33,7 @@ var mapStyle = { }, "radar_140": { "type": "image", - "url": "/static/140.png", + "url": "/static/{{ latest_140 }}_140.png", "coordinates": [ [33.35317413, 33.27232471], [36.32243686, 33.27232471], @@ -88,6 +88,9 @@ var mapStyle = { "type": "raster", "paint": { "raster-opacity": 0.85 + }, + "layout": { + "visibility": "none" } }, { @@ -146,6 +149,19 @@ var map = new mapboxgl.Map({ style: mapStyle, hash: false }); + +map.on('zoom', function (x) { + var zoom = map.getZoom(); + if (zoom > 7) { + map.getLayer('radar_140').layout.visibility='visible'; + map.getLayer('radar_280').layout.visibility='none'; + } + else { + map.getLayer('radar_140').layout.visibility='none'; + map.getLayer('radar_280').layout.visibility='visible'; + } +}) + -- cgit v1.3.1