summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <yuval@y3xz.com>2015-11-08 14:44:32 +0200
committerYuval Adam <yuval@y3xz.com>2015-11-08 14:44:32 +0200
commit9743869e75e94f43bdaaee5ab41b6840cf3a5bb0 (patch)
tree4e8ae5e0d29e94c473ee6aebe199331b4c6bd85a
parent8ec1cf0656747e6fa5bd46c5fba582a264247d9c (diff)
Layer zoom toggle works
-rw-r--r--templates/index.html18
1 files changed, 17 insertions, 1 deletions
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';
+ }
+})
+
</script>
</body>