Skip to main content
usage

Base Widget

UnifiedMap is the entry widget — the same shape as flutter_map's FlutterMap, which is also exported under that name so an existing import compiles unchanged. It takes the options, an optional controller, and a list of children:

UnifiedMap(
  mapController: controller,
  options: MapOptions(initialCenter: brussels, initialZoom: 6),
  children: [
    TileLayer(urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', maxNativeZoom: 19),
    MarkerLayer(markers: markers),
    Positioned(right: 12, bottom: 12, child: CompassButton(controller: controller)),
  ],
)

On Android the children render into a Google Map, on iOS and macOS into a MapKit view, and on web, Windows, Linux and in tests into flutter_map — the same widget tree everywhere.

Configure the map​

MapOptions follows flutter_map field for field: initialCenter / initialZoom / initialRotation (or initialCameraFit to open on exactly what must be visible), minZoom / maxZoom, interactionOptions, and the callbacks (onTap, onLongPress, onPositionChanged, …). See Options.

Three fields are ours, on top of flutter_map's:

  • nativeParams — settings only the native SDKs have (base map style, traffic, the platform's user-location dot…), ignored by the flutter_map backend so the same code keeps its meaning there;
  • onMapLoaded / onMapError — the base map finished loading, or cannot be shown (missing API key, unavailable services), reported with the details.

Add some layers​

children mixes layer widgets — TileLayer, MarkerLayer, PolylineLayer, PolygonLayer, CircleLayer, OverlayImageLayer, and the layers of extension packages — with any other widget. Layers register their objects with the map; anything else is drawn above it in a Stack, in the same order. As in flutter_map, the order of children is the z-order. Each layer type has its own page in the Layers section.

When the platform cannot show the base map, UnifiedMap draws the widget returned by errorBuilder above everything (a MapErrorView by default — return SizedBox.shrink() to show nothing).