-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[docs] Address user feedback for /api: setStyle, getStyle, isStyleLoaded #8807
Merged
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1032,9 +1032,14 @@ class Map extends Camera { | |
} | ||
|
||
/** | ||
* Updates the map's Mapbox style object with a new value. If a style already is set and options.diff is true, | ||
* this compares the style against the map's current state and performs only the changes necessary to make | ||
* the map style match the desired state. | ||
* Updates the map's Mapbox style object with a new value. | ||
* | ||
* If a style is already set when this is used and options.diff is set to true, the map renderer will attempt to compare the given style | ||
* against the map's current state and perform only the changes necessary to make the map style match the desired state. Changes in sprites | ||
* (images used for icons and patterns) and glyphs (fonts for label text) **cannot** be diffed. If the sprites or fonts used in the current | ||
* style and the given style are different in any way, the map renderer will force a full update, removing the current style and building | ||
* the given one from scratch. | ||
* | ||
* | ||
* @param style A JSON object conforming to the schema described in the | ||
* [Mapbox Style Specification](https://mapbox.com/mapbox-gl-style-spec/), or a URL to such JSON. | ||
|
@@ -1047,6 +1052,10 @@ class Map extends Camera { | |
* Set to `false`, to enable font settings from the map's style for these glyph ranges. | ||
* Forces a full update. | ||
* @returns {Map} `this` | ||
* | ||
* @example | ||
* map.setStyle("mapbox://styles/mapbox/streets-v11"); | ||
* | ||
* @see [Change a map's style](https://www.mapbox.com/mapbox-gl-js/example/setstyle/) | ||
*/ | ||
setStyle(style: StyleSpecification | string | null, options?: {diff?: boolean} & StyleOptions) { | ||
|
@@ -1118,6 +1127,10 @@ class Map extends Camera { | |
* Returns the map's Mapbox style object, which can be used to recreate the map's style. | ||
* | ||
* @returns {Object} The map's style object. | ||
* | ||
* @example | ||
* var styleJson = map.getStyle(); | ||
asheemmamoowala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
*/ | ||
getStyle() { | ||
if (this.style) { | ||
|
@@ -1129,6 +1142,9 @@ class Map extends Camera { | |
* Returns a Boolean indicating whether the map's style is fully loaded. | ||
* | ||
* @returns {boolean} A Boolean indicating whether the style is fully loaded. | ||
* | ||
* @example | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
* var styleLoadStatus = map.isStyleLoaded(); | ||
*/ | ||
isStyleLoaded() { | ||
if (!this.style) return warnOnce('There is no style added to the map.'); | ||
|
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.
It would be useful to add why it is valuable to enable to diff. If a style is not changing drastically, it enables a cross-faded change from the current style to the next and it is more performant - by reusing existing source and layer definitions and transitioning them to a future state - it saves on CPU cycles, and possibly network bandwidth.