-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a hillshade layer #1157
Open
jleedev
wants to merge
13
commits into
main
Choose a base branch
from
jleedev-relieved
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add a hillshade layer #1157
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6fb25d0
Add a hillshade layer
jleedev e12f62c
Move hillshade under water
jleedev 56760ba
Changed the hillshade colors
jleedev ad3e8cb
Fade out more slowly
jleedev 6ff4bcd
Add a toggle button
jleedev 6eeca39
Upgrade maplibre-gl from 2.4.0 to 4.7.0
jleedev 0f98db3
Increase hillshade source from 12 to 13.
jleedev 4025dcb
Merge branch 'main' into jleedev-relieved
claysmalley 607eeff
Darken shadow
jleedev 1394349
Extract colors; disable by default
jleedev 021c041
correct import
jleedev 4977f95
Fade out even less
jleedev ca32102
Bump version
jleedev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
export class HillshadeControl { | ||
constructor({ layerId }) { | ||
this._layerId = layerId; | ||
} | ||
|
||
_onClick = () => { | ||
if (this._map.getLayoutProperty(this._layerId, "visibility") == "none") { | ||
this._map.setLayoutProperty(this._layerId, "visibility", "visible"); | ||
this._button.classList.add("maplibregl-ctrl-terrain-enabled"); | ||
this._button.title = "Disable terrain"; | ||
} else { | ||
this._map.setLayoutProperty(this._layerId, "visibility", "none"); | ||
this._button.classList.remove("maplibregl-ctrl-terrain-enabled"); | ||
this._button.title = "Enable terrain"; | ||
} | ||
}; | ||
|
||
onAdd(map) { | ||
this._map = map; | ||
|
||
this._container = document.createElement("div"); | ||
this._container.className = "maplibregl-ctrl maplibregl-ctrl-group"; | ||
|
||
this._button = document.createElement("button"); | ||
this._button.className = "maplibregl-ctrl-terrain"; | ||
this._button.classList.add("maplibregl-ctrl-terrain-enabled"); | ||
this._button.title = "Disable terrain"; | ||
this._button.addEventListener("click", this._onClick); | ||
this._container.append(this._button); | ||
|
||
const span = document.createElement("span"); | ||
span.className = "maplibregl-ctrl-icon"; | ||
span.setAttribute("aria-hidden", "true"); | ||
this._button.append(span); | ||
|
||
return this._container; | ||
} | ||
|
||
onRemove() { | ||
this._container.remove(); | ||
this._map = undefined; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export const hillshading = { | ||
id: "hillshading", | ||
type: "hillshade", | ||
source: "dem", | ||
maxzoom: 17, | ||
paint: { | ||
"hillshade-exaggeration": [ | ||
"interpolate", | ||
["linear"], | ||
["zoom"], | ||
6, | ||
1, | ||
12, | ||
0.7, | ||
16, | ||
0.1, | ||
17, | ||
0, | ||
], | ||
"hillshade-shadow-color": "hsla(30, 14%, 76%, 1)", | ||
"hillshade-highlight-color": "hsla(30, 44%, 99%, 1)", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Astonishingly, my iPhone 8 is able to keep up with the map with the hillshading enabled, but it turns the battery meter into a sad trombone. Should we hide the layer by default on mobile devices, or somehow detect less powerful devices?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I upgraded maplibre-gl, the changelog mentions some performance improvements, want to try again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first render is reasonably quick, but there’s a lot more stuttering while panning than on main. The battery goes down by a few percent after about 20 seconds of panning around the Appalachians at zoom level 8. That’s still much better than the majority of ad-laden news websites these days, but the stuttering is a bummer.