Class StyleMaptiler
Hierarchy (View Summary)
- Style
- Style
Index
Constructors
Properties
Methods
Constructors
Maptilerconstructor
Parameters
- map: Map
- options: StyleOptions = {}
Returns Style
Properties
crossTileSymbolIndex
dispatcher
glyphManager
imageManager
light
lineAtlas
map
pauseablePlacement
placement
projection
sky
stylesheet
tileManagers
z
zoomHistory
Methods
addImage
Parameters
- id: string
- image: StyleImage
Returns this
addLayer
Add a layer to the map style. The layer will be inserted before the layer with ID
before, or appended ifbeforeis omitted.Parameters
- layerObject: AddLayerObject
The style layer to add.
Optionalbefore: stringID of an existing layer to insert before
Optionaloptions: StyleSetterOptionsStyle setter options.
Returns this
- layerObject: AddLayerObject
addSource
- addSource(
id: string,
source: CanvasSourceSpecification | SourceSpecification,
options?: StyleSetterOptions,
): voidParameters
- id: string
- source: CanvasSourceSpecification | SourceSpecification
Optionaloptions: StyleSetterOptions
Returns void
addSprite
- addSprite(
id: string,
url: string,
options?: StyleSetterOptions,
completion?: (err: Error) => void,
): voidAdd a sprite.
Parameters
- id: string
The id of the desired sprite
- url: string
The url to load the desired sprite from
Optionaloptions: StyleSetterOptionsThe style setter options
Optionalcompletion: (err: Error) => voidThe completion handler
Returns void
- id: string
destroy
Destroys all internal resources of the style (sources, images, layers, etc.)
Returns void
fire
Parameters
- event: string | Event
Optionalproperties: any
Returns this
getDashes
Parameters
- mapId: string | number
- params: GetDashesParameters
Returns Promise<GetDashesResponse>
getFeatureState
Parameters
- target: FeatureIdentifier
Returns FeatureState
getFilter
Get a layer's filter object
Parameters
- layer: string
the layer to inspect
Returns void | FilterSpecification
the layer's filter, if any
- layer: string
getGlobalState
Returns Record<string, any>
getGlyphs
Parameters
- mapId: string | number
- params: GetGlyphsParameters
Returns Promise<GetGlyphsResponse>
getGlyphsUrl
Returns string | null
getImage
Parameters
- id: string
Returns StyleImage
getImages
Parameters
- mapId: string | number
- params: GetImagesParameters
Returns Promise<GetImagesResponse>
getLayer
Return the style layer object with the given
id.Parameters
- id: string
id of the desired layer
Returns StyleLayer | undefined
a layer, if one with the given
idexists- id: string
getLayersOrder
Return the ids of all layers currently in the style, including custom layers, in order.
Returns string[]
ids of layers, in order
getLayoutProperty
Get a layout property's value from a given layer
Parameters
- layerId: string
the layer to inspect
- name: string
the name of the layout property
Returns any
the property value
- layerId: string
getLight
Returns LightSpecification
getPaintProperty
Parameters
- layer: string
- name: string
Returns unknown
getProjection
Returns ProjectionSpecification
getSky
Returns SkySpecification
getSource
getSprite
Get the current sprite value.
Returns { id: string; url: string }[]
empty array when no sprite is set; id-url pairs otherwise
getTransition
Returns { delay: number; duration: number } & TransitionSpecification
hasLayer
Checks if a specific layer is present within the style.
Parameters
- id: string
the id of the desired layer
Returns boolean
a boolean specifying if the given layer is present
- id: string
hasTransitions
Returns boolean
listens
Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.
Parameters
- type: string
The event type
Returns boolean
trueif there is at least one registered listener for specified event type,falseotherwise- type: string
listImages
Returns string[]
loaded
Returns boolean
loadEmpty
Returns void
loadJSON
- loadJSON(
json: StyleSpecification,
options?: StyleSetterOptions & StyleSwapOptions,
previousStyle?: StyleSpecification,
): voidParameters
- json: StyleSpecification
Optionaloptions: StyleSetterOptions & StyleSwapOptionsOptionalpreviousStyle: StyleSpecification
Returns void
loadURL
- loadURL(
url: string,
options?: StyleSwapOptions & StyleSetterOptions,
previousStyle?: StyleSpecification,
): Promise<void>Parameters
- url: string
Optionaloptions: StyleSwapOptions & StyleSetterOptionsOptionalpreviousStyle: StyleSpecification
Returns Promise<void>
moveLayer
Moves a layer to a different z-position. The layer will be inserted before the layer with ID
before, or appended ifbeforeis omitted.Parameters
- id: string
ID of the layer to move
Optionalbefore: stringID of an existing layer to insert before
Returns void
- id: string
off
Removes a previously registered event listener.
Parameters
- type: string
The event type to remove listeners for.
- listener: Listener
The listener function to remove.
Returns this
- type: string
on
Adds a listener to a specified event type.
Parameters
- type: string
The event type to add a listen for.
- listener: Listener
The function to be called when the event is fired. The listener function is called with the data object passed to
fire, extended withtargetandtypeproperties.
Returns Subscription
- type: string
once
Adds a listener that will be called only once to a specified event type.
The listener will be called first time the event fires after the listener is registered.
Parameters
- type: string
The event type to listen for.
Optionallistener: ListenerThe function to be called when the event is fired the first time.
Returns Promise<any> | Style
thisor a promise if a listener is not provided- type: string
queryRenderedFeatures
- queryRenderedFeatures(
queryGeometry: Point[],
params: QueryRenderedFeaturesOptions,
transform: IReadonlyTransform,
): MapGeoJSONFeature[]Parameters
- queryGeometry: Point[]
- params: QueryRenderedFeaturesOptions
- transform: IReadonlyTransform
Returns MapGeoJSONFeature[]
querySourceFeatures
Parameters
- sourceID: string
Optionalparams: QuerySourceFeatureOptions
Returns GeoJSONFeature[]
removeFeatureState
Parameters
- target: FeatureIdentifier
Optionalkey: string
Returns void
removeImage
Parameters
- id: string
Returns this
removeLayer
Remove the layer with the given id from the style. A ErrorEvent event will be fired if no such layer exists.
Parameters
- id: string
id of the layer to remove
Returns void
- id: string
removeSource
removeSprite
Remove a sprite by its id. When the last sprite is removed, the whole
this.stylesheet.spriteobject becomesundefined. This falsyundefinedvalue later prevents attempts to load the sprite when it's absent.Parameters
- id: string
the id of the sprite to remove
Returns void
- id: string
serialize
Returns StyleSpecification | undefined
setEventedParent
Bubble all events fired by this instance of Evented to this parent instance of Evented.
Parameters
Optionalparent: Evented | nullOptionaldata: any
Returns this
setFeatureState
Parameters
- target: FeatureIdentifier
- state: any
Returns void
setFilter
- setFilter(
layerId: string,
filter?: FilterSpecification | null,
options?: StyleSetterOptions,
): voidParameters
- layerId: string
Optionalfilter: FilterSpecification | nullOptionaloptions: StyleSetterOptions
Returns void
setGeoJSONSourceData
Set the data of a GeoJSON source, given its id.
Parameters
- id: string
id of the source
- data: string | GeoJSON<Geometry, GeoJsonProperties>
GeoJSON source
Returns void
- id: string
setGlobalState
Parameters
- newStylesheetState: StateSpecification
Returns void
setGlobalStateProperty
Parameters
- name: string
- value: any
Returns this
setGlyphs
Parameters
- glyphsUrl: string | null | undefined
Optionaloptions: StyleSetterOptions
Returns void
setLayerZoomRange
Parameters
- layerId: string
Optionalminzoom: number | nullOptionalmaxzoom: number | null
Returns void
setLayoutProperty
Parameters
- layerId: string
- name: string
- value: any
Optionaloptions: StyleSetterOptions
Returns void
setLight
Parameters
- lightOptions: LightSpecification
Optionaloptions: StyleSetterOptions
Returns void
setPaintProperty
Parameters
- layerId: string
- name: string
- value: any
Optionaloptions: StyleSetterOptions
Returns void
setProjection
Parameters
Optionalprojection: ProjectionSpecification
Returns void
setSky
Parameters
OptionalskyOptions: SkySpecificationOptionaloptions: StyleSetterOptions
Returns void
setSprite
- setSprite(
sprite: SpriteSpecification,
options?: StyleSetterOptions,
completion?: (err: Error) => void,
): voidSet a new value for the style's sprite.
Parameters
- sprite: SpriteSpecification
new sprite value
Optionaloptions: StyleSetterOptionsstyle setter options
Optionalcompletion: (err: Error) => voidthe completion handler
Returns void
- sprite: SpriteSpecification
setState
Update this style's state to match the given style JSON, performing only the necessary mutations.
May throw an Error ('Unimplemented: METHOD') if the mapbox-gl-style-spec diff algorithm produces an operation that is not supported.
Parameters
- nextState: StyleSpecification
Optionaloptions: StyleSwapOptions & StyleSetterOptions
Returns boolean
true if any changes were made; false otherwise
update
Parameters
- parameters: EvaluationParameters
Returns void
updateImage
Parameters
- id: string
- image: StyleImage
Returns void
The Style base class