MapplsMapController class
Controller for a single MapplsMap instance running on the host platform.
Some of its methods can only be called after the onStyleLoaded
callback has been invoked.
To add annotations (Circles, Lines, Symbols and Fills) on the map, there are two ways:
- Simple way to add annotations: Use the corresponding add* methods (addCircle, addLine, addSymbol and addFill) on the MapLibreMapController to add one annotation at a time to the map. There are also corresponding addCircles, addLines etc. methods which work the same but add multiple annotations at a time.
(If you are interested how this works: under the hood, this uses AnnotationManagers to manage the annotations. An annotation manager performs the steps from the advanced way, but hides the complexity from the developer. E.g. the addCircle method uses the CircleManager, which in turn adds a GeoJson source to the map's style with the circle's locations as features. The CircleManager also adds a circle style layer to the map's style that references that GeoJson source, therefore rendering all circles added with addCircle on the map.)
There are also corresponding clear* methods like clearCircles to remove all circles from the map, which had been added with addCircle or addCircles.
There are also properties like circles to get the current set of circles on the map, which had been added with addCircle or addCircles.
Click events on annotations that are added this way (with the addCircle, addLine etc. methods) can be received by adding callbacks to onCircleTapped, onLineTapped etc.
Note: circles, clearCircles and onCircleTapped only work for circles added with addCircle or addCircles, not for circles that are already contained in the map's style when the map is loaded or are added to that map's style with the methods from the advanced way (see below). The same of course applies for fills, lines and symbols.
- Advanced way to add annotations: Modify the underlying MapLibre Style of the map to add a new data source (e.g. with the addSource method or the more specific methods like addGeoJsonSource)
and add a new layer to display the data of that source on the map (either with the addLayer method or with the more specific methods like addCircleLayer, addLineLayer etc.).
For more information about MapLibre Styles, see the documentation of
maplibre_gl
as well as the specification athttps://maplibre.org/maplibre-style-spec/
.
A MapLibreMapController is also a ChangeNotifier. Subscribers (change listeners) are notified upon changes to any of
- the configuration options of the
MapLibreMap
widget - the symbols, lines, circles or fills properties (i.e. the collection of Symbols, Lines, Circles and Fills added to this map via the "simple way" (see above))
- the isCameraMoving property
- the cameraPosition property
Listeners are notified after changes have been applied on the platform side.
- Inheritance
-
- Object
- ChangeNotifier
- MapplsMapController
Constructors
-
MapplsMapController.new({required MapplsGlPlatform mapplsGlPlatform, required CameraPosition initialCameraPosition, required Iterable<
AnnotationType> annotationOrder, required Iterable<AnnotationType> annotationConsumeTapEvents, OnStyleLoadedCallback? onStyleLoadedCallback, OnMapClickCallback? onMapClick, OnMapLongClickCallback? onMapLongClick, OnAttributionClickCallback? onAttributionClick, OnCameraTrackingDismissedCallback? onCameraTrackingDismissed, OnCameraTrackingChangedCallback? onCameraTrackingChanged, OnMapIdleCallback? onMapIdle, OnUserLocationUpdated? onUserLocationUpdated, OnCameraIdleCallback? onCameraIdle, OnGeoAnalyticsSelected? onGeoAnalyticsSelected})
Properties
- cameraPosition → CameraPosition?
-
Returns the most recent camera position reported by the platform side.
Will be null, if MapplsMap.trackCameraPosition is false.
no setter
-
circles
→ Set<
Circle> -
The current set of circles on this map added with the addCircle or addCircles methods.
no setter
-
fills
→ Set<
Fill> -
The current set of fills on this map added with the addFill or addFills methods.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isCameraMoving → bool
-
True if the map camera is currently moving.
no setter
-
lines
→ Set<
Line> -
The current set of lines on this map added with the addLine or addLines methods.
no setter
- onAttributionClick → OnAttributionClickCallback?
-
final
- onCameraIdle → OnCameraIdleCallback?
-
final
- onCameraTrackingChanged → OnCameraTrackingChangedCallback?
-
final
- onCameraTrackingDismissed → OnCameraTrackingDismissedCallback?
-
final
-
onCircleTapped
→ ArgumentCallbacks<
Circle> -
Callbacks to receive tap events for symbols placed on this map.
final
-
onFeatureDrag
→ List<
OnFeatureDragnCallback> -
final
-
onFeatureTapped
→ List<
OnFeatureInteractionCallback> -
Callbacks to receive tap events for features (geojson layer) placed on this map.
final
-
onFillTapped
→ ArgumentCallbacks<
Fill> -
Callbacks to receive tap events for fills placed on this map.
final
- onGeoAnalyticsSelected → OnGeoAnalyticsSelected?
-
final
-
onInfoWindowTapped
→ ArgumentCallbacks<
Symbol> -
Callbacks to receive tap events for info windows on symbols
final
-
onLineTapped
→ ArgumentCallbacks<
Line> -
Callbacks to receive tap events for lines placed on this map.
final
- onMapClick → OnMapClickCallback?
-
final
- onMapIdle → OnMapIdleCallback?
-
final
- onMapLongClick → OnMapLongClickCallback?
-
final
- onStyleLoadedCallback → OnStyleLoadedCallback?
-
final
-
onSymbolTapped
→ ArgumentCallbacks<
Symbol> -
Callbacks to receive tap events for symbols placed on this map.
final
- onUserLocationUpdated → OnUserLocationUpdated?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
symbols
→ Set<
Symbol> -
The current set of symbols on this map added with the addSymbol or addSymbols methods.
no setter
Methods
-
addCircle(
CircleOptions options, [Map? data]) → Future< Circle> -
Adds a circle to the map, configured using the specified custom
options
. -
addCircleLayer(
String sourceId, String layerId, CircleLayerProperties properties, {String? belowLayerId, String? sourceLayer, double? minzoom, double? maxzoom, dynamic filter, bool enableInteraction = true}) → Future< void> - Add a circle layer to the map with the given properties
-
addCircles(
List< CircleOptions> options, [List<Map> ? data]) → Future<List< Circle> > -
Adds multiple circles to the map, configured using the specified custom
options
. -
addCirclesFromJson(
String geoJson, [List< Map> ? data]) → Future<List< Circle> > -
addFill(
FillOptions options, [Map? data]) → Future< Fill> -
Adds a fill to the map, configured using the specified custom
options
. -
addFillExtrusionLayer(
String sourceId, String layerId, FillExtrusionLayerProperties properties, {String? belowLayerId, String? sourceLayer, double? minzoom, double? maxzoom, dynamic filter, bool enableInteraction = true}) → Future< void> - Add a fill extrusion layer to the map with the given properties
-
addFillLayer(
String sourceId, String layerId, FillLayerProperties properties, {String? belowLayerId, String? sourceLayer, double? minzoom, double? maxzoom, dynamic filter, bool enableInteraction = true}) → Future< void> - Add a fill layer to the map with the given properties
-
addFills(
List< FillOptions> options, [List<Map> ? data]) → Future<List< Fill> > -
Adds multiple fills to the map, configured using the specified custom
options
. -
addFillsFromJson(
String geoJson, [List< Map> ? data]) → Future<List< Fill> > -
addGeoJsonSource(
String sourceId, Map< String, dynamic> geojson, {String? promoteId}) → Future<void> - Adds a new geojson source
-
addHeatmapLayer(
String sourceId, String layerId, HeatmapLayerProperties properties, {String? belowLayerId, String? sourceLayer, double? minzoom, double? maxzoom}) → Future< void> - Add a heatmap layer to the map with the given properties
-
addHillshadeLayer(
String sourceId, String layerId, HillshadeLayerProperties properties, {String? belowLayerId, String? sourceLayer, double? minzoom, double? maxzoom}) → Future< void> - Add a hillshade layer to the map with the given properties
-
addImage(
String name, Uint8List bytes, [bool sdf = false]) → Future< void> - Adds an image to the style currently displayed in the map, so that it can later be referred to by the provided name.
-
addImageLayer(
String layerId, String imageSourceId, {double? minzoom, double? maxzoom}) → Future< void> - Adds an image layer to the map's style at render time.
-
addImageLayerBelow(
String layerId, String sourceId, String imageSourceId, {double? minzoom, double? maxzoom}) → Future< void> - Adds an image layer below the layer provided with belowLayerId to the map's style at render time.
-
addImageSource(
String imageSourceId, Uint8List bytes, LatLngQuad coordinates) → Future< void> - Adds an image source to the style currently displayed in the map, so that it can later be referred to by the provided id. Not implemented on web.
-
addLayer(
String sourceId, String layerId, LayerProperties properties, {String? belowLayerId, bool enableInteraction = true, String? sourceLayer, double? minzoom, double? maxzoom, dynamic filter}) → Future< void> - Add a layer to the map with the given properties
-
addLayerBelow(
String layerId, String sourceId, String imageSourceId, {double? minzoom, double? maxzoom}) → Future< void> - Adds an image layer below the layer provided with belowLayerId to the map's style at render time. Only works for image sources!
-
addLine(
LineOptions options, [Map? data]) → Future< Line> -
Adds a line to the map, configured using the specified custom
options
. -
addLineLayer(
String sourceId, String layerId, LineLayerProperties properties, {String? belowLayerId, String? sourceLayer, double? minzoom, double? maxzoom, dynamic filter, bool enableInteraction = true}) → Future< void> - Add a line layer to the map with the given properties
-
addLines(
List< LineOptions> options, [List<Map> ? data]) → Future<List< Line> > -
Adds multiple lines to the map, configured using the specified custom
options
. -
addLinesFromJson(
String geoJson, [List< Map> ? data]) → Future<List< Line> > -
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
addRasterLayer(
String sourceId, String layerId, RasterLayerProperties properties, {String? belowLayerId, String? sourceLayer, double? minzoom, double? maxzoom}) → Future< void> - Add a raster layer to the map with the given properties
-
addSource(
String sourceid, SourceProperties properties) → Future< void> - Add a new source to the map
-
addSymbol(
SymbolOptions options, [Map? data]) → Future< Symbol> -
Adds a symbol to the map, configured using the specified custom
options
. -
addSymbolLayer(
String sourceId, String layerId, SymbolLayerProperties properties, {String? belowLayerId, String? sourceLayer, double? minzoom, double? maxzoom, dynamic filter, bool enableInteraction = true}) → Future< void> - Add a symbol layer to the map with the given properties
-
addSymbols(
List< SymbolOptions> options, [List<Map> ? data]) → Future<List< Symbol> > -
Adds multiple symbols to the map, configured using the specified custom
options
. -
addSymbolsFromJson(
String json) → Future< List< Symbol> > -
animateCamera(
CameraUpdate cameraUpdate, {Duration? duration}) → Future< bool?> - Starts an animated change of the map camera position.
-
animateCameraWithMapplsPin(
CameraMapplsPinUpdate cameraUpdate) → Future< bool?> -
clearCircles(
) → Future< void> - Removes all circles from the map added with the addCircle or addCircles methods.
-
clearFills(
) → Future< void> - Removes all fills from the map added with the addFill or addFills methods.
-
clearLines(
) → Future< void> - Removes all lines from the map added with the addLine or addLines methods.
-
clearSymbols(
) → Future< void> - Removes all symbols from the map added with the addSymbol or addSymbols methods.
-
dispose(
) → void -
Discards any resources used by the object. After this is called, the
object is not in a usable state and should be discarded (calls to
addListener will throw after the object is disposed).
override
-
easeCamera(
CameraUpdate cameraUpdate) → Future< bool?> -
easeCameraWithMapplsPin(
CameraMapplsPinUpdate cameraUpdate) → Future< bool?> -
enableTraffic(
bool enable) → Future< void> -
enableTrafficClosure(
bool enable) → Future< void> -
enableTrafficFreeFlow(
bool enable) → Future< void> -
enableTrafficNonFreeFlow(
bool enable) → Future< void> -
enableTrafficStopIcon(
bool enable) → Future< void> -
forceResizeWebMap(
) → void - Triggers a hard map resize event on web and does not check if it is required or not.
-
getCircleLatLng(
Circle circle) → Future< LatLng> -
Retrieves the current position of the circle.
This may be different from the value of
circle.options.geometry
if the circle is draggable. In that case this method provides the circle's actual position, andcircle.options.geometry
the last programmatically set position. -
getFilter(
String layerId) → Future -
getLayerIds(
) → Future< List> -
getLineLatLngs(
Line line) → Future< List< LatLng> > -
Retrieves the current position of the line.
This may be different from the value of
line.options.geometry
if the line is draggable. In that case this method provides the line's actual position, andline.options.geometry
the last programmatically set position. -
getMapplsAvailableStyles(
) → Future< List< MapplsStyle> > -
getMapplsStyle(
) → Future< String> -
getMetersPerPixelAtLatitude(
double latitude) → Future< double> -
Returns the distance spanned by one pixel at the specified
latitude
and current zoom level. The distance between pixels decreases as the latitude approaches the poles. This relationship parallels the relationship between longitudinal coordinates at different latitudes. -
getSourceIds(
) → Future< List< String> > - Retrieve every source ids of the map as a String list, including the ones added internally
-
getSymbolLatLng(
Symbol symbol) → Future< LatLng> -
Retrieves the current position of the symbol.
This may be different from the value of
symbol.options.geometry
if the symbol is draggable. In that case this method provides the symbol's actual position, andsymbol.options.geometry
the last programmatically set position. -
getTelemetryEnabled(
) → Future< bool> - Retrieves whether collection of anonymized telemetry data is enabled.
-
getVisibleRegion(
) → Future< LatLngBounds> - This method returns the boundaries of the region currently displayed in the map.
-
invalidateAmbientCache(
) → Future -
isEnableTraffic(
) → Future< bool> -
isEnableTrafficClosure(
) → Future< bool> -
isEnableTrafficFreeFlow(
) → Future< bool> -
isEnableTrafficNonFreeFlow(
) → Future< bool> -
isEnableTrafficStopIcon(
) → Future< bool> -
matchMapLanguageWithDeviceDefault(
) → Future< void> - Updates the language of the map labels to match the device's language.
-
moveCamera(
CameraUpdate cameraUpdate) → Future< bool?> - Instantaneously re-position the camera. Note: moveCamera() quickly moves the camera, which can be visually jarring for a user. Strongly consider using the animateCamera() methods instead because it's less abrupt.
-
moveCameraWithMapplsPin(
CameraMapplsPinUpdate cameraUpdate) → Future< bool?> - Instantaneously re-position the camera. Note: moveCameraWithMapplsPin() quickly moves the camera, which can be visually jarring for a user. Strongly consider using the animateCameraWithMapplsPin() methods instead because it's less abrupt.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
queryRenderedFeatures(
Point< double> point, List<String> layerIds, List<Object> ? filter) → Future<List> - Query rendered (i.e. visible) features at a point in screen coordinates
-
queryRenderedFeaturesInRect(
Rect rect, List< String> layerIds, String? filter) → Future<List> - Query rendered (i.e. visible) features in a Rect in screen coordinates
-
querySourceFeatures(
String sourceId, String? sourceLayerId, List< Object> ? filter) → Future<List> -
Query features contained in the source with the specified
sourceId
. -
removeCircle(
Circle circle) → Future< void> -
Removes the specified
circle
from the map. The circle must be a current member of the circles set. -
removeCircles(
Iterable< Circle> circles) → Future<void> -
Removes the specified
circles
from the map. The circles must be current members of thecircles
set. -
removeFill(
Fill fill) → Future< void> -
Removes the specified
fill
from the map. The fill must be a current member of the fills set. -
removeFills(
Iterable< Fill> fills) → Future<void> -
Removes the specified
fills
from the map. The fills must be current members of thefills
set. -
removeGeoAnalytics(
{required MapplsGeoAnalyticsType type, required String geoboundType, String? attribute, required List< MapplsGeoAnalyticsRequest> geobound, required List<String> propertyNames, String? query, bool? transparent}) → Future<void> -
removeImageSource(
String imageSourceId) → Future< void> - Removes previously added image source by id
-
removeLayer(
String layerId) → Future< void> - Removes a Mappls style layer
-
removeLine(
Line line) → Future< void> -
Removes the specified
line
from the map. The line must be a current member of the lines set. -
removeLines(
Iterable< Line> lines) → Future<void> -
Removes the specified
lines
from the map. The lines must be current members of thelines
set. -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
removeSource(
String sourceId) → Future< void> - Removes previously added source by id
-
removeSymbol(
Symbol symbol) → Future< void> -
Removes the specified
symbol
from the map. The symbol must be a current member of the symbols set. -
removeSymbols(
Iterable< Symbol> symbols) → Future<void> -
Removes the specified
symbols
from the map. The symbols must be current members of thesymbols
set. -
requestMyLocationLatLng(
) → Future< LatLng?> - Get last my location
-
resizeWebMap(
) → void - Triggers a resize event for the map on web (ignored on Android or iOS).
-
setCameraBounds(
{required double west, required double north, required double south, required double east, required int padding}) → Future - Pans and zooms the map to contain its visible area within the specified geographical bounds.
-
setFilter(
String layerId, dynamic filter) → Future< void> -
setGeoJsonFeature(
String sourceId, Map< String, dynamic> geojsonFeature) → Future<void> - Sets new geojson data to and existing source
-
setGeoJsonSource(
String sourceId, Map< String, dynamic> geojson) → Future<void> - Sets new geojson data to and existing source
-
setLayerProperties(
String layerId, LayerProperties properties) → Future< void> - Set one or multiple properties of a layer. You can only use properties that are supported for the layer's type. So you can e.g. only use LineLayerProperties on a line layer.
-
setLayerVisibility(
String layerId, bool visible) → Future< void> -
setMapLanguage(
String language) → Future< void> -
Updates the language of the map labels to match the specified language.
This will use labels with "name:$language" if available, otherwise "name:latin" or "name".
This naming schema is used by OpenStreetMap (see
https://wiki.openstreetmap.org/wiki/Multilingual_names
), and is also used by some other vector tile generation software and vector tile providers. Commonly, (and according to the OSM wiki)language
should be "a lowercase language's ISO 639-1 alpha2 code (second column), a lowercase ISO 639-2 code if an ISO 639-1 code doesn't exist, or a ISO 639-3 code if neither of those exist". -
setSymbolIconAllowOverlap(
bool enable) → Future< void> - If true, the icon will be visible even if it collides with other previously drawn symbols.
-
setSymbolIconIgnorePlacement(
bool enable) → Future< void> - If true, other symbols can be visible even if they collide with the icon.
-
setSymbolTextAllowOverlap(
bool enable) → Future< void> - If true, the text will be visible even if it collides with other previously drawn symbols.
-
setSymbolTextIgnorePlacement(
bool enable) → Future< void> - If true, other symbols can be visible even if they collide with the text.
-
setTelemetryEnabled(
bool enabled) → Future< void> - Enables or disables the collection of anonymized telemetry data.
-
showGeoAnalytics(
{required MapplsGeoAnalyticsType type, required String geoboundType, String? attribute, required List< MapplsGeoAnalyticsRequest> geobound, required List<String> propertyNames, String? query, bool? transparent}) → Future<void> -
toLatLng(
Point< num> screenLocation) → Future<LatLng> - Returns the geographic location (as LatLng) that corresponds to a point on the screen. The screen location is specified in screen pixels (not display pixels) relative to the top left of the map (not the top left of the whole screen).
-
toScreenLocation(
LatLng latLng) → Future< Point< num> > -
Returns the point on the screen that corresponds to a geographical coordinate (
latLng
). The screen location is in screen pixels (not display pixels) relative to the top left of the map (not of the whole screen) -
toScreenLocationBatch(
Iterable< LatLng> latLngs) → Future<List< Point< >num> > -
toString(
) → String -
A string representation of this object.
inherited
-
updateCircle(
Circle circle, CircleOptions changes) → Future< void> -
Updates the specified
circle
with the givenchanges
. The circle must be a current member of the circles set. -
updateContentInsets(
EdgeInsets insets, [bool animated = false]) → Future< void> - Updates the distance from the edges of the map view’s frame to the edges of the map view’s logical viewport, optionally animating the change.
-
updateFill(
Fill fill, FillOptions changes) → Future< void> -
Updates the specified
fill
with the givenchanges
. The fill must be a current member of the fills set. -
updateImageSource(
String imageSourceId, Uint8List? bytes, LatLngQuad? coordinates) → Future< void> - Update the image and/or coordinates of an image source. Not implemented on web.
-
updateLine(
Line line, LineOptions changes) → Future< void> -
Updates the specified
line
with the givenchanges
. The line must be a current member of the lines set.‚ -
updateMyLocationTrackingMode(
MyLocationTrackingMode myLocationTrackingMode) → Future< void> - Updates user location tracking mode.
-
updateSymbol(
Symbol symbol, SymbolOptions changes) → Future< void> -
Updates the specified
symbol
with the givenchanges
. The symbol must be a current member of the symbols set.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited