Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Asc Geostac
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aflab
astrogeology
Asc Geostac
Commits
058d0a40
Commit
058d0a40
authored
1 year ago
by
zksx
Browse files
Options
Downloads
Patches
Plain Diff
got sld styling to work
parent
776ac91e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/presentational/FootprintResults.jsx
+25
-1
25 additions, 1 deletion
src/components/presentational/FootprintResults.jsx
src/js/AstroMap.js
+3
-10
3 additions, 10 deletions
src/js/AstroMap.js
with
28 additions
and
11 deletions
src/components/presentational/FootprintResults.jsx
+
25
−
1
View file @
058d0a40
...
@@ -169,15 +169,39 @@ export default function FootprintResults(props) {
...
@@ -169,15 +169,39 @@ export default function FootprintResults(props) {
}
}
}
}
async
function
fetchSLD
(
sld_url
)
{
try
{
const
response
=
await
fetch
(
sld_url
)
if
(
!
response
.
ok
)
{
throw
new
Error
(
'
SLD response not ok
'
+
response
.
statusText
);
}
const
SLD_DATA
=
await
response
.
text
();
//const parser = new DOMParser();
//const sld_file = parser.parseFromString(SLD_DATA, text/xml);
return
SLD_DATA
}
catch
(
error
)
{
console
.
error
(
'
SLD unable to be fetched
'
,
error
);
}
}
(
async
()
=>
{
(
async
()
=>
{
let
collections
=
await
FetchObjects
(
collectionUrls
);
let
collections
=
await
FetchObjects
(
collectionUrls
);
// Add extra properties to each collection
// Add extra properties to each collection
for
(
const
key
in
collections
){
for
(
const
key
in
collections
){
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
];
let
sldtext
=
null
;
if
(
styleSheetUrls
[
key
])
{
sldtext
=
await
fetchSLD
(
styleSheetUrls
[
key
]);
collections
[
key
].
styleSheets
=
sldtext
;
}
}
}
// Updates collectionId if switching to a new set of collections (new target)
// Updates collectionId if switching to a new set of collections (new target)
...
...
This diff is collapsed.
Click to expand it.
src/js/AstroMap.js
+
3
−
10
View file @
058d0a40
...
@@ -302,7 +302,7 @@ export default L.Map.AstroMap = L.Map.extend({
...
@@ -302,7 +302,7 @@ export default L.Map.AstroMap = L.Map.extend({
let
title
=
featureCollections
[
i
].
title
;
let
title
=
featureCollections
[
i
].
title
;
let
sld_
file
=
featureCollections
[
i
].
styleSheets
;
let
sld_
text
=
featureCollections
[
i
].
styleSheets
;
// set style if available
// set style if available
let
myStyle
=
null
;
let
myStyle
=
null
;
...
@@ -312,15 +312,8 @@ export default L.Map.AstroMap = L.Map.extend({
...
@@ -312,15 +312,8 @@ export default L.Map.AstroMap = L.Map.extend({
// [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
)
{
if
(
sld_text
!=
null
)
{
this
.
SLDStyler
=
new
L
.
SLDStyler
(
sld_text
);
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
();
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment