diff options
| author | Ohad Ron <ohdron@gmail.com> | 2015-11-06 12:37:53 +0200 |
|---|---|---|
| committer | Ohad Ron <ohdron@gmail.com> | 2015-11-06 12:37:53 +0200 |
| commit | 8a99e664b9f095a1b53dcaa380daaa35b1093c18 (patch) | |
| tree | 5ff319c175835fa1d0d0fec0185cfd318d1b2406 | |
| parent | 98ec7b35afb5a59e7db6af842c63b71216dc73d3 (diff) | |
Changing images live
| -rw-r--r-- | img/280_0.png | bin | 0 -> 119540 bytes | |||
| -rw-r--r-- | img/280_1.png (renamed from img/280.png) | bin | 91892 -> 91892 bytes | |||
| -rw-r--r-- | img/280_2.png | bin | 0 -> 114716 bytes | |||
| -rw-r--r-- | img/280_3.png | bin | 0 -> 114757 bytes | |||
| -rw-r--r-- | img/280_4.png | bin | 0 -> 115120 bytes | |||
| -rw-r--r-- | index.html | 46 |
6 files changed, 33 insertions, 13 deletions
diff --git a/img/280_0.png b/img/280_0.png Binary files differnew file mode 100644 index 0000000..979cef4 --- /dev/null +++ b/img/280_0.png diff --git a/img/280.png b/img/280_1.png Binary files differindex 48af202..48af202 100644 --- a/img/280.png +++ b/img/280_1.png diff --git a/img/280_2.png b/img/280_2.png Binary files differnew file mode 100644 index 0000000..f98fa52 --- /dev/null +++ b/img/280_2.png diff --git a/img/280_3.png b/img/280_3.png Binary files differnew file mode 100644 index 0000000..98bfe2a --- /dev/null +++ b/img/280_3.png diff --git a/img/280_4.png b/img/280_4.png Binary files differnew file mode 100644 index 0000000..327d39c --- /dev/null +++ b/img/280_4.png @@ -5,7 +5,7 @@ <title></title> <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> <script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.11.2/mapbox-gl.js'></script> - <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.11.2/mapbox-gl.css' rel='stylesheet' /> + <link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.11.2/mapbox-gl.css' rel='stylesheet' /> <style> body { margin:0; padding:0; } #map { position:absolute; top:0; bottom:0; width:100%; } @@ -39,11 +39,6 @@ var mapStyle = { "mapbox": { "type": "vector", "url": "mapbox://mapbox.mapbox-streets-v6" - }, - "overlay": { - "type": "image", - "url": "/img/280.png", - "coordinates": RASTER_COORDS_280 } }, "sprite": "mapbox://sprites/mapbox/dark-v8", @@ -70,12 +65,6 @@ var mapStyle = { "paint": {"line-color": "#797979"} }, { - "id": "overlay", - "source": "overlay", - "type": "raster", - "paint": {"raster-opacity": 0.85} - }, - { "id": "cities", "source": "mapbox", "source-layer": "place_label", @@ -124,8 +113,39 @@ var map = new mapboxgl.Map({ hash: false }); +function changeToImage(num){ + map.addSource('overlay'+num,{ + "type": "image", + "url": "/img/280_"+num+".png", + "coordinates": RASTER_COORDS_280 + } + ); + if (map.getLayer("overlay")) { + map.removeSource(map.getLayer("overlay").source); + map.removeLayer('overlay'); + } + map.addLayer({ + "id": "overlay", + "source": "overlay"+num, + "type": "raster", + "paint": {"raster-opacity": 0.85} + },"cities"); + map.update(true); +} + +map.on('load', function(){ + var count = 0; + var nextImage = function(){ + changeToImage(count); + count = count+1; + if(count>4) count = 0; + } + + window.setInterval(nextImage, 1000); +}); + + </script> </body> </html> - |
