MapWidget class
A widget that displays a Mapbox map using the Mapbox Maps Flutter SDK.
You use this class to display map information and to manipulate the map contents from your application. You can center the map on a given coordinate, specify the size of the area you want to display, and style the features of the map to fit your application's use case.
Use of MapWidget requires a Mapbox API access token. Obtain an access token on the Mapbox account page.
Warning: Please note that you are responsible for getting permission to use the map data, and for ensuring your use adheres to the relevant terms of use.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- MapWidget
Constructors
-
MapWidget.new({Key? key, String styleUri = MapboxStyles.STANDARD, ViewportState? viewport, ViewportController? viewportController, MapCreatedCallback? onMapCreated, OnStyleLoadedListener? onStyleLoadedListener, OnCameraChangeListener? onCameraChangeListener, OnMapIdleListener? onMapIdleListener, OnMapLoadedListener? onMapLoadedListener, OnMapLoadErrorListener? onMapLoadErrorListener, OnRenderFrameStartedListener? onRenderFrameStartedListener, OnRenderFrameFinishedListener? onRenderFrameFinishedListener, OnSourceAddedListener? onSourceAddedListener, OnSourceDataLoadedListener? onSourceDataLoadedListener, OnSourceRemovedListener? onSourceRemovedListener, OnStyleDataLoadedListener? onStyleDataLoadedListener, OnStyleImageMissingListener? onStyleImageMissingListener, OnStyleImageUnusedListener? onStyleImageUnusedListener, OnResourceRequestListener? onResourceRequestListener, @Deprecated('Subscribe to mapboxMap.gestures.pan.gestureEvents inside [onMapCreated] instead.') OnMapScrollListener? onScrollListener, @Deprecated('Subscribe to mapboxMap.gestures.zoom.gestureEvents inside [onMapCreated] instead.') OnMapZoomListener? onZoomListener, MapOptions? mapOptions, bool? textureView, AndroidPlatformViewHostingMode androidHostingMode = AndroidPlatformViewHostingMode.HC, Set<
Factory< ? gestureRecognizers, bool? isOpaque = true})OneSequenceGestureRecognizer> > -
const
Properties
- androidHostingMode → AndroidPlatformViewHostingMode
-
How the underlying Android
MapViewis hosted by Flutter. Has no effect on iOS or web.final -
gestureRecognizers
→ Set<
Factory< ?OneSequenceGestureRecognizer> > -
Gesture recognizers that should compete with the map for pointer
events. Used to integrate the map inside scrollables.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isOpaque → bool?
-
Whether the map is rendered as opaque. Only has an effect on iOS —
on Android, a transparent background requires MapWidget.textureView
to be
true(the default). Ignored on web: GL JS always renders to an alpha-capable canvas, so a transparent background there works out of the box and is not configurable.final - key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- mapOptions → MapOptions?
-
Initial map options applied at native-map construction time. Mobile
only; ignored on web.
final
- onCameraChangeListener → OnCameraChangeListener?
-
Invoked whenever camera position changes.
final
- onMapCreated → MapCreatedCallback?
-
Called when the map is created and ready for interaction.
final
- onMapIdleListener → OnMapIdleListener?
-
Invoked when the Map has entered the idle state. The Map is in the idle state when there are no ongoing transitions
and the Map has rendered all available tiles.
final
- onMapLoadedListener → OnMapLoadedListener?
-
Invoked when the Map's style has been fully loaded, and the Map has rendered all visible tiles.
final
- onMapLoadErrorListener → OnMapLoadErrorListener?
-
Invoked whenever the map load errors out.
final
- onRenderFrameFinishedListener → OnRenderFrameFinishedListener?
-
Invoked whenever the Map finished rendering a frame.
The render-mode value tells whether the Map has all data ("full") required to render the visible viewport.
The needs-repaint value provides information about ongoing transitions that trigger Map repaint.
The placement-changed value tells if the symbol placement has been changed in the visible viewport.
final
- onRenderFrameStartedListener → OnRenderFrameStartedListener?
-
Invoked whenever the Map started rendering a frame.
final
- onResourceRequestListener → OnResourceRequestListener?
-
Invoked when map makes a request to load required resources.
final
- onScrollListener → OnMapScrollListener?
-
final
- onSourceAddedListener → OnSourceAddedListener?
-
Invoked whenever the Source has been added with StyleManager#addStyleSource runtime API.
final
- onSourceDataLoadedListener → OnSourceDataLoadedListener?
-
Invoked when the requested source data has been loaded.
final
- onSourceRemovedListener → OnSourceRemovedListener?
-
Invoked whenever the Source has been removed with StyleManager#removeStyleSource runtime API.
final
- onStyleDataLoadedListener → OnStyleDataLoadedListener?
-
Invoked when the requested style data has been loaded.
final
- onStyleImageMissingListener → OnStyleImageMissingListener?
-
Invoked whenever a style has a missing image. This event is emitted when the Map renders visible tiles and
one of the required images is missing in the sprite sheet. Subscriber has to provide the missing image
by calling StyleManager#addStyleImage method.
final
- onStyleImageUnusedListener → OnStyleImageUnusedListener?
-
Invoked whenever an image added to the Style is no longer needed and can be removed using StyleManager#removeStyleImage method.
final
- onStyleLoadedListener → OnStyleLoadedListener?
-
Invoked when the requested style has been fully loaded, including the style, specified sprite and sources' metadata.
final
- onZoomListener → OnMapZoomListener?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- styleUri → String
-
The styleUri will applied for the MapWidget in the onStart lifecycle event if no style is set. Default is MapboxStyles.STANDARD.
final
- textureView → bool?
-
Whether to use a
TextureViewas the Android render surface. Has no effect on iOS or web. Defaults totrueto work around theSurfaceViewmemory leak documented at https://github.com/flutter/flutter/issues/118384.final - viewport → ViewportState?
-
The camera position and behavior of the map.
final
- viewportController → ViewportController?
-
A controller for imperatively changing the map's viewport with animations.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited