PowerMapController class

Controller for a PowerMap widget.

Provides a unified API facade to manipulate the map, add markers, calculate routes, control the camera, and utilize MapLibreGL functionality.

Constructors

PowerMapController(MapLibreMapController mapController, {GeocodingProvider? geocodingProvider})
Creates a PowerMapController for the given mapController.

Properties

cameraPosition CameraPosition?
Returns the most reliable current camera position.
no setter
clusters ClusterManager
latefinal
geometry GeometryManager
latefinal
hashCode int
The hash code for this object.
no setterinherited
indoor IndoorManager
latefinal
layers LayerManager
latefinal
mapController MapLibreMapController
final
markers MarkerManager
latefinal
routing RoutingManager
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
searchAPI SearchManager
latefinal
tracking TrackingManager
latefinal

Methods

addGeoJson(String sourceId, Map<String, dynamic> geoJson) Future<void>
Adds a GeoJSON source to the map.
addIndoorExtrusionLayer(String sourceId, {String layerId = 'pm-indoor-3d', dynamic fillColor = '#4f46e5', dynamic filter}) Future<void>
Renders a 3D extrusion layer (e.g., for indoor buildings) from GeoJSON data.
addMarker(LatLng position, {String? color, String? iconImage, double size = 1.0, Map<String, dynamic>? data, double opacity = 1.0, double? iconRotate, String? iconAnchor}) Future
Adds a customizable marker at the given position on the map.
addPolygonLayer(String sourceId, {String layerId = 'pm-polygon-layer', dynamic fillColor = '#FF0000', dynamic fillOpacity = 0.5, dynamic outlineColor, dynamic filter}) Future<void>
Renders a polygon layer from the provided GeoJSON source.
addPolylineLayer(String sourceId, {String layerId = 'pm-polyline-layer', dynamic lineColor = '#0000FF', dynamic lineWidth = 3.0, dynamic lineOpacity = 1.0, dynamic filter}) Future<void>
Renders a polyline layer from the provided GeoJSON source.
addRoute({required LatLng start, required LatLng destination, List<LatLng>? waypoints, bool optimize = false, String profile = 'driving', String language = 'th', bool fitCamera = true}) Future<PowerMapRouteResult?>
Calculates and draws a route on the map matching the Web SDK format.
addSymbolLayer(String sourceId, {String layerId = 'pm-symbol-layer', dynamic iconImage, dynamic textField, dynamic textColor = '#000000', dynamic filter}) Future<void>
Renders a symbol layer (icons/text) from the provided GeoJSON source.
addWidgetMarker(LatLng position, Widget widget, {String? id, Alignment alignment = Alignment.center}) → void
Adds a custom Flutter widget as a marker at the given position.
autocompleteDebounced(String query, Duration delay, dynamic onResult(List<PowerMapSearchResult>), {LatLng? location, String lang = 'auto'}) → void
Debounced autocomplete for search-as-you-type.
clearClusters() Future<void>
Clears all clustered markers.
clearGeometry() Future<void>
Removes all geometries added via the GeometryManager.
clearMarkers() Future<void>
Clears all markers from the map.
clearRoutes() Future<void>
Clears any drawn routes.
clearSearchCache() → void
Clears internal search cache.
clearWidgetMarkers() → void
Clears all widget-based markers.
disableFollowMode() Future<void>
Unlocks camera so user can drag freely again.
disposeTracking() → void
Clean up tracking resources.
enableFollowMode() Future<void>
Locks camera smoothly on device location.
enableFollowModeWithCompass() Future<void>
Locks camera and rotates map to match device heading (compass).
ensureLayer(String layerId) Future<void>
Downloads and prepares a custom layer but keeps it hidden.
exportGeometry([String? id, Map<String, dynamic>? options]) Future<Map<String, dynamic>?>
Exports current geometry data to GeoJSON. (Alias for getGeoJSON)
getBearing() double?
Returns the current bearing (rotation) of the map in degrees.
getCatalog() List<PowerMapLayerGroup>
Get the full catalog of available map layers.
getCenter() LatLng?
Returns the current center coordinates of the map.
getCurrentLocation() Future<LatLng?>
Returns the current device position as a one-shot request.
getGeoJSON([String? id, Map<String, dynamic>? options]) Future<Map<String, dynamic>?>
Retrieve geometry data in GeoJSON format.
getLayerState(String layerId) Map<String, dynamic>
Get the current loaded/visible state of a specific layer.
getTilt() double?
Returns the current tilt (pitch) of the map in degrees.
getZoom() double?
Returns the current zoom level of the map.
hideLayer(String layerId) Future<void>
Hides a specific map layer.
hideLayerGroup(String groupKey) Future<void>
Hides an entire group of layers.
importGeoJson(String sourceId, Map<String, dynamic> geoJson, {bool autoRender = true, Map<String, dynamic>? options}) Future<void>
Imports GeoJSON and optionally renders it automatically.
moveCamera(LatLng target, {double? zoom, double? tilt, double? bearing}) Future<void>
Moves the camera with smooth animation.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeGeometry(String sourceId) Future<void>
Removes a geometry layer and its corresponding source.
requestPermission() Future<bool>
Checks and requests location permission. Returns true if permission is granted.
reverseGeocode(LatLng location, {String lang = 'auto'}) Future<PowerMapSearchResult?>
Reverse geocode coordinates to an address.
Searches for places matching the query.
searchByCategory(String categoryId, LatLng location, {int dist = 5, String lang = 'auto'}) Future<List<PowerMapSearchResult>>
Searches for places nearby by category ID.
setBearing(double bearing) Future<void>
Sets the map's bearing (rotation) in degrees.
setClusters(List<LatLng> points) Future<void>
Sets high-performance clustered markers.
setMarkersOpacity(double opacity) Future<void>
Sets the opacity of all currently visible native markers (GL Circles and Symbols) to opacity in a single bulk call — ideal for fade-in/fade-out animations.
setOpacity(String id, double opacity) Future<void>
Sets the opacity of a layer or geometry source (0.0 to 1.0). This provides a unified API matching the Web SDK.
setStyle(String style) Future<void>
Changes the map's visual style.
setTilt(double tilt) Future<void>
Sets the map's tilt (bearing) in degrees.
showLayer(String layerId) Future<void>
Ensures and shows a specific map layer.
showLayerGroup(String groupKey) Future<void>
Shows an entire group of layers (e.g., 'city', 'transport').
showUserLocation(bool enabled) Future<void>
Enables or disables the visual user location indicator (blue puck with compass).
tiltDown() Future<void>
switches to a 2D top-down view (tilt 0 degrees).
tiltUp() Future<void>
Switches to a 3D perspective view (tilt ~60 degrees).
toggleLayer(String layerId) Future<void>
Toggles visibility of a specific map layer.
toString() String
A string representation of this object.
inherited
updateGeoJson(String sourceId, Map<String, dynamic> geoJson) Future<void>
Refreshes/updates the GeoJSON data for an existing source.
zoomIn() Future<void>
Increments the current zoom level by 1.0.
zoomOut() Future<void>
Decrements the current zoom level by 1.0.

Operators

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