MapboxMap class

User-facing controller for a Mapbox map instance.

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

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 OnMapZoomListener?
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.
latefinal

Methods

addInteraction<T extends TypedFeaturesetFeature<FeaturesetDescriptor>>(TypedInteraction<T> interaction, {String? interactionID}) → void
Adds an interaction to the map.
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.
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.
getMapOptions() Future<MapOptions>
Returns the configured MapOptions for this map.
getPrefetchZoomDelta() Future<int>
Returns the current prefetch zoom delta.
getSize() Future<Size>
Returns the current map size in logical pixels.
isGestureInProgress() Future<bool>
Returns whether a gesture is currently in progress.
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.
moveBy(ScreenCoordinate screenCoordinate, MapAnimationOptions? mapAnimationOptions) Future<void>
Moves the camera by a screenCoordinate offset.
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.
removeInteraction(String interactionID) → void
Removes an interaction from the map by its interactionID.
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.
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.
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.
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.
toString() String
A string representation of this object.
inherited
triggerRepaint() Future<void>
Triggers a repaint of the map.

Operators

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