ImageSpriteManager interface
A manager for the map control's image sprite. Exposed through the imageSprite property of the atlas.Map class. Cannot be instantiated by the user.
Methods
add(string, string | HTMLImage |
Add an icon image to the map's image sprite for use with symbols and patterns. |
clear() | Removes all images added by the user. |
create |
Creates and adds an image to the maps image sprite. Provide the name of the built-in template to use, and a color to apply. Optionally, specifiy a secondary color if the template supports one. A scale can also be specified. This will allow the SVG to be scaled before it is converted into an image and thus look much better when scaled up. Returns a promise. Reference this in the Polygon or Symbol layer. |
get |
Gets a list of all the image ids that have been added to the maps image sprite. |
has |
Checks to see if an image is already loaded into the maps image sprite. |
remove(string) | Removes an image from the map's image sprite. |
Method Details
add(string, string | HTMLImageElement | ImageData, StyleImageMetadata)
Add an icon image to the map's image sprite for use with symbols and patterns.
function add(id: string, icon: string | HTMLImageElement | ImageData, meta?: StyleImageMetadata): Promise<void>
Parameters
- id
-
string
The image's id. If the specified id matches the id of a previously added image the new image will be ignored.
- icon
-
string | HTMLImageElement | ImageData
The image to add to the map's sprite. Can be a data URI, inline SVG, or image URL.
- meta
- StyleImageMetadata
Additional options that describe the image
Returns
Promise<void>
clear()
Removes all images added by the user.
function clear()
createFromTemplate(string, string, string, string, number)
Creates and adds an image to the maps image sprite. Provide the name of the built-in template to use, and a color to apply. Optionally, specifiy a secondary color if the template supports one. A scale can also be specified. This will allow the SVG to be scaled before it is converted into an image and thus look much better when scaled up. Returns a promise. Reference this in the Polygon or Symbol layer.
function createFromTemplate(id: string, templateName: string, color?: string, secondaryColor?: string, scale?: number): Promise<void>
Parameters
- id
-
string
The image's id. If the specified id matches the id of a previously added image the new image will be ignored.
- templateName
-
string
The name of the template to use.
- color
-
string
The primary color value. Default: #1A73AA
- secondaryColor
-
string
A secondary color value. Default: white
- scale
-
number
Specifies how much to scale the template. For best results, scale the icon to the maximum size you want to display it on the map, then use the symbol layers icon size option to scale down if needed. This will reduce blurriness due to scaling. Default: 1
Returns
Promise<void>
getImageIds()
Gets a list of all the image ids that have been added to the maps image sprite.
function getImageIds(): string[]
Returns
string[]
hasImage(string)
Checks to see if an image is already loaded into the maps image sprite.
function hasImage(id: string): boolean
Parameters
- id
-
string
The id to check the map's image sprite for.
Returns
boolean
remove(string)
Removes an image from the map's image sprite.
function remove(id: string)
Parameters
- id
-
string
The id of the image to remove.