plugin_api library
API for packages that add their own layers to UnifiedMap, like flutter_map's plugin_api.dart.
A layer is a StatefulWidget placed in UnifiedMap.children (directly or inside other widgets) whose state
extends MapLayerState. The order of UnifiedMap.children is the layers' z-order. In MapLayerState.sync it
registers native objects with the map:
- markers through a MarkerPublisher: a list of MarkerSpecs is published atomically once all its icons are rasterised, optionally animated by a MarkerTransition (this layer's markers sliding from / to a position while fading) and with the layer's polylines (spiderfy legs), which are sent once those markers are applied;
- polylines alone with MapLayerState.setPolylines;
- flutter_map layer widgets with MapLayerState.setFlutterMapLayers, drawn only where MapLayerHost.supportsFlutterMapLayers (web, Windows, Linux);
- anything else through MapLayerHost.registry (LayerRegistry).
MapLayerState.host gives the camera (MapLayerHost.camera, MapLayerHost.liveCamera on every move, MapLayerHost.idleCamera when settled), the controller, the pixel ratio and the icon cache.
class PinsLayer extends StatefulWidget {
const PinsLayer({super.key, required this.points});
final List<LatLng> points;
@override
State<PinsLayer> createState() => _PinsLayerState();
}
class _PinsLayerState extends MapLayerState<PinsLayer> {
late final _publisher = MarkerPublisher(layerId);
@override
void sync() => _publisher.publish(host, [
for (final (i, p) in widget.points.indexed)
MarkerSpec(id: objectId(null, i), position: p, iconKey: 'pin', child: const Pin(), size: const Size(24, 24)),
]);
@override
void dispose() {
_publisher.dispose();
super.dispose();
}
}
Classes
- AndroidMapParams
- Settings of the Google Maps SDK for Android. Every null field keeps the SDK default.
- AndroidMarkerParams
- Google Maps marker settings.
- AndroidPolygonParams
- Google Maps polygon settings.
- AppleMapParams
- Settings of MapKit (iOS and macOS share one map view). Every null field keeps the MapKit default.
- AppleMarkerParams
- MapKit marker settings.
- ApplePoiFilter
-
MKPointOfInterestFilter. - AssetTileProvider
- Fetch tiles from the app's shipped assets, where the tile URL is a path within the asset store
- BaseOverlayImage
- An image of an OverlayImageLayer. Same fields as flutter_map's.
- BuiltInMapCachingProvider
- Simple built-in map caching using an I/O storage mechanism, for native (non-web) platforms only
- CachedMapTileMetadata
- Metadata about a tile cached with a MapCachingProvider
- CameraConstraint
-
Limits where the camera can go. Same API as flutter_map's (
MapOptions.cameraConstraint). - CameraFit
- Describes a camera position by what must be visible. Same API as flutter_map's: subclass it and implement fit for a custom fit.
- CentroidCalculator
-
CircleLayer<
R extends Object> -
flutter_map's
CircleLayer. optimizeRadiusInMeters tunes flutter_map's painter and only applies on the flutter_map backend. -
CircleMarker<
R extends Object> -
flutter_map's
CircleMarker. A metre radius (useRadiusInMeter) is a native circle (GoogleCircle, MapKitMKCircle). A pixel radius keeps its size on screen at every moment, as in flutter_map: natively it is drawn as a marker showing a rasterised circle (fill and border), anchored at its center. - ContainCamera
- ContainCameraCenter
- ContainCameraLatitude
- Crs
- An abstract representation of a Coordinate Reference System.
- CrsSimple
- Custom CRS for non geographical maps
- CursorKeyboardRotationOptions
- Options to configure cursor/keyboard rotation
- DisabledMapCachingProvider
- Caching provider which disables built-in caching
- Epsg3857
- EPSG:3857, The most common CRS used for rendering maps.
- Epsg4326
- EPSG:4326, A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
- FadeInTileDisplay
- Displays a tile with a fade-in animation
- FadeRAWA
- The popup fades in (the default).
- FileTileProvider
- Fetch tiles from the local filesystem (not asset store), where the tile URL is a path within the filesystem.
- FitBounds
- FitCoordinates
- FitInsideBounds
- FlutterMapLayer
-
A raw flutter_map layer: child is drawn inside the map's
FlutterMap, above the map's own objects, on the platforms that draw the map with flutter_map (web, Windows, Linux). On Android, iOS and macOS it draws nothing. - IconCache
- Per-map cache of rasterised marker icons, keyed by icon key, logical size and pixel ratio.
- InstantaneousTileDisplay
- Displays a tile instantaneously
- InteractionOptions
-
flutter_map's
InteractionOptions, field for field. - InteractiveFlag
- Use InteractiveFlag to disable / enable certain events Use InteractiveFlag.all to enable all events, use InteractiveFlag.none to disable all events
- KeyboardOptions
- Options to configure how keyboard keys may be used to control the map
- LatLng
- Coordinates in Degrees
- LatLngBounds
- Data structure representing rectangular bounding box constrained by its northwest and southeast corners
- LatLngTween
-
A Tween object for LatLng. Used for AnimationController to handle
animated changes of the
MapCamera. -
LayerHitResult<
R extends Object> -
What a tap hit in a layer, as flutter_map's
LayerHitResult: the hitValues of the elements under the pointer (topmost first), and where the tap landed. Resolved in Dart by the core. - LayerRegistry
- Objects contributed by every layer of one map, grouped by kind and keyed by layer id.
- LogoSourceAttribution
-
An image attribution permanently displayed adjacent to the open/close icon of
a
RichAttributionWidget - MapCachingProvider
- Provides tile caching facilities to TileProviders
- MapCamera
-
The view of a map: same API as flutter_map's
MapCamera, refreshed on every platform camera event. - MapController
-
Drives the camera of a UnifiedMap. flutter_map's
MapControllerAPI, plus the animated API offlutter_map_animations.AnimatedMapController, since native maps animate the camera themselves. - MapError
- A map error as reported by the platform. message is the platform's own description (key name, native error text). title and hint are English guidance for developers, used by the default MapErrorView.
- MapErrorView
-
Default overlay shown by
UnifiedMapwhen the platform reports a MapError. Replace it withUnifiedMap.errorBuilder. - MapEvent
- Base class of every map event, as flutter_map's: apps and plugins may extend it (with MapEventSource.custom).
- MapEventDoubleTapZoom
- MapEventDoubleTapZoomEnd
- MapEventDoubleTapZoomStart
- MapEventFlingAnimation
- MapEventFlingAnimationEnd
- MapEventFlingAnimationNotStarted
- A drag ended without momentum.
- MapEventFlingAnimationStart
- MapEventLongPress
- MapEventMove
-
The camera moved. id is the id given to
MapController.move(id:)(oranimateTo(customId:)) when the move comes from that call. - MapEventMoveEnd
- A gesture ended.
- MapEventMoveStart
- A gesture starts moving the camera. Programmatic moves have no start and end events, as in flutter_map.
- MapEventNonRotatedSizeChange
- MapEventRotate
- The rotation changed. Emitted whenever it changes, alongside MapEventMove when the center or zoom changed too.
- MapEventRotateEnd
- The end of a gesture that rotated the map.
- MapEventRotateStart
- The first rotation change of a gesture.
- MapEventScrollWheelZoom
- MapEventSecondaryTap
- A secondary tap (mouse right click, stylus button, secondary click on iPadOS and macOS).
- MapEventTap
- MapEventWithMove
- An event that changed the camera.
- MapLayerHost
-
What a layer needs from the map it lives in. A
MapLayerStatereaches it throughhost. -
MapLayerState<
W extends StatefulWidget> - Base state of every map layer, built-in or from another package.
- MapOptions
-
flutter_map's
MapOptions, field for field, plus nativeParams (native-only settings, ignored by the flutter_map backend) and onMapLoaded / onMapError (every backend). - Marker
-
A widget pinned to a coordinate. flutter_map's
Marker, plus iconKey, onTap and nativeParams. - MarkerLayer
-
flutter_map's
MarkerLayer. Each marker becomes a native marker showing its rasterised child (on the flutter_map backend, the same bitmap in flutter_map's marker layer). - MarkerPublisher
- Publishes a layer's markers in atomic generations.
- MarkerSpec
- One native marker to publish: its object id, where it goes, what to rasterise and how to anchor it.
- MarkerTransition
-
How a layer wants its next marker update animated (see
PlatformMarkerTransitionfor what every backend does). - MobileLayerTransformer
-
flutter_map's
MobileLayerTransformer: sizes child to the rotated view and turns it with the map, for custom layers painted by Flutter. Over a native map such a layer follows the camera one frame late during gestures. - MultiFingerGesture
- Use MultiFingerGesture to disable / enable certain gestures Use MultiFingerGesture.all to enable all gestures, use MultiFingerGesture.none to disable all gestures
- NativeMarkerParams
-
Settings of a native marker, for
Marker.nativeParams. Ignored by the flutter_map backend. Every null field keeps the default given in its doc. - NativeParams
-
Settings that only native maps have, for
MapOptions.nativeParams. - NativePolygonParams
-
Settings of a native polygon, for
Polygon.nativeParams. Ignored by the flutter_map backend. - NativePolylineParams
-
Settings of a native polyline, for
Polyline.nativeParams. Ignored by the flutter_map backend. - NativeTileLayerParams
-
Settings of a tile layer on native maps, for
TileLayer.nativeParams. Ignored by the flutter_map backend. - NetworkTileProvider
- TileProvider to fetch tiles from the network.
- OverlayImage
- An image stretched over bounds, north up.
- OverlayImageLayer
-
flutter_map's
OverlayImageLayer: images pinned to the ground. Natively each image is a ground overlay (GoogleGroundOverlay, a MapKit overlay drawing the image), resolved from itsImageProvideronce and registered with the platform like a marker icon; the flutter_map backend draws flutter_map's own layer. -
Polygon<
R extends Object> -
flutter_map's
Polygon, plus nativeParams. Per backend: - PolygonLabelPlacementCalculator
- Where a polygon's label goes. Same API as flutter_map's.
-
PolygonLayer<
R extends Object> -
flutter_map's
PolygonLayer. Per backend: - PolylabelCalculator
-
Polyline<
R extends Object> -
flutter_map's
Polyline, plus nativeParams. Per backend: -
PolylineLayer<
R extends Object> -
flutter_map's
PolylineLayer. cullingMargin and simplificationTolerance tune flutter_map's painter: natively the map culls and simplifies itself, so they only apply on the flutter_map backend. drawInSingleWorld false (the default) draws each segment the short way across the antimeridian, as native maps do; true is honoured on the flutter_map backend only. - PositionedTapController
- PositionedTapDetector2
- Proj4Crs
- Custom CRS
- Projection
- The abstract base Projection class, used for coordinate reference systems like Epsg3857. Inherit from this class if you want to create or implement your own CRS.
- RenderTranslucentPointer
- A render object that is invisible to its parent during hit testing.
- RichAttributionWidget
-
flutter_map's
RichAttributionWidget: a button that opens a popup listing the attributions, with the LogoSourceAttributions always shown next to it. Place it inUnifiedMap.children. - RichAttributionWidgetAnimation
- How a RichAttributionWidget animates its popup and button. Same API as flutter_map's.
- RotatedOverlayImage
- An image whose top-left, bottom-left and bottom-right corners land on the given points (rotated or skewed). MapKit draws it exactly; Google Maps can only rotate a rectangle, so a skewed image is drawn as the closest rotated rectangle there.
- Scalebar
-
flutter_map's
Scalebar: a metric scale bar drawn by Flutter over the map, on every backend. Place it inUnifiedMap.children. (MapKit's own scale bar isAppleMapParams.showsScale.) - ScalebarPainter
- Paints a Scalebar.
- ScaleRAWA
- The popup scales in from the button's corner.
- SimpleAttributionWidget
-
Bottom-right one-line attribution, as flutter_map's. Place it in
UnifiedMap.children. - SimpleCentroidCalculator
- SimpleMultiWorldCentroidCalculator
- SourceAttribution
-
Base class for attributions that render themselves as widgets in a
RichAttributionWidget - SphericalMercator
- Spherical mercator projection
- StrokePattern
- Determines whether a stroke should be solid, dotted, or dashed, and the exact characteristics of each
- TapPosition
- TextSourceAttribution
-
A simple text attribution displayed in the popup box of a
RichAttributionWidget - TileCoordinates
-
Tile coordinates identify the position of the tile position for
slippy map tiles. The z coordinate represents the zoom level where the
zoom level of 0 fits the complete world while bigger z values are using
accordingly to the zoom level of the
MapCamera. - TileDisplay
- Defines how the tile should get displayed on the map.
- TileImage
- The tile image class
- TileLayer
-
flutter_map's
TileLayer, plus nativeParams. On native maps the tiles are drawn by the platform above its own base map (NativeTileLayerParams.replacesBaseMap hides it); on the flutter_map backend this is flutter_map's own layer, built with every parameter. - TileProvider
- The base tile provider, extended by other classes with more specialised purposes and/or requirements
- TileUpdateEvent
- Describes whether loading and/or pruning should occur and allows overriding the load center/zoom.
- TileUpdateTransformers
- Contains a set of built-in TileUpdateTransformers
- TranslucentPointer
- A widget that is invisible for its parent during hit testing, but still allows its subtree to receive pointer events
- UnconstrainedCamera
- UnifiedMap
-
The map. Same shape as flutter_map's
FlutterMap(also available under that name), plus errorBuilder. - WidgetRasterizer
- Renders a widget off-screen to PNG bytes at a device pixel ratio.
- WMSTileLayerOptions
- Options for the []
Enums
- AndroidMapColorScheme
-
GoogleMap.setMapColorScheme. - AndroidMapType
-
Google Maps map types:
GoogleMap.mapType(MAP_TYPE_NORMAL,SATELLITE,HYBRID,TERRAIN,NONE); muted is the normal map with a desaturated style. - AppleCollisionMode
-
MKAnnotationViewCollisionMode. - AppleElevationStyle
-
MKMapConfiguration.elevationStyle: realistic draws terrain in 3D (iOS 16 / macOS 13). - AppleMapType
-
MapKit map types. The flyover types use
elevationStyle: .realistic(3D terrain); like tilt, they make the Dart projections approximate. - ApplePoiCategory
-
Categories of MapKit's points of interest (
MKPointOfInterestCategory). - AttributionAlignment
-
Position to anchor
RichAttributionWidgetto relative to theFlutterMap - CursorRotationBehaviour
- The behaviour of the cursor/keyboard rotation function in terms of the angle that the map is rotated to
- EvictErrorTileStrategy
- Strategies on how to handle tile errors
- MapErrorCode
- Why the map cannot show its base map.
- MapEventSource
- Who triggered an event. Same values as flutter_map's.
- MapStyle
-
Native base map rendering shared by Google Maps and MapKit. none hides the native base map, for apps whose
TileLayerreplaces it. - PatternFit
- Determines how a non-solid StrokePattern should be fit to a line when their lengths are not equal or multiples
- PolygonLabelPlacement
-
Defines the algorithm used to calculate the position of the
Polygonlabel. - PolygonPainterFillMethod
- The method used by the painter to fill polygons and resolve overlaps & intersections
- RetinaMode
- Retina mode improves the resolution of map tiles, particularly on high density displays
- ScalebarLength
- How long the Scalebar is, relative to the default m.
Extensions
Constants
- integerZoomEpsilon → const double
- Tolerance of integerZoom: MapKit reports zoom 5 as 4.9999999.
Functions
-
coordinateDebugTileBuilder(
BuildContext context, Widget tileWidget, TileImage tile) → Widget - Shows coordinates over Tiles
-
darkModeTileBuilder(
BuildContext context, Widget tileWidget, TileImage tile) → Widget - Applies inversion color matrix on Tiles which may simulate Dark mode. darkModeTilesContainerBuilder is better at performance because it applies color matrix on the container instead of on every Tile
-
darkModeTilesContainerBuilder(
BuildContext context, Widget tilesContainer) → Widget - Applies inversion color matrix on Tiles container which may simulate Dark mode.
-
integerZoom(
double zoom) → int -
The integer zoom level
zoomis at, tolerating the rounding error of platforms that convert zoom to a span. -
loadingTimeDebugTileBuilder(
BuildContext context, Widget tileWidget, TileImage tile) → Widget - Shows the Tile loading time in ms
Typedefs
- CachedMapTile = ({Uint8List bytes, CachedMapTileMetadata metadata})
- A tile's bytes and metadata returned from MapCachingProvider.getTile
- ErrorTileCallBack = void Function(TileImage tile, Object error, StackTrace? stackTrace)
-
Callback definition for the
TileLayer.errorTileCallbackoption. - FlutterMap = UnifiedMap
-
flutter_map's name for UnifiedMap, so that
FlutterMap(options: ..., children: [...])compiles unchanged. - IconCacheKey = (Object, Size, double)
- IsKeyCursorRotationTrigger = bool Function(LogicalKeyboardKey key)
- See CursorKeyboardRotationOptions.isKeyTrigger
-
LayerHitNotifier<
R extends Object> = ValueNotifier< LayerHitResult< R> ?> -
flutter_map's
LayerHitNotifier: set when a tap, secondary tap or long press reaches the map (just beforeMapOptions.onTap/onSecondaryTap/onLongPressrun), to the hit elements of the layer or null. - LayerHitTester = void Function(MapCamera camera, LatLng position, Offset screenPoint)
- LongPressCallback = void Function(TapPosition tapPosition, LatLng point)
- MapErrorCallback = void Function(MapError error)
- MapEventCallback = void Function(MapEvent)
- MarkerTapHandler = void Function(String markerId)
- MoveAndRotateResult = ({bool moveSuccess, bool rotateSuccess})
- The result of MapController.moveAndRotate and MapController.rotateAroundPoint, as flutter_map's.
- NativeMarkerDragCallback = void Function(LatLng point)
- PointerCancelCallback = void Function(PointerCancelEvent event, LatLng point)
- PointerDownCallback = void Function(PointerDownEvent event, LatLng point)
- PointerHoverCallback = void Function(PointerHoverEvent event, LatLng point)
- PointerMoveCallback = void Function(PointerMoveEvent event, LatLng point)
- PointerUpCallback = void Function(PointerUpEvent event, LatLng point)
- PositionCallback = void Function(MapCamera camera, bool hasGesture)
- TapCallback = void Function(TapPosition tapPosition, LatLng point)
- TapPositionCallback = void Function(TapPosition position)
- TileBuilder = Widget Function(BuildContext context, Widget tileWidget, TileImage tile)
- Builder function that returns a TileBuilder instance.
-
TileUpdateTransformer
= StreamTransformer<
TileUpdateEvent, TileUpdateEvent> -
Restricts and limits TileUpdateEvents (which are emitted 'by'
MapEvents), which cause the tiles of theTileLayerto update (see below).
Exceptions / Errors
- CachedMapTileReadFailure
- Indicates that the tile with the given URL was present in the cache, but could not be correctly read