MapboxMap class base

User-facing controller for a Mapbox map instance.

Application code and the MapCreatedCallback in MapWidget use this class. Platform packages implement MapboxMapPlatformInterface directly.

Style APIs are available directly on this class, which extends StyleManager (e.g. mapboxMap.addLayer(...)).

Inheritance
Implemented types

Properties

annotations AnnotationManager
Provides access to annotation manager creation.
latefinal
attribution AttributionSettingsManager
Provides access to the attribution ornament settings.
latefinal
compass CompassSettingsManager
Provides access to the compass ornament settings.
latefinal
gestures GesturesSettingsManager
Provides access to gesture configuration.
latefinal
hashCode int
The hash code for this object.
no setterinherited
httpService MapboxHttpService
Provides access to HTTP request configuration.
latefinal
indoorSelector IndoorSelectorSettingsManager
Provides access to the indoor floor selector settings.
latefinal
location LocationSettingsManager
Provides access to the user location indicator.
latefinal
Provides access to the Mapbox logo ornament settings.
latefinal
onMapScrollListener OnMapScrollListener?
getter/setter pair
onMapZoomListener OnMapScrollListener?
getter/setter pair
projection Projection
Provides access to Spherical Mercator projection math.
latefinal
recorder MapRecorder
Provides access to recording and replaying API calls on the map.
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scaleBar ScaleBarSettingsManager
Provides access to the scale bar ornament settings.
latefinal
style StyleManager
Provides access to the map's style APIs.
no setter

Methods

addGeoJSONSourceFeatures(String sourceId, String dataId, List<Feature<GeometryObject>> features) Future<void>
Adds features to a GeoJSON style source.
inherited
addInteraction<T extends TypedFeaturesetFeature<FeaturesetDescriptor>>(TypedInteraction<T> interaction, {String? interactionID}) → void
Adds an interaction to the map.
addLayer(Layer layer, [LayerPosition? position]) Future<void>
Adds a Layer to the current style. Serializes the layer to JSON and forwards to StylePlatformInterface.addStyleLayer.
inherited
addPersistentLayer(Layer layer, [LayerPosition? position]) Future<void>
Adds a persistent Layer to the current style. Persistent layers survive style reloads when the new style does not redefine the layer id.
inherited
addPersistentStyleLayer(String properties, LayerPosition? layerPosition) Future<void>
Adds a persistent style layer from a JSON properties string. Persistent layers survive style reloads when the new style does not redefine the same layer id. Prefer the typed addPersistentLayer helpers for facade layer classes.
inherited
addSource(Source source) Future<void>
Adds a Source to the current style. Sources with multi-phase add requirements (e.g. GeoJsonSource with initial data) override Source.addToStyle to handle their specifics.
inherited
addStyleImage(String imageId, double scale, MbxImage image, {bool sdf = false, List<ImageStretches?> stretchX = const <ImageStretches?>[], List<ImageStretches?> stretchY = const <ImageStretches?>[], ImageContent? content}) Future<void>
Adds an image to the style. Existing images with the same imageId are replaced. stretchX and stretchY default to empty lists; content and sdf to null/false — mirroring the most common usage.
inherited
addStyleImportFromJSON(String importId, String json, {Map<String, Object>? config, ImportPosition? importPosition}) Future<void>
Adds a new import to the current style from a JSON string.
inherited
addStyleImportFromURI(String importId, String uri, {Map<String, Object>? config, ImportPosition? importPosition}) Future<void>
Adds a new import to the current style from a URI.
inherited
addStyleLayer(String properties, LayerPosition? layerPosition) Future<void>
Adds a new style layer from a JSON properties string. Prefer the typed addLayer / addLayerAt helpers when constructing layers from facade classes; this raw-JSON form is for callers driving layers from style spec strings directly.
inherited
addStyleModel(String modelId, String modelUri) Future<void>
Adds a 3D model to the style for use as model-id in a model layer.
inherited
addStyleSource(String sourceId, String properties) Future<void>
Adds a new style source from a JSON properties string. Prefer the typed addSource helper when constructing sources from facade classes; this raw-JSON form is for callers driving sources from style spec strings.
inherited
cameraForCoordinateBounds(CoordinateBounds bounds, MbxEdgeInsets padding, double? bearing, double? pitch, double? maxZoom, ScreenCoordinate? offset) Future<CameraOptions>
Returns camera options that fit the given coordinate bounds.
cameraForCoordinates(List<Point> coordinates, MbxEdgeInsets padding, double? bearing, double? pitch) Future<CameraOptions>
Returns camera options centered on the given coordinates.
cameraForCoordinatesCameraOptions(List<Point> coordinates, CameraOptions camera, ScreenBox box) Future<CameraOptions>
Returns the camera options adjusted so the given coordinates fit inside the given box, using the given starting camera state.
cameraForCoordinatesPadding(List<Point> coordinates, CameraOptions camera, MbxEdgeInsets? coordinatesPadding, double? maxZoom, ScreenCoordinate? offset) Future<CameraOptions>
Returns camera options that fit the given coordinates with optional padding, max zoom and offset.
cameraForGeometry(Map<String?, Object?> geometry, MbxEdgeInsets padding, double? bearing, double? pitch) Future<CameraOptions>
Returns camera options that fit the given GeoJSON geometry.
cancelCameraAnimation() Future<void>
Cancels any in-progress camera animation.
clearData() Future<void>
Clears temporary map data for this instance, freeing resources.
coordinateBoundsForCamera(CameraOptions camera) Future<CoordinateBounds>
Returns the coordinate bounds that are visible for a given camera.
coordinateBoundsForCameraUnwrapped(CameraOptions camera) Future<CoordinateBounds>
Returns the coordinate bounds (unwrapped) visible for a given camera.
coordinateBoundsZoomForCamera(CameraOptions camera) Future<CoordinateBoundsZoom>
Returns the coordinate bounds and zoom for a given camera.
coordinateBoundsZoomForCameraUnwrapped(CameraOptions camera) Future<CoordinateBoundsZoom>
Returns the coordinate bounds (unwrapped) and zoom for a given camera.
coordinateForPixel(ScreenCoordinate pixel) Future<Point>
Converts a pixel screen position to a geographic coordinate.
coordinatesForPixels(List<ScreenCoordinate> pixels) Future<List<Point>>
Converts a list of screen pixels to geographic coordinates.
dispatch(String gesture, ScreenCoordinate screenCoordinate) Future<void>
Dispatches a synthetic gesture event for testing purposes.
dispose() → void
Releases resources held by this map instance.
easeTo(CameraOptions cameraOptions, MapAnimationOptions? mapAnimationOptions) Future<void>
Animates the camera to cameraOptions using an ease animation.
flyTo(CameraOptions cameraOptions, MapAnimationOptions? mapAnimationOptions) Future<void>
Animates the camera to cameraOptions using a fly animation.
getBounds() Future<CameraBounds>
Returns the current camera bounds.
getCameraState() Future<CameraState>
Returns the current camera state.
getDebugOptions() Future<List<MapWidgetDebugOptions>>
Returns the currently-enabled widget debug options for this map.
getElevation(Point coordinate) Future<double?>
Returns the elevation in meters at the given coordinate.
getFeaturesets() Future<List<FeaturesetDescriptor>>
Returns the featuresets defined by the currently loaded style.
inherited
getFeatureState(String sourceId, String? sourceLayerId, String featureId) Future<String>
Returns the state map of a feature within a style source as a JSON string.
getFeatureStateForFeaturesetDescriptor(FeaturesetDescriptor featureset, FeaturesetFeatureId featureId) Future<Map<String, Object?>>
Gets the state map of a feature within a featureset.
getFeatureStateForFeaturesetFeature(FeaturesetFeature feature) Future<Map<String, Object?>>
Gets the state map of a feature.
getGeoJsonClusterChildren(String sourceIdentifier, Map<String?, Object?> cluster) Future<FeatureExtensionValue>
Returns the children of a cluster from a GeoJSON source.
getGeoJsonClusterExpansionZoom(String sourceIdentifier, Map<String?, Object?> cluster) Future<FeatureExtensionValue>
Returns the zoom at which a cluster expands into multiple children.
getGeoJsonClusterLeaves(String sourceIdentifier, Map<String?, Object?> cluster, int? limit, int? offset) Future<FeatureExtensionValue>
Returns the leaves (original points) of a cluster from a GeoJSON source.
getLayer(String layerId) Future<Layer?>
Returns a decoded Layer by id, or null when layerId is unknown or its type is not handled.
inherited
getMapOptions() Future<MapOptions>
Returns the configured MapOptions for this map.
getPrefetchZoomDelta() Future<int>
Returns the current prefetch zoom delta.
getProjection() Future<StyleProjection?>
Returns the style projection.
inherited
getSize() Future<Size>
Returns the current map size in logical pixels.
getSource(String sourceId) Future<Source?>
Returns a Source by id, or null when sourceId is unknown or its type is not handled. The returned source is bound to this style so subsequent property getters work.
inherited
getStyleDefaultCamera() Future<CameraOptions>
Returns the default camera position defined by the style.
inherited
getStyleImage(String imageId) Future<MbxImage?>
Returns a previously-added style image, or null when imageId is unknown.
inherited
getStyleImportConfigProperties(String importId) Future<Map<String, StylePropertyValue>>
Returns all configuration properties for a style import as a map.
inherited
getStyleImportConfigProperty(String importId, String config) Future<StylePropertyValue>
Returns a single configuration property for a style import.
inherited
getStyleImports() Future<List<StyleObjectInfo?>>
Returns all current style imports.
inherited
getStyleImportSchema(String importId) Future<Object>
Returns the schema of a style import.
inherited
getStyleJSON() Future<String>
Returns the current style as a JSON string.
inherited
getStyleLayerProperties(String layerId) Future<String>
Returns all properties of a layer as a JSON string.
inherited
getStyleLayerProperty(String layerId, String property) Future<StylePropertyValue>
Returns the live value of a single layer property.
inherited
getStyleLayers() Future<List<StyleObjectInfo?>>
Returns all style layers.
inherited
getStyleLightProperty(String id, String property) Future<StylePropertyValue>
Returns the live value of a single light property.
inherited
getStyleLights() Future<List<StyleObjectInfo?>>
Returns the current style's lights.
inherited
getStyleSourceProperties(String sourceId) Future<String>
Returns all properties of a source as a JSON string.
inherited
getStyleSourceProperty(String sourceId, String property) Future<StylePropertyValue>
Returns the live value of a single source property as a StylePropertyValue envelope.
inherited
getStyleSources() Future<List<StyleObjectInfo?>>
Returns all style sources.
inherited
getStyleTerrainProperty(String property) Future<StylePropertyValue>
Returns the live value of a single terrain property.
inherited
getStyleTransition() Future<TransitionOptions>
Returns the current style transition options.
inherited
getStyleURI() Future<String>
Returns the current style URI.
inherited
hasStyleImage(String imageId) Future<bool>
Returns whether an image with the given id exists.
inherited
invalidateStyleCustomGeometrySourceRegion(String sourceId, CoordinateBounds bounds) Future<void>
Invalidates a region in a custom geometry source so its tiles get re-fetched.
inherited
invalidateStyleCustomGeometrySourceTile(String sourceId, CanonicalTileID tileId) Future<void>
Invalidates a tile in a custom geometry source so it gets re-fetched.
inherited
isGestureInProgress() Future<bool>
Returns whether a gesture is currently in progress.
isStyleLayerPersistent(String layerId) Future<bool>
Returns whether the layer with the given id is persistent.
inherited
isStyleLoaded() Future<bool>
Returns whether the style is fully loaded.
inherited
isUserAnimationInProgress() Future<bool>
Returns whether a user-driven animation is currently in progress.
loadStyleJson(String styleJson) Future<void>
Loads the style from a JSON string.
loadStyleURI(String styleURI) Future<void>
Loads the style from a given URI.
localizeLabels(String locale, List<String>? layerIds) Future<void>
Localizes label text in the style for the given locale, optionally scoped to a subset of layers.
inherited
moveBy(ScreenCoordinate screenCoordinate, MapAnimationOptions? mapAnimationOptions) Future<void>
Moves the camera by a screenCoordinate offset.
moveStyleImport(String importId, ImportPosition? importPosition) Future<void>
Moves an import to a new position.
inherited
moveStyleLayer(String layerId, LayerPosition? layerPosition) Future<void>
Moves a style layer to a new position.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pitchBy(double pitch, MapAnimationOptions? mapAnimationOptions) Future<void>
Pitches the camera by pitch degrees with optional animation.
pixelForCoordinate(Point coordinate) Future<ScreenCoordinate>
Converts a geographic coordinate to a screen ScreenCoordinate.
pixelsForCoordinates(List<Point> coordinates) Future<List<ScreenCoordinate>>
Converts a list of geographic coordinates to screen positions.
queryRenderedFeatures(RenderedQueryGeometry geometry, RenderedQueryOptions options) Future<List<QueriedRenderedFeature?>>
Queries the map for rendered features inside geometry matching the given query options.
queryRenderedFeaturesForFeatureset({required FeaturesetDescriptor featureset, RenderedQueryGeometry? geometry, String? filter}) Future<List<FeaturesetFeature>>
Queries the map for rendered features matching a featureset.
querySourceFeatures(String sourceId, SourceQueryOptions options) Future<List<QueriedSourceFeature?>>
Queries the source identified by sourceId for features matching the given query options.
reduceMemoryUse() Future<void>
Reduces memory usage by clearing caches.
removeFeatureState(String sourceId, String? sourceLayerId, String featureId, String? stateKey) Future<void>
Removes a single state property (or all properties) from a feature within a style source. Pass null for stateKey to remove all.
removeFeatureStateForFeaturesetDescriptor({required FeaturesetDescriptor featureset, required FeaturesetFeatureId featureId, String? stateKey}) Future<void>
Removes entries from a feature state object within a featureset.
removeFeatureStateForFeaturesetFeature({required FeaturesetFeature feature, String? stateKey}) Future<void>
Removes entries from a feature state object.
removeGeoJSONSourceFeatures(String sourceId, String dataId, List<String> featureIds) Future<void>
Removes features from a GeoJSON style source by id.
inherited
removeInteraction(String interactionID) → void
Removes an interaction from the map by its interactionID.
removeStyleImage(String imageId) Future<void>
Removes a style image.
inherited
removeStyleImport(String importId) Future<void>
Removes an import from the style.
inherited
removeStyleLayer(String layerId) Future<void>
Removes a style layer.
inherited
removeStyleModel(String modelId) Future<void>
Removes a 3D model from the style.
inherited
removeStyleSource(String sourceId) Future<void>
Removes a style source.
inherited
resetFeatureStatesForFeatureset(FeaturesetDescriptor featureset) Future<void>
Resets all feature states within a featureset.
rotateBy(ScreenCoordinate first, ScreenCoordinate second, MapAnimationOptions? mapAnimationOptions) Future<void>
Rotates the camera between two touch points.
scaleBy(double amount, ScreenCoordinate? anchor, MapAnimationOptions? mapAnimationOptions) Future<void>
Scales the camera by amount around an optional anchor point.
setBounds(CameraBoundsOptions options) Future<void>
Constrains the camera to the given bounds options.
setCamera(CameraOptions cameraOptions) Future<void>
Sets the camera to the given CameraOptions without animation.
setConstrainMode(ConstrainMode mode) Future<void>
Sets the map's constrain mode.
setCustomHeaders(Map<String, String> headers) Future<void>
Set custom headers for all Mapbox HTTP requests
setDebugOptions(List<MapWidgetDebugOptions> options) Future<void>
Replaces the set of enabled widget debug options with options.
setFeatureState(String sourceId, String? sourceLayerId, String featureId, String state) Future<void>
Updates entries in the state map of a feature within a style source.
setFeatureStateForFeaturesetDescriptor(FeaturesetDescriptor featureset, FeaturesetFeatureId featureId, FeatureState state) Future<void>
Updates entries in the state map of a feature within a featureset.
setFeatureStateForFeaturesetFeature(FeaturesetFeature feature, FeatureState state) Future<void>
Updates the state map of an individual feature.
setGestureInProgress(bool inProgress) Future<void>
Tells the rendering engine that a gesture is in progress so labels can switch to gesture-friendly texture filters.
setLight(FlatLight flatLight) Future<void>
Sets a single flat light source. Use setLights for ambient + directional.
inherited
setLights(AmbientLight ambientLight, DirectionalLight directionalLight) Future<void>
Sets ambient + directional lights together. Disables any flat light.
inherited
setNorthOrientation(NorthOrientation orientation) Future<void>
Sets the map's north orientation.
setOnMapMoveListener(OnMapScrollListener? listener) → void
setOnMapZoomListener(OnMapZoomListener? listener) → void
setPrefetchZoomDelta(int delta) Future<void>
Sets the prefetch zoom delta. When non-zero, the engine first requests tiles delta levels below the target zoom so the map fills in faster at lower resolution.
setProjection(StyleProjection projection) Future<void>
Sets the style projection.
inherited
setSnapshotLegacyMode(bool enabled) Future<void>
Sets whether legacy mode is used for snapshot. Has no effect on iOS.
setStyleGlyphURL(String glyphURL) Future<void>
Sets the runtime glyph URL used for text labels.
setStyleImportConfigProperties(String importId, Map<String, Object> configs) Future<void>
Sets all configuration properties for an import from a map.
inherited
setStyleImportConfigProperty(String importId, String config, Object value) Future<void>
Sets an import configuration property value.
inherited
setStyleJSON(String json) Future<void>
Loads a style from a JSON string.
inherited
setStyleLayerProperties(String layerId, String properties) Future<void>
Sets all properties of a layer from a JSON object string.
inherited
setStyleLayerProperty(String layerId, String property, Object value) Future<void>
Sets a layer property value from a JSON string.
inherited
setStyleLightProperty(String id, String property, Object value) Future<void>
Sets a value on a single light property.
inherited
setStyleSourceProperties(String sourceId, String properties) Future<void>
Sets all properties of a source from a JSON object string.
inherited
setStyleSourceProperty(String sourceId, String property, Object value) Future<void>
Sets a source property value from a JSON string.
inherited
setStyleTerrain(String properties) Future<void>
Sets the style terrain from a JSON string.
inherited
setStyleTerrainProperty(String property, Object value) Future<void>
Sets a value on a single terrain property.
inherited
setStyleTransition(TransitionOptions transitionOptions) Future<void>
Sets the style transition options.
inherited
setStyleURI(String uri) Future<void>
Loads a style from a URI.
inherited
setTileCacheBudget(TileCacheBudgetInMegabytes? tileCacheBudgetInMegabytes, TileCacheBudgetInTiles? tileCacheBudgetInTiles) Future<void>
Sets the tile cache budget.
setUserAnimationInProgress(bool inProgress) Future<void>
Tells the rendering engine that a user-driven animation is in progress so symbol placement is more stable.
setViewportMode(ViewportMode mode) Future<void>
Sets the map's viewport mode.
snapshot() Future<Uint8List>
Captures a snapshot of the current map view as PNG-encoded bytes.
startPerformanceStatisticsCollection(PerformanceStatisticsOptions options, PerformanceStatisticsListener listener) → void
Starts collecting CPU/GPU render performance statistics with the given options, delivering each sampled snapshot to listener. Calling this while collection is already active replaces the previous listener; call stopPerformanceStatisticsCollection before restarting.
stopPerformanceStatisticsCollection() → void
Stops collection started by startPerformanceStatisticsCollection. No-op when no collection is active.
styleGlyphURL() Future<String>
Returns the runtime glyph URL used for text labels.
styleLayerExists(String layerId) Future<bool>
Returns whether a layer with the given id exists.
inherited
styleSourceExists(String sourceId) Future<bool>
Returns whether a source with the given id exists.
inherited
toString() String
A string representation of this object.
inherited
triggerRepaint() Future<void>
Triggers a repaint of the map.
updateGeoJSONSourceFeatures(String sourceId, String dataId, List<Feature<GeometryObject>> features) Future<void>
Updates existing features in a GeoJSON style source.
inherited
updateLayer(Layer layer) Future<void>
Updates an existing layer. Serializes the layer to JSON and forwards to StylePlatformInterface.setStyleLayerProperties.
inherited
updateSource(Source source) Future<void>
Updates an existing source. Serializes the source to JSON and forwards to StylePlatformInterface.setStyleSourceProperties.
inherited
updateStyleImageSourceImage(String sourceId, MbxImage image) Future<void>
Replaces the image data of an existing image-type style source.
inherited
updateStyleImportWithJSON(String importId, String json, {Map<String, Object>? config}) Future<void>
Updates an existing import from a JSON string.
inherited
updateStyleImportWithURI(String importId, String uri, {Map<String, Object>? config}) Future<void>
Updates an existing import from a URI.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited