Changed datasets.json to allow for multiple basemaps

This commit is contained in:
Caleb Robinson 2020-07-28 20:12:44 +00:00
Родитель b4053a41ea
Коммит 80c93d92d4
3 изменённых файлов: 42 добавлений и 33 удалений

Просмотреть файл

@ -2,7 +2,6 @@
"hcmc_sentinel": { "hcmc_sentinel": {
"metadata": { "metadata": {
"displayName": "Ho Chi Minh City, Vietnam", "displayName": "Ho Chi Minh City, Vietnam",
"imageryName": "Sentinel Imagery",
"locationName": null "locationName": null
}, },
"dataLayer": { "dataLayer": {
@ -11,7 +10,9 @@
"padding": 500, "padding": 500,
"resolution": 10 "resolution": 10
}, },
"basemapLayer": { "basemapLayers": [
{
"layerName": "Sentinel Imagery",
"initialZoom": 11, "initialZoom": 11,
"url": "data/basemaps/hcmc_sentinel_tiles/{z}/{x}/{y}.png", "url": "data/basemaps/hcmc_sentinel_tiles/{z}/{x}/{y}.png",
"initialLocation": [ 10.682, 106.752 ], "initialLocation": [ 10.682, 106.752 ],
@ -23,7 +24,8 @@
"minZoom": 10, "minZoom": 10,
"bounds": [[10.516963329949858, 106.88465642003204], [10.850214900118745, 106.55144323441078]] "bounds": [[10.516963329949858, 106.88465642003204], [10.850214900118745, 106.55144323441078]]
} }
}, }
],
"shapeLayers": [ "shapeLayers": [
{ {
"shapesFn": "data/zones/hcmc_sentinel_admin_1_clipped.geojson", "shapesFn": "data/zones/hcmc_sentinel_admin_1_clipped.geojson",
@ -46,7 +48,6 @@
"naip_maryland": { "naip_maryland": {
"metadata": { "metadata": {
"displayName": "Maryland 2017", "displayName": "Maryland 2017",
"imageryName": "NAIP Imagery",
"locationName": null "locationName": null
}, },
"dataLayer": { "dataLayer": {
@ -55,7 +56,9 @@
"padding": 20, "padding": 20,
"resolution": 1 "resolution": 1
}, },
"basemapLayer": { "basemapLayers": [
{
"layerName": "NAIP 2017 Imagery",
"initialZoom": 11, "initialZoom": 11,
"url": "data/basemaps/m_3807537_ne_18_1_20170611_tiles/{z}/{x}/{y}.png", "url": "data/basemaps/m_3807537_ne_18_1_20170611_tiles/{z}/{x}/{y}.png",
"initialLocation": [ 38.477018, -75.402312], "initialLocation": [ 38.477018, -75.402312],
@ -67,7 +70,8 @@
"minZoom": 10, "minZoom": 10,
"bounds": [[38.43467413843691, -75.37107263863105], [38.50279589938556, -75.44149473165253]] "bounds": [[38.43467413843691, -75.37107263863105], [38.50279589938556, -75.44149473165253]]
} }
}, }
],
"shapeLayers": [ "shapeLayers": [
{ {
"shapesFn": "data/zones/m_3807537_ne_18_1_20170611_boundary.geojson", "shapesFn": "data/zones/m_3807537_ne_18_1_20170611_boundary.geojson",

Просмотреть файл

@ -183,11 +183,17 @@
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// Create the basemap for the current dataset // Create the basemap for the current dataset
var baseLayer = L.tileLayer(DATASETS[gCurrentDataset]["basemapLayer"]["url"], DATASETS[gCurrentDataset]["basemapLayer"]["args"]); var baseLayer = L.tileLayer(DATASETS[gCurrentDataset]["basemapLayers"][0]["url"], DATASETS[gCurrentDataset]["basemapLayers"][0]["args"]);
// This is the list of basemaps that will be displayed on the control in bottom left of GUI // This is the list of basemaps that will be displayed on the control in bottom left of GUI
gCurrentBasemapLayerName = DATASETS[gCurrentDataset]["metadata"]["imageryName"]; gCurrentBasemapLayerName = DATASETS[gCurrentDataset]["basemapLayers"][0]["layerName"];
gBasemaps[DATASETS[gCurrentDataset]["metadata"]["imageryName"]] = baseLayer;
gBasemaps[gCurrentBasemapLayerName] = baseLayer;
for(var i=1; i<DATASETS[gCurrentDataset]["basemapLayers"].length; i++){
var layerName = DATASETS[gCurrentDataset]["basemapLayers"][i]["layerName"];
var layer = L.tileLayer(DATASETS[gCurrentDataset]["basemapLayers"][i]["url"], DATASETS[gCurrentDataset]["basemapLayers"][i]["args"])
gBasemaps[layerName] = layer;
}
gBasemaps["OpenStreetMap"] = getOSMLayer(); gBasemaps["OpenStreetMap"] = getOSMLayer();
gBasemaps["ESRI World Imagery"] = getESRILayer(); gBasemaps["ESRI World Imagery"] = getESRILayer();
@ -203,8 +209,8 @@
gMap = L.map('map', { gMap = L.map('map', {
zoomControl: false, zoomControl: false,
crs: L.CRS.EPSG3857, // this is the projection CRS (EPSG:3857), but it is different than the data CRS (EPSG:4326). See https://gis.stackexchange.com/questions/225765/leaflet-map-crs-is-3857-but-coordinates-4326/225786. crs: L.CRS.EPSG3857, // this is the projection CRS (EPSG:3857), but it is different than the data CRS (EPSG:4326). See https://gis.stackexchange.com/questions/225765/leaflet-map-crs-is-3857-but-coordinates-4326/225786.
center: DATASETS[gCurrentDataset]["basemapLayer"]["initialLocation"], center: DATASETS[gCurrentDataset]["basemapLayers"][0]["initialLocation"],
zoom: DATASETS[gCurrentDataset]["basemapLayer"]["initialZoom"], zoom: DATASETS[gCurrentDataset]["basemapLayers"][0]["initialZoom"],
keyboard: false, keyboard: false,
minZoom: baseLayer.options.minZoom, minZoom: baseLayer.options.minZoom,
layers: initialLayers layers: initialLayers

Просмотреть файл

@ -261,12 +261,11 @@
//----------------------- //-----------------------
for (var dsName in datasets) { for (var dsName in datasets) {
var dataset = datasets[dsName]; var dataset = datasets[dsName];
var tab = `<a class="list-group-item list-group-item-action" data-toggle="list" data-name="${dsName}" href="#dataset-${dsName}" role="tab">${dataset["metadata"]["displayName"]} - ${dataset["metadata"]["imageryName"]}</a>`; var tab = `<a class="list-group-item list-group-item-action" data-toggle="list" data-name="${dsName}" href="#dataset-${dsName}" role="tab">${dataset["metadata"]["displayName"]}</a>`;
var panel = ` var panel = `
<div class="tab-pane" id="dataset-${dsName}" role="tabpanel"> <div class="tab-pane" id="dataset-${dsName}" role="tabpanel">
<div class="tab-pane-content"> <div class="tab-pane-content">
<span class="tab-title">Location: </span><span class="tab-text">${dataset["metadata"]["displayName"]}</span><br> <span class="tab-title">Location: </span><span class="tab-text">${dataset["metadata"]["displayName"]}</span><br>
<span class="tab-title">Imagery Source: </span><span class="tab-text">${dataset["metadata"]["imageryName"]}</span><br>
<!--<img src="${dataset["previewFn"]}" class="thumbnail" />--> <!--<img src="${dataset["previewFn"]}" class="thumbnail" />-->
</div> </div>
</div> </div>