Skip to content

Commit

Permalink
[docs] Address user feedback for /api: setStyle, getStyle, isStyleLoa…
Browse files Browse the repository at this point in the history
…ded (#8807)
  • Loading branch information
Colleen McGinnis authored and Arindam Bose committed Oct 28, 2019
1 parent af1b009 commit cefe3bc
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -1036,9 +1036,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.
Expand All @@ -1051,6 +1056,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) {
Expand Down Expand Up @@ -1122,6 +1131,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();
*
*/
getStyle() {
if (this.style) {
Expand All @@ -1133,6 +1146,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
* var styleLoadStatus = map.isStyleLoaded();
*/
isStyleLoaded() {
if (!this.style) return warnOnce('There is no style added to the map.');
Expand Down

0 comments on commit cefe3bc

Please sign in to comment.