Interface StyleImageInterface
data: Uint8Array<ArrayBufferLike> | Uint8ClampedArray<ArrayBufferLike>;
height: number;
onAdd?: (map: MapLibreMap, id: string) => void;
onRemove?: () => void;
render?: () => boolean;
width: number;
}
Properties
data
height
OptionalonAdd
Optional method called when the layer has been added to the Map with Map.addImage.
Type Declaration
- (map: MapLibreMap, id: string): void
Parameters
- map: MapLibreMap
The Map this custom layer was just added to.
- id: string
Returns void
- map: MapLibreMap
OptionalonRemove
Optional method called when the icon is removed from the map with Map.removeImage. This gives the image a chance to clean up resources and event listeners.
Optionalrender
This method is called once before every frame where the icon will be used.
The method can optionally update the image's data member with a new image.
If the method updates the image it must return true to commit the change.
If the method returns false or nothing the image is assumed to not have changed.
If updates are infrequent it maybe easier to use Map.updateImage to update the image instead of implementing this method.
Type Declaration
- (): boolean
Returns boolean
trueif this method updated the image.falseif the image was not changed.
Interface for dynamically generated style images. This is a specification for implementers to model: it is not an exported method or class.
Images implementing this interface can be redrawn for every frame. They can be used to animate icons and patterns or make them respond to user input. Style images can implement a StyleImageInterface.render method. The method is called every frame and can be used to update the image.
See
Add an animated icon to the map.
Example