MapScene class abstract

Represents a map scene and exposes the functionality to manipulate its content.

Map schemes

The content of the displayed map and how it looks is specified by a MapScheme which is set when loading a scene with MapScene.loadSceneForMapScheme. It is also possible to load your own custom map scheme from a file bundled with your application. Supported file formats are:

  • JSON (file extension '.json'; e.g. 'my_custom_style.json')
  • ZIP archive (file extension '.zip'; e.g. 'my_custom_style.zip'), with the following archive structure:
    • root folder: any, not empty (e.g. 'my_custom_style')
    • JSON configuration: '/style.json'
    • custom assets folder: '/assets'

Map features

Different map schemes offer different sets of features, for example showing traffic or 3D buildings. Some features have multiple modes of operation, but most have only one. MapScene.getSupportedFeatures can be used to check what features and modes are supported for the current scene. Features can be enabled using MapScene.enableFeatures and disabled with MapScene.disableFeatures. Checking which features are currently enabled can be done using MapScene.getActiveFeatures. For convenience, MapFeatures and MapFeatureModes hold constants for feature and mode names.

Since version 4.15.0, map features cannot be controlled using MapScene.setLayerVisibility, since MapScene.setLayerVisibility controls only visibility of the layers which are corresponding to the features enabled either by MapScene.enableFeatures or enabled by default for the scene.

Map layers

A map scheme is organized in layers, which can be controlled using MapScene.setLayerVisibility. It's possible to change the visibility state of any map layer as long as the name is known.

Layer visibility settings persist between scene reloading.

User content

User generated content can be visualised on the map using MapPolyline, MapPolygon, MapMarker, MapMarkerCluster, MapArrow, MapMarker3D and MapImageOverlay (collectively referred to as "map items"). Those can be added to and removed from the scene by respective add and remove methods. The render order of the map items is according to the list above. The order of objects within the same type can be controlled using the drawOrder property of each object.

Be careful when adding a very large number of map items as this can have a negative impact on the performance of the app. To work around this limitation the following approach can be used: Register to map camera updates using MapCamera.addListener. Query the bounding box of the camera viewport using MapCamera.boundingBox (it may be extended) and then use the method GeoBox.containsGeoCoordinates in combination with MapCameraState.distanceToTargetInMeters to determine which map items are actually visible to the user in the current camera viewport and thus need to be added to the map.

Constructors

MapScene()

Properties

hashCode → int
The hash code for this object.
no setterinherited
lights MapSceneLights
Controls lights present in the scene. Provides access to a MapSceneLights instance that controls the lights in the scene.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addMapArrow(MapArrow mapArrow) → void
Adds a map arrow to this map scene.
addMapImageOverlay(MapImageOverlay overlay) → void
Adds a map image overlay to this map scene.
addMapMarker(MapMarker marker) → void
Adds a map marker to this map scene.
addMapMarker3d(MapMarker3D marker) → void
Adds a 3D map marker to this map scene.
addMapMarkerCluster(MapMarkerCluster cluster) → void
Adds a map marker cluster to the map.
addMapMarkers(List<MapMarker> markers) → void
Adds multiple map markers to this map scene.
addMapMarkers3d(List<MapMarker3D> markers) → void
Adds multiple 3D map markers to this map scene.
addMapPolygon(MapPolygon mapPolygon) → void
Adds a map polygon to this map scene.
addMapPolygons(List<MapPolygon> mapPolygons) → void
Adds multiple map polygons to this map scene.
addMapPolyline(MapPolyline mapPolyline) → void
Adds a map polyline to this map scene.
addMapPolylines(List<MapPolyline> mapPolylines) → void
Adds map polylines to this map scene.
disableFeatures(List<String> features) → void
Disables specified map features.
enableFeatures(Map<String, String> features) → void
Enables specified map features.
getActiveFeatures() → Map<String, String>
Gets map features that are currently active.
getSupportedFeatures() → Map<String, List<String>>
Gets features and all of their modes supported by the currently loaded scene configuration.
loadScene(MapSceneLoadOptions options, MapSceneLoadSceneCallback? callback) → void
Asynchronously loads a map scene using MapSceneLoadOptions.
loadSceneForMapScheme(MapScheme mapScheme, MapSceneLoadSceneCallback? callback) → void
Asynchronously loads a map scene described by a specified map scheme.
loadSceneFromConfigurationFile(String configurationFile, MapSceneLoadSceneCallback? callback) → void
Asynchronously loads a map scene described by a specified file in one of the supported formats.
loadSceneFromConfigurationFileWithWatermarkStyle(String configurationFile, WatermarkStyle watermarkStyle, MapSceneLoadSceneCallback? callback) → void
Asynchronously loads a map scene described by a specified file in one of the supported formats.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reloadScene() → void
Asynchronously reloads the current map scene from file.
removeAllMapMarkers() → void
Removes all map markers from this map scene.
removeAllMapMarkers3d() → void
Removes all 3D map markers from this map scene.
removeAllMapPolygons() → void
Removes all map polygons from this map scene.
removeAllMapPolylines() → void
Removes all map polylines from this map scene.
removeMapArrow(MapArrow mapArrow) → void
Removes a map arrow from this map scene.
removeMapImageOverlay(MapImageOverlay overlay) → void
Removes a map image overlay from this map scene.
removeMapMarker(MapMarker marker) → void
Removes a map marker from this map scene.
removeMapMarker3d(MapMarker3D marker) → void
Removes a 3D map marker from this map scene.
removeMapMarkerCluster(MapMarkerCluster cluster) → void
Removes a map marker cluster from the map.
removeMapMarkers(List<MapMarker> markers) → void
Removes multiple map markers from this map scene.
removeMapMarkers3d(List<MapMarker3D> markers) → void
Removes multiple 3D map markers from this map scene.
removeMapPolygon(MapPolygon mapPolygon) → void
Removes a map polygon from this map scene.
removeMapPolygons(List<MapPolygon> mapPolygons) → void
Removes multiple map polygon from this map scene.
removeMapPolyline(MapPolyline mapPolyline) → void
Removes a map polyline from this map scene.
removeMapPolylines(List<MapPolyline> mapPolylines) → void
Removes map polylines from this map scene.
setLayerVisibility(String layerName, VisibilityState visibility) → void
Immediately changes the visibility of a specified map layer.
toString() → String
A string representation of this object.
inherited

Operators

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