Skip to content
Snippets Groups Projects
Commit 401ba01a authored by Clark, Timothy G's avatar Clark, Timothy G
Browse files

Merge branch 'layer-updates' into 'main'

added nomenclature Layer to overlays, update stac layer title

See merge request asc/geostac!10
parents bc4769ab 16094d85
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@ var _limitVal = 10;
* @function callAPI
* @description Fetches the STAC API at the collections level
*/
function callAPI() {
export function callAPI() {
return fetch(
"https://stac.astrogeology.usgs.gov/api/collections"
).then(response => response.json());
......
......@@ -3,6 +3,7 @@ import "proj4leaflet";
import AstroProj from "./AstroProj";
import LayerCollection from "./LayerCollection";
import { getItemCollection,
callAPI,
setNumberMatched,
setMaxNumberPages,
getCurrentPage,
......@@ -144,6 +145,7 @@ export default L.Map.AstroMap = L.Map.extend({
var matched = 0;
var returned = 0;
const features = [];
getItemCollection(name, queryString).then(result => {
if (result != undefined) {
this._geoLayers = new Array(result.length);
......@@ -157,9 +159,27 @@ export default L.Map.AstroMap = L.Map.extend({
this._geoLayers[i].addData(result[i].features[j]);
}
}
var collectionNames ={};
callAPI().then(response =>{
for (let i = 0; i < response.collections.length; i++) {
if (response.collections[i].hasOwnProperty("summaries")){
if (
response.collections[i].summaries["ssys:targets"][0].toLowerCase() == name.toLowerCase()
) {
collectionNames[response.collections[i].id] = response.collections[i].title;
}
}
}
for (var key in this._footprintCollection){
let title = collectionNames[key];
this._footprintCollection[title]= this._footprintCollection[key];
delete this._footprintCollection[key];
}
this._footprintControl = L.control
.layers(null, this._footprintCollection, {collapsed: false})
.addTo(this);
.addTo(this)
});
}
setNumberMatched(matched);
setNumberReturned(returned);
......@@ -192,6 +212,7 @@ export default L.Map.AstroMap = L.Map.extend({
let layers = {
base: [],
overlays: [],
nomenclature: [],
wfs: []
};
......@@ -218,6 +239,10 @@ export default L.Map.AstroMap = L.Map.extend({
// Do not add "Show Feature Names" PNG layer.
if (currentLayer["displayname"] != "Show Feature Names") {
layers["overlays"].push(currentLayer);
} else {
if(currentLayer["layer"] == "NOMENCLATURE"){
layers["nomenclature"].push(currentLayer);
}
}
}
} else {
......
......@@ -29,6 +29,7 @@ export default L.LayerCollection = L.Class.extend({
throw "No base layers created. At least one base layer is needed.";
}
this.createOverlays(layerInfo["overlays"]);
this.createNomenclature(layerInfo["nomenclature"]);
},
/**
......@@ -108,6 +109,31 @@ export default L.LayerCollection = L.Class.extend({
// }
},
/**
* @function LayerCollection.prototype.createNomenclatures
* @description Creates nomenclature layers and adds them to the list of overlays.
* @param {List} layers - List of nomenclature information.
*/
createNomenclature: function(layers){
for (let i = 0; i < layers.length; i++){
let layer = layers[i];
let nomenclature = L.tileLayer.wms(
String(layer["url"]) + "?map=" + String(layer["map"]),
{
layers: String(layer["layer"]),
transparent: true,
format: "image/png",
noWrap: true,
minZoom: 4,
bounds: [[-90, 360], [90, 0]]
}
);
let name = String(layer["displayname"] + " (Zoom to enable)");
this._overlays[name] = nomenclature;
}
},
/**
* @function LayerCollection.prototype.addTo
* @description Removes the current layers, adds the base layers and overlays to the map, and sets the default layer.
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment