diff --git a/index.html b/index.html index 8125332..ade6f5f 100644 --- a/index.html +++ b/index.html @@ -25,50 +25,72 @@
@@ -80,43 +102,10 @@ zoom: 8, center: [-74.5447, 40.6892] }); - // var sources =[ - // // { - // // [{ - // // - // // 'type': 'raster', - // // 'tiles': [ - // // 'https://gis.nemac.org/nfwf?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=NA_AssetIndex', - // // - // // ], - // // 'tileSize': 256 - // // },{ - // // - // // 'type': 'raster', - // // 'tiles': [ - // // 'https://gis.nemac.org/nfwf?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=NA_ThreatIndex_Ramp', - // // - // // ], - // // 'tileSize': 256 - // // },{ - // // - // // 'type': 'raster', - // // 'tiles': [ - // // 'https://gis.nemac.org/nfwf?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=NA_ExposureIndex' - // // - // // ], - // // 'tileSize': 256 - // // } - // - // - // // } - // 'https://gis.nemac.org/nfwf?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=NA_AssetIndex', - // 'https://gis.nemac.org/nfwf?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=NA_ThreatIndex_Ramp', - // 'https://gis.nemac.org/nfwf?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=NA_ExposureIndex' - // ]; + var layers = document.getElementById('menu'); - //on the opening of page all layers load. + //on the opening of page no layers load. map.on('load', function() { //add nfwf with correct srs update with bbox @@ -128,119 +117,73 @@ ], 'tileSize': 256 }); - map.addLayer({ - 'id': 'NA Exposure Index', - 'type': 'raster', - 'source': 'NA Exposure Index', - 'layout': { - 'visibility': 'none' - }, - 'paint': {} - }, 'aeroway-taxiway'); - // - map.addSource('NA Threat Index', { - 'type': 'raster', - 'tiles': [ - 'https://gis.nemac.org/nfwf?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=NA_ThreatIndex_Ramp' - ], - - 'tileSize': 256 - }); - map.addLayer({ - 'id': 'NA Threat Index', - 'type': 'raster', - 'source': 'NA Threat Index', - 'layout': { - 'visibility': 'none' - }, - 'paint': {} - }, 'aeroway-taxiway'); //new layer - // - map.addSource('NA Asset Index', { - 'type': 'raster', - 'tiles': [ - 'https://gis.nemac.org/nfwf?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=NA_AssetIndex' - ], - - 'tileSize': 256 - }); - // - map.addLayer({ - 'id': 'NA Asset Index', - 'type': 'raster', - 'source': 'NA Asset Index', - 'layout': { - 'visibility': 'none' - }, - 'paint': {} - }, 'aeroway-taxiway'); - }); //end of load map - // - // sources.forEach(function(sources){ - var layerIds = ['NA Asset Index','NA Threat Index','NA Exposure Index']; - // var layers = document.getElementById('menu'); - for (var i = 0; i < layerIds.length; i++) { - var id = layerIds[i]; - // map.addSource(id, { - // 'type': 'raster', - // // 'data': sources[i] - // // 'source': - // 'tiles': [ - // sources[i] - // ], - // 'tileSize': 256 - // } - // ); - // if (!map.getLayer(id)) { - // map.addLayer({ - // 'id': id, - // 'type': 'raster', - // 'source': id, - // 'layout': { - // 'visibility': 'none' - // }, - // 'paint': {} - // }, 'aeroway-taxiway'); - // }; - var box = document.createElement('input'); - box.type = 'checkbox'; - box.id = id; - box.checked = false; - // box.href = '#'; - var tag = document.createElement('label'); - tag.setAttribute('for', id); - // url.className = 'active'; - tag.textContent = id; - layers.appendChild(box); - layers.appendChild(tag); - box.addEventListener('change', function(clicked) { - map.setLayoutProperty(id, 'visibility', + map.addLayer({ + 'id': 'NA Exposure Index', + 'type': 'raster', + 'source': 'NA Exposure Index', + 'layout': { + 'visibility': 'none' + }, + 'paint': {} + }, 'aeroway-taxiway'); + + map.addSource('NA Threat Index', { + 'type': 'raster', + 'tiles': [ + 'https://gis.nemac.org/nfwf?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=NA_ThreatIndex_Ramp' + ], + + 'tileSize': 256 + }); + map.addLayer({ + 'id': 'NA Threat Index', + 'type': 'raster', + 'source': 'NA Threat Index', + 'layout': { + 'visibility': 'none' + }, + 'paint': {} + }, 'aeroway-taxiway'); //new layer + + map.addSource('NA Asset Index', { + 'type': 'raster', + 'tiles': [ + 'https://gis.nemac.org/nfwf?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&layers=NA_AssetIndex' + ], + + 'tileSize': 256 + }); + map.addLayer({ + 'id': 'NA Asset Index', + 'type': 'raster', + 'source': 'NA Asset Index', + 'layout': { + 'visibility': 'none' + }, + 'paint': {} + }, 'aeroway-taxiway'); + }); //end of load map + + var layerIds = ['NA Asset Index', 'NA Threat Index', 'NA Exposure Index']; + for (var i = 0; i < layerIds.length; i++) { + var id = layerIds[i]; + var box = document.createElement('input'); + box.type = 'checkbox'; + box.id = id; + box.checked = false; + var tag = document.createElement('label'); + tag.className = 'label'; + var span = document.createElement('span'); + span.setAttribute("class", "check"); + tag.textContent = id; + tag.appendChild(box); + tag.appendChild(span); + layers.appendChild(tag); + box.addEventListener('change', function(clicked) { + map.setLayoutProperty(this.id, 'visibility', clicked.target.checked ? 'visible' : 'none'); - }); - }; - - - - - // }; - // box.onclick = function(clicked) { - // clicked.preventDefault(); - // clicked.stopPropagation(); - // var currentLayer = this.textContent; - // var visibility = map.getLayoutProperty(currentLayer, 'visibility'); - // if (visibility === 'visible') { - // map.setLayoutProperty(currentLayer, 'visibility', 'visible'); - // this.className = ''; - // this.checkbox = false; - // } else { - // this.className = 'active'; - // map.setLayoutProperty(currentLayer, 'visibility', 'visible'); - // this.checkbox = true; - // } - // }); - // }; - // }); - //end of map load + }); + };