Skip to content
Snippets Groups Projects
Commit 776ac91e authored by zksx's avatar zksx
Browse files

added some stuff for styling

parent 16df93f7
No related branches found
No related tags found
No related merge requests found
...@@ -119,6 +119,8 @@ export default function FootprintResults(props) { ...@@ -119,6 +119,8 @@ export default function FootprintResults(props) {
} }
let collectionUrls = {}; let collectionUrls = {};
let styleSheetUrls = [];
for (const collection of props.target.collections) { for (const collection of props.target.collections) {
...@@ -133,15 +135,37 @@ export default function FootprintResults(props) { ...@@ -133,15 +135,37 @@ export default function FootprintResults(props) {
// change filter for the pygeo api // change filter for the pygeo api
myFilter = "&limit=" + step; myFilter = "&limit=" + step;
} }
let styleSheet;
const foundStyleSheet = collection.links.find(link=> link.rel == "stylesheet");
if(foundStyleSheet) {
styleSheet = foundStyleSheet.href;
styleSheetUrls[collection.id] = styleSheet;
console.log("Found Style Sheet");
}
if(isInStacAPI || isInPyAPI) { if(isInStacAPI || isInPyAPI) {
let itemsUrl = collection.links.find(link => link.rel === "items").href; let itemsUrl = collection.links.find(link => link.rel === "items").href;
collectionUrls[collection.id] = itemsUrl + myFilter + pageInfo; collectionUrls[collection.id] = itemsUrl + myFilter + pageInfo;
let style_url = null;
for (let index = 0; index < collection.links.length; index++) {
if (collection.links[index].rel === "stylesheet") {
style_url = collection.links[index].href
}
}
collectionUrls[collection.id + ": stylesheet"] = style_url;
// if (collection.links.find(link => link.rel === "stylesheet").href != undefined) {
// let styleUrl = collection.links.find(link => link.rel === "stylesheet").href;
// collectionUrls[collection.id].style = styleUrl;
// }
// }
} }
else { else {
let itemsUrl = collection.links.find(link => link.rel === "items").href; let itemsUrl = collection.links.find(link => link.rel === "items").href;
collectionUrls[collection.id] = itemsUrl + pageInfo; collectionUrls[collection.id] = itemsUrl + pageInfo;
} }
} }
...@@ -153,6 +177,7 @@ export default function FootprintResults(props) { ...@@ -153,6 +177,7 @@ export default function FootprintResults(props) {
collections[key].id = key; collections[key].id = key;
collections[key].title = props.target.collections.find(collection => collection.id === key).title; collections[key].title = props.target.collections.find(collection => collection.id === key).title;
collections[key].url = collectionUrls[key]; collections[key].url = collectionUrls[key];
collections[key].styleSheets = styleSheetUrls[key];
} }
// Updates collectionId if switching to a new set of collections (new target) // Updates collectionId if switching to a new set of collections (new target)
......
...@@ -2,7 +2,8 @@ import L from "leaflet"; ...@@ -2,7 +2,8 @@ import L from "leaflet";
import "proj4leaflet"; import "proj4leaflet";
import AstroProj from "./AstroProj"; import AstroProj from "./AstroProj";
import LayerCollection from "./LayerCollection"; import LayerCollection from "./LayerCollection";
import SLDText from "../slds/Global_Geology.sld"; import FecthData from "./FetchData";
import { data } from "autoprefixer";
/** /**
...@@ -58,8 +59,7 @@ export default L.Map.AstroMap = L.Map.extend({ ...@@ -58,8 +59,7 @@ export default L.Map.AstroMap = L.Map.extend({
// Set by layer collection or baselayerchange event // Set by layer collection or baselayerchange event
this._currentLayer = null; this._currentLayer = null;
this.SLDStyler = new L.SLDStyler(SLDText); this.SLDStyler = new L.SLDStyler();
// Store layers at map creation so we only need to create layers once. // Store layers at map creation so we only need to create layers once.
let cylLayerInfo = this.parseJSON("cylindrical"); let cylLayerInfo = this.parseJSON("cylindrical");
...@@ -302,26 +302,27 @@ export default L.Map.AstroMap = L.Map.extend({ ...@@ -302,26 +302,27 @@ export default L.Map.AstroMap = L.Map.extend({
let title = featureCollections[i].title; let title = featureCollections[i].title;
let sld_file = featureCollections[i].styleSheets;
// set style if available
let myStyle = null;
// Add each _geoLayer that has footprints to the FootprintCollection object. // Add each _geoLayer that has footprints to the FootprintCollection object.
// The collection title is used as the property name // The collection title is used as the property name
// [old] and it shows up as the layer title when added to the separate Leaflet control // [old] and it shows up as the layer title when added to the separate Leaflet control
if(featureCollections[i].features.length > 0) { if(featureCollections[i].features.length > 0) {
let found_stylesheet = false;
let sld_file = null;
// set style if available
for (let j = 0; j < featureCollections[i].links.length; j++) {
if (featureCollections[i].links[j].rel == "stylesheet") {
found_stylesheet = true;
sld_file = fetch(featureCollections[i].links[j].href);
this.SLDStyler = new L.SLDStyler(sld_file);
}
}
let myStyle = null;
if (found_stylesheet) { if (sld_file) {
let sldtext = fetch(sld_file);
let res = sldtext.res
console.log("good style wow");
this.SLDStyler = new L.SLDStyler(sldtext);
myStyle = this.SLDStyler.getStyleFunction(); myStyle = this.SLDStyler.getStyleFunction();
} }
else{ else{
// Set colors if available // Set colors if available
......
...@@ -122,7 +122,7 @@ export default async function Initialize(){ ...@@ -122,7 +122,7 @@ export default async function Initialize(){
// view the collection as GEOJSON // view the collection as GEOJSON
let target_name = pycollection.id.split('/')[0]; let target_name = pycollection.id.split('/')[0];
if (target.name == target_name.toUpperCase()) { if (target.name == target_name.toUpperCase()) {
pycollection.links[9].href = "https://astrogeology.usgs.gov/pygeoapi" + pycollection.links[9].href; pycollection.links.find(link => link.rel === "items").href = "https://astrogeology.usgs.gov/pygeoapi" + pycollection.links.find(link => link.rel === "items").href;
// Add a specification to the title in order to show what kind of data the user is requesting // Add a specification to the title in order to show what kind of data the user is requesting
pycollection.title = pycollection.title.concat(" (Vector)"); pycollection.title = pycollection.title.concat(" (Vector)");
myCollections.push(pycollection); myCollections.push(pycollection);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment