logo Huawei MAP Kit Flutter Plugin


Contents


1. Introduction

Huawei Map Kit, provides standard maps as well as UI elements such as markers, shapes, and layers for you to customize maps that better meet service scenarios. Enables users to interact with a map in your app through gestures and buttons in different scenarios.

Huawei Map Kit provides the following core capabilities:

  • Huawei Map: Core map component with tons of features.
  • My Location: Your location on the map.
  • Markers: Adding markers on the map with tons of modifications with their InfoWindow component.
  • Polylines: Adding polylines on the map with tons of modifications.
  • Polygons: Adding polygons on the map with tons of modifications.
  • Circles: Adding circles on the map with tons of modifications.
  • Ground Overlays: Adding ground overlays on the map with tons of modifications.
  • Tile Overlays: Adding tile overlays on the map with tons of modifications.

This plugin enables communication between HUAWEI MAP Kit SDK and Flutter platform. It exposes all functionality provided by HUAWEI MAP Kit SDK.


2. Installation Guide

  • Before you get started, you must register as a HUAWEI developer and complete identity verification on the HUAWEI Developer website. For details, please refer to Register a HUAWEI ID.

  • Create an app in your project is required in AppGallery Connect in order to communicate with Huawei services. To create an app, perform the following steps:

Step 1. Sign in to AppGallery Connect and select My projects.

Step 2. Click your project from the project list.

Step 3. Go to Project Setting > General information, and click Add app. If an app exists in the project, and you need to add a new one, expand the app selection area on the top of the page and click Add app.

Step 4. On the Add app page, enter app information, and click OK.

  • A signing certificate fingerprint is used to verify the authenticity of an app when it attempts to access an HMS Core service through the HMS Core SDK. Before using HMS Core (APK), you must locally generate a signing certificate fingerprint and configure it in AppGallery Connect. Ensure that the JDK has been installed on your computer.

  • To use HUAWEI Map, you need to enable the Map service first. For details, please refer to Enabling Services.

Configuring the Signing Certificate Fingerprint

Step 1: Go to Project Setting > General information. In the App information field, click the icon next to SHA-256 certificate fingerprint, and enter the obtained SHA256 certificate fingerprint.

Step 2: After completing the configuration, click check mark.

Integrating Flutter Map Plugin

Step 1: Sign in to AppGallery Connect and select My projects.

Step 2: Find your app project, and click the desired app name.

Step 3: Go to Project Setting > General information. In the App information section, click agconnect-services.json to download the configuration file.

Step 4: Create a Flutter project if you do not have one.

Step 5: Copy the agconnect-service.json file to the android/app directory of your Flutter project.

Step 6: Copy the signature file that generated in Generating a Signing Certificate section, to the android/app directory of your Flutter project.

Step 7: Check whether the agconnect-services.json file and signature file are successfully added to the android/app directory of the Flutter project.

Step 8: Open the build.gradle file in the android directory of your Flutter project.

  • Go to buildscript then configure the Maven repository address and agconnect plugin for the HMS SDK.

        buildscript {
            repositories {
                google()
                jcenter()
                maven { url 'https://developer.huawei.com/repo/' }
            }
    
            dependencies {
                /*
                 * <Other dependencies>
                 */
                classpath 'com.huawei.agconnect:agcp:1.4.1.300'
            }
        }
    
  • Go to allprojects then configure the Maven repository address for the HMS SDK.

        allprojects {
            repositories {
                google()
                jcenter()
                maven { url 'https://developer.huawei.com/repo/' }
            }
        }
    

Step 9: Open the build.gradle file in the android/app directory.

  • Add apply plugin: 'com.huawei.agconnect' line after the apply entries.

        apply plugin: 'com.android.application'
        apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
        apply plugin: 'com.huawei.agconnect'
    
  • Set your package name in defaultConfig > applicationId and set minSdkVersion to 19 or higher.

  • Package name must match with the package_name entry in agconnect-services.json file.

        defaultConfig {
                applicationId "<package_name>"
                minSdkVersion 19
                /*
                 * <Other configurations>
                 */
            }
    
  • Copy the signature file that generated in Generating a Signing Certificate to android/app directory.

  • Configure the signature in android according to the signature file information and configure Obfuscation Scripts.

        android {
            /*
             * <Other configurations>
             */
    
            signingConfigs {
                config {
                    storeFile file('<keystore_file>.jks')
                    storePassword '<keystore_password>'
                    keyAlias '<key_alias>'
                    keyPassword '<key_password>'
                }
            }
    
            buildTypes {
                debug {
                    signingConfig signingConfigs.config
                }
                release {
                    minifyEnabled true
                    shrinkResources true
                    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
                    signingConfig signingConfigs.config
                }
            }
        }
    
  • For Obfuscation Scripts, please refer to Configuring Obfuscation Scripts.

Step 10: On your Flutter project directory find and open your pubspec.yaml file and add library to dependencies.

  • To download the package from pub.dev.

    dependencies:
      huawei_map: { library version }
    

    or

    If you downloaded the package from the HUAWEI Developer website, specify the library path on your local device.

    dependencies:
      huawei_map:
        # Replace {library path} with actual library path of Huawei Map Plugin for Flutter.
        path: { library path }
    
    • Replace {library path} with the actual library path of Flutter Map Plugin. The following are examples:
      • Relative path example: path: ../huawei_map
      • Absolute path example: path: D:\Projects\Libraries\huawei_map

Step 11: Run following command to update package info.

  [project_path]> flutter pub get

Step 12: Run following command to start the app.

  [project_path]> flutter run

3. API Reference

HuaweiMap

A Stateful Widget which displays a map with data obtained from the Huawei Map service.

Public Properties

NameTypeDescription
keyKeyKey.
initialCameraPositionCameraPositionSpecifies the initial camera position for a map.
compassEnabledboolSets whether to enable the compass for a map.
mapToolbarEnabledboolSets whether to enable toolbar for a map.
cameraTargetBoundsCameraTargetBoundsSets a LatLngBounds object to constrain the camera target so that the camera target does not move outside the bounds when a user scrolls the map.
mapTypeMapTypeSets the map type.
minMaxZoomPreferenceMinMaxZoomPreferenceSets the preferred minimum and maximum zoom level of the camera.
rotateGesturesEnabledboolSpecifies whether to enable rotate gestures for a map.
scrollGesturesEnabledboolSets whether to enable scroll gestures for a map.
zoomControlsEnabledboolSpecifies whether to enable the zoom function for the camera.
zoomGesturesEnabledboolSets whether to enable zoom gestures for a map.
tiltGesturesEnabledboolSets whether to enable tilt gestures for a map.
paddingEdgeInsetsSets padding on a map.
markersSet<Marker>Adds markers to a map. The marker icon is displayed at the specified position on the map.
polygonsSet<Polygon>Adds polygons to a map.
polylinesSet<Polyline>Adds polylines to a map.
circlesSet<Circle>Adds circles to a map. The longitude and latitude of the center and the radius are specified for the circle to indicate the surrounding area of a location.
groundOverlaysSet<GroundOverlay>Adds images to a map.
tileOverlaysSet<TileOverlay>Adds tile overlays to a map.
myLocationEnabledboolSets whether to enable the my-location layer. If the my-location layer is enabled and the location is available, the layer constantly draws the user's current location and bearing and displays the UI controls for the user to interact with their location. To use the my-location layer function, you must apply for the ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permissions.
myLocationButtonEnabledboolSets whether to enable the my-location icon for a map.
trafficEnabledboolSets whether to enable the traffic status layer.
buildingsEnabledboolSets whether to enable the 3D building layer.
markersClusteringEnabledboolSets whether a marker can be clustered.
onMapCreatedMapCreatedCallbackFunction to be called when a map is created.
onCameraMoveStartedVoidCallbackFunction to be called when a camera move started.
onCameraMoveCameraPositionCallbackFunction to be called when a camera moved.
onCameraIdleVoidCallbackFunction to be called when a camera is idle.
onClickArgumentCallback<LatLng>Function to be called when map is clicked.
onLongPressArgumentCallback<LatLng>Function to be called when a map is long clicked.
gestureRecognizersSet<Factory<OneSequenceGestureRecognizers>>Gesture recognizers.

Public Constructor Summary

ConstructorDescription
HuaweiMap({Key key, CameraPosition initialCameraPosition, MapType mapType, Set<Factory<OneSequenceGestureRecognizers>> gestureRecognizers, bool compassEnabled, bool mapToolbarEnabled, CameraTargetBounds cameraTargetBounds, MinMaxZoomPreference minMaxZoomPreference, bool rotateGesturesEnabled, bool scrollGesturesEnabled, bool zoomControlsEnabled, bool zoomGesturesEnabled, bool tiltGesturesEnabled, bool myLocationEnabled, bool myLocationButtonEnabled, EdgeInsets padding, bool trafficEnabled, bool markersClusteringEnabled, bool buildingsEnabled, Set<Marker> markers, Set<Polygon> polygons, Set<Polyline> polylines, Set<Circle> circles, Set<GroundOverlay> groundOverlays, Set<TileOverlay> tileOverlays, MapCreatedCallback onMapCreated, VoidCallback onCameraMoveStarted, CameraPositionCallback onCameraMove, VoidCallback onCameraIdle, ArgumentCallback<LatLng> onClick, ArgumentCallback<LatLng> onLongPress})Default constructor.

Public Constructors

HuaweiMap

Constructor for HuaweiMap widget.

ParameterTypeDescription
keyKeyKey.
initialCameraPositionCameraPositionSpecifies the initial camera position for a map.
compassEnabledboolSets whether to enable the compass for a map.
mapToolbarEnabledboolSets whether to enable toolbar for a map.
cameraTargetBoundsCameraTargetBoundsSets a LatLngBounds object to constrain the camera target so that the camera target does not move outside the bounds when a user scrolls the map.
mapTypeMapTypeSets the map type.
minMaxZoomPreferenceMinMaxZoomPreferenceSets the preferred minimum and maximum zoom level of the camera.
rotateGesturesEnabledboolSpecifies whether to enable rotate gestures for a map.
scrollGesturesEnabledboolSets whether to enable scroll gestures for a map.
zoomControlsEnabledboolSpecifies whether to enable the zoom function for the camera.
zoomGesturesEnabledboolSets whether to enable zoom gestures for a map.
tiltGesturesEnabledboolSets whether to enable tilt gestures for a map.
paddingEdgeInsetsSets padding on a map.
markersSet<Marker>Adds markers to a map. The marker icon is displayed at the specified position on the map.
polygonsSet<Polygon>Adds polygons to a map.
polylinesSet<Polyline>Adds polylines to a map.
circlesSet<Circle>Adds circles to a map. The longitude and latitude of the center and the radius are specified for the circle to indicate the surrounding area of a location.
groundOverlaysSet<GroundOverlay>Adds images to a map.
tileOverlaysSet<TileOverlay>Adds tile overlays to a map.
myLocationEnabledboolSets whether to enable the my-location layer. If the my-location layer is enabled and the location is available, the layer constantly draws the user's current location and bearing and displays the UI controls for the user to interact with their location. To use the my-location layer function, you must apply for the ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission unless you have set a custom location source.
myLocationButtonEnabledboolSets whether to enable the my-location icon for a map.
trafficEnabledboolSets whether to enable the traffic status layer.
buildingsEnabledboolSets whether to enable the 3D building layer.
markersClusteringEnabledboolSets whether a marker can be clustered.
onMapCreatedMapCreatedCallbackFunction to be called when a map is created.
onCameraMoveStartedVoidCallbackFunction to be called when a camera move started.
onCameraMoveCameraPositionCallbackFunction to be called when a camera moved.
onCameraIdleVoidCallbackFunction to be called when a camera is idle.
onClickArgumentCallback<LatLng>Function to be called when map is clicked.
onLongPressArgumentCallback<LatLng>Function to be called when a map is long clicked.
gestureRecognizersSet<Factory<OneSequenceGestureRecognizers>>Gesture recognizers.

HuaweiMapUtils

Entry class for Huawei Map Utilities.

Public Method Summary

MethodReturn TypeDescription
disableLogger()Future<void>Disables HMS Logger.
enableLogger()Future<void>Enables HMS Logger.
distanceCalculator(LatLng start, LatLng end)Future<double>Method used to calculate the distance between two coordinate points.

Public Methods

Future<void> disableLogger() async

This method disables the HMSLogger capability which is used for sending usage analytics of Map SDK's methods to improve the service quality. Asynchronous.

Return Type
TypeDescription
Future<void>Future result of an execution that returns no value.
Call Example
//Call disableLogger API.
await HuaweiMapUtils.disableLogger();
Future<void> enableLogger() async

This method enables the HMSLogger capability which is used for sending usage analytics of Map SDK's methods to improve the service quality. Asynchronous.

Return Type
TypeDescription
Future<void>Future result of an execution that return no value.
Call Example
//Call enableLogger API.
await HuaweiMapUtils.enableLogger();
Future<double> distanceCalculator(LatLng start, LatLng end) async

Method used to calculate the distance between two coordinate points. Asynchronous.

Parameters
NameDescription
startStart coordinate point.
endEnd coordinate point.
Return Type
TypeDescription
Future<double>Distance between the specified two coordinate points, in meters.
Call Example
//Call distanceCalculator API. 
double result = await HuaweiMapUtils.distanceCalculator(
	start: LatLng(41.048641, 28.977033),
    end: LatLng(41.063984, 29.033135),
);

HuaweiMapController

Map controller for Huawei Map.

Public Method Summary

MethodReturn TypeDescription
clearTileCache(TileOverlay tileOverlay)Future<void>Clears the cache of a tile overlay.
startAnimationOnMarker(Marker marker)Future<void>Starts the animation of a marker.
animateCamera(CameraUpdate cameraUpdate)Future<void>Updates the camera position in animation mode.
moveCamera(CameraUpdate cameraUpdate)Future<void>Updates the camera position. The movement is instantaneous.
setMapStyle(String mapStyle)Future<void>Sets the map style.
getVisibleRegion()Future<LatLngBounds>Obtains the visible region after conversion between the screen coordinates and longitude/latitude coordinates.
getScreenCoordinate(LatLng latLng)Future<ScreenCoordinate>Obtains a location on the screen corresponding to the specified longitude/latitude coordinates. The location on the screen is specified in screen pixels (instead of display pixels) relative to the top left corner of the map (instead of the top left corner of the screen).
getLatLng(ScreenCoordinate screenCoordinate)Future<LatLng>Obtains the longitude and latitude of a location on the screen. The location on the screen is specified in screen pixels (instead of display pixels) relative to the top left corner of the map (instead of the top left corner of the screen).
showMarkerInfoWindow(MarkerId markerId)Future<void>Displays the information window for a marker.
hideMarkerInfoWindow(MarkerId markerId)Future<void>Hides the information window that is displayed for a marker. This method is invalid for invisible markers.
isMarkerInfoWindowShown(MarkerId markerId)Future<bool>Checks whether an information window is currently displayed for a marker. This method will not consider whether the information window is actually visible on the screen.
isMarkerClusterable(MarkerId markerId)Future<bool>Checks whether a marker can be clustered.
getZoomLevel()Future<double>Obtains zoom level of a map.
takeSnapshot()Future<Uint8List>Takes a snapshot of a map.

Public Methods

Future<void> clearTileCache(TileOverlay tileOverlay) async

Clears the cache of a tile overlay. Asynchronous.

Parameter
NameDescription
tileOverlayTile overlay object.
Return Type
TypeDescription
Future<void>Future result of an execution that returns no value.
Call Example:
//Define HuaweiMapController and TileOverlay.
HuaweiMapController mapController;
TileOverlay tileOverlay;

//Call clearTileCache API.
await mapController.clearTileCache(tileOverlay);
Future<void> startAnimationOnMarker(Marker marker) async

Starts the animation of a marker. Asynchronous.

Parameter
NameDescription
markerMarker object.
Return Type
TypeDescription
Future<void>Future result of an execution that returns no value.
Call Example:
//Define HuaweiMapController and a Marker with an Animation.
HuaweiMapController mapController;
Marker marker;

//Call startAnimationOnMarker API.
await mapController.startAnimationOnMarker(marker);
Future<void> animateCamera(CameraUpdate cameraUpdate) async

Updates the camera position in animation mode. Asynchronous.

Parameter
NameDescription
cameraUpdateCamera position change.
Return Type
TypeDescription
Future<void>Future result of an execution that returns no value.
Call Example:
//Define HuaweiMapController and a CameraUpdate object.
HuaweiMapController mapController;
CameraUpdate cameraUpdate;

//Call animateCamera API.
await mapController.animateCamera(cameraUpdate);
Future<void> moveCamera(CameraUpdate cameraUpdate) async

Updates the camera position. The movement is instantaneous. Asynchronous.

Parameter
NameDescription
cameraUpdateCamera position change.
Return Type
TypeDescription
Future<void>Future result of an execution that returns no value.
Call Example:
//Define HuaweiMapController and a CameraUpdate object.
HuaweiMapController mapController;
CameraUpdate cameraUpdate;

//Call moveCamera API.
await mapController.moveCamera(cameraUpdate);
Future<void> setMapStyle(String mapStyle) async

Sets the map style. Asynchronous.

Parameter
NameDescription
mapStyleMap style as a JSON String.
Return Type
TypeDescription
Future<void>Future result of an execution that returns no value.
Call Example:
//Define HuaweiMapController.
HuaweiMapController mapController;

//Call setMapStyle API.
await mapController.setMapStyle("YOUR_MAP_STYLE_AS_JSON");
Future<LatLngBounds> getVisibleRegion() async

Obtains the visible region after conversion between the screen coordinates and longitude/latitude coordinates. Asynchronous.

Return Type
TypeDescription
Future<LatLngBounds>Smallest bounding box that includes the visible region.
Call Example:
//Define HuaweiMapController.
HuaweiMapController mapController;

//Call getVisibleRegion API.
LatLngBounds bounds = await mapController.getVisibleRegion();
Future<ScreenCoordinate> getScreenCoordinate(LatLng latLng) async

Obtains a location on the screen corresponding to the specified longitude/latitude coordinates. The location on the screen is specified in screen pixels (instead of display pixels) relative to the top left corner of the map (instead of the top left corner of the screen). Asynchronous.

Parameter
NameDescription
latLngLongitude and latitude of a location on the map.
Return Type
TypeDescription
Future<ScreenCoordinate>Coordinates of a location on the screen, in pixels.
Call Example:
//Define HuaweiMapController and a LatLng object.
HuaweiMapController mapController;
LatLng latLng;

//Call getScreenCoordinate API.
ScreenCoordinate coordinate = await mapController.getScreenCoordinate(latLng);
Future<LatLng> getLatLng(ScreenCoordinate screenCoordinate) async

Obtains the longitude and latitude of a location on the screen. The location on the screen is specified in screen pixels (instead of display pixels) relative to the top left corner of the map (instead of the top left corner of the screen). Asynchronous.

Parameter
NameDescription
screenCoordinateCoordinates of a location on the screen, in pixels.
Return Type
TypeDescription
Future<LatLng>LatLng object that contains the corresponding longitude and latitude.
Call Example:
//Define HuaweiMapController and a ScreenCoordinate object.
HuaweiMapController mapController;
ScreenCoordinate screenCoordinate;

//Call getLatLng API.
LatLng latLng = await mapController.getLatLng(screenCoordinate);
Future<void> showMarkerInfoWindow(MarkerId markerId) async

Displays the information window for a marker. Asynchronous.

Parameter
NameDescription
markerIdMarker id.
Return Type
TypeDescription
Future<void>Future result of an execution that returns no value.
Call Example:
//Define HuaweiMapController and a Marker object with InfoWindow.
HuaweiMapController mapController;
Marker marker;

//Call showMarkerInfoWindow API.
await mapController.showMarkerInfoWindow(marker.markerId);
Future<void> hideMarkerInfoWindow(MarkerId markerId) async

Hides the information window that is displayed for a marker. This method is invalid for invisible markers. Asynchronous.

Parameter
NameDescription
markerIdMarker id.
Return Type
TypeDescription
Future<void>Future result of an execution that returns no value.
Call Example:
//Define HuaweiMapController and a Marker object with InfoWindow.
HuaweiMapController mapController;
Marker marker;

//Call hideMarkerInfoWindow API.
await mapController.hideMarkerInfoWindow(marker.markerId);
Future<bool> isMarkerInfoWindowShown(MarkerId markerId) async

Checks whether an information window is currently displayed for a marker. This method will not consider whether the information window is actually visible on the screen. Asynchronous.

Parameter
NameDescription
markerIdMarker id.
Return Type
TypeDescription
Future<bool>true if an information window is currently displayed; false otherwise.
Call Example:
//Define HuaweiMapController and a Marker object with InfoWindow.
HuaweiMapController mapController;
Marker marker;

//Call isMarkerInfoWindowShown API.
bool status = await mapController.isMarkerInfoWindowShown(marker.markerId);
Future<bool> isMarkerClusterable(MarkerId markerId) async

Checks whether a marker can be clustered. Asynchronous.

Parameter
NameDescription
markerIdMarker id.
Return Type
TypeDescription
Future<bool>true if the marker can be clustered; false otherwise.
Call Example:
//Define HuaweiMapController and a Marker object with clusterable feature.
HuaweiMapController mapController;
Marker marker;

//Call isMarkerClusterable API.
bool isClusterable = await mapController.isMarkerClusterable(marker.markerId);
Future<double> getZoomLevel() async

Obtains zoom level of a map. Asynchronous.

Return Type
TypeDescription
Future<double>Zoom level.
Call Example:
//Define HuaweiMapController.
HuaweiMapController mapController;

//Call getZoomLevel API.
double zoomLevel = await mapController.getZoomLevel();
Future<Uint8List> takeSnapshot() async

Takes a snapshot of a map. Asynchronous.

Return Type
TypeDescription
Future<Uint8List>Uint8List data of an image.
Call Example:
//Define HuaweiMapController.
HuaweiMapController mapController;

//Call takeSnapshot API.
Uint8List imageData = await mapController.takeSnapshot();

Data Types

Data Types Summary

ClassDescription
BitmapDescriptorDefines a Bitmap image.
CameraPositionA class that encapsulates all camera attributes.
CameraTargetBoundsA class that encapsulates bound attribute.
CameraUpdateProvides various constructors for creating CameraUpdate objects that modify the camera of a map.
CapDefines a cap that is applied at the start or end vertex of a polyline.
InfoWindowDefines an information window that shows up when a Marker is tapped.
JointTypeDefines the joint type for a polyline.
LatLngRepresents the longitude and latitude, in degrees.
LatLngBoundsRepresents a longitude/latitude aligned rectangle.
MinMaxZoomPreferenceA class that encapsulates minimum and maximum zoom attributes.
PatternItemAn immutable class that describes the stroke pattern of a polyline.
ScreenCoordinateA class that encapsulates x and y attributes.
CircleDefines a circle on a map.
CircleIdRepresents the immutable circle id class.
MarkerDefines an icon placed at a specified position on a map.
MarkerIdRepresents the immutable marker id class.
PolygonDefines a polygon on a map.
PolygonIdRepresents the immutable polygon id class.
PolylineDefines a polyline on a map.
PolylineIdRepresents the immutable polyline id class.
GroundOverlayClass that defines an image on the map.
GroundOverlayIdRepresents the immutable ground overlay id class.
TileOverlayRepresents a tile overlay.
TileOverlayIdRepresents the immutable tile overlay id class.
TileProvides tile images for TileOverlay.
UrlTileProvides tile images for TileOverlay from URL.
RepetitiveTileProvides repetitive tile images for TileOverlay.
HmsMarkerAnimationAn abstract class for supporting marker animation.
HmsMarkerAlphaAnimationAn animation class that controls the transparency.
HmsMarkerRotateAnimationA class that controls the animation rotation.
HmsMarkerScaleAnimationA class for controlling the animation scale.
HmsMarkerTranslateAnimationA class that controls the animation movement.
MapTypeMap types.

You may find and read more about the APIs and classes that provided by the Huawei Map Kit Flutter Plugin on Huawei Developer Website.

BitmapDescriptor

Defines a Bitmap image. A Bitmap image can be used as a Marker icon or for a GroundOverlay.

Public Constants
ConstantTypeDescription
hueReddoubleRed.
hueOrangedoubleOrange.
hueYellowdoubleYellow.
hueGreendoubleGreen.
hueCyandoubleCyan.
hueAzuredoubleAzure.
hueBluedoubleBlue.
hueVioletdoubleViolet.
hueMagentadoubleMagenta.
hueRosedoubleRose.
defaultMarkerBitmapDescriptorDefault marker.
Public Constructor Summary
ConstructorDescription
BitmapDescriptor.defaultMarkerWithHue(double hue)Creates a BitmapDescriptor objects for default marker icons in different colors using different hue values. This class provides 10 hue values. You can call this method by passing a hue value.
BitmapDescriptor.fromBytes(Uint8List byteData)Creates a BitmapDescriptor object from a Uint8List.
BitmapDescriptor.fromAsset(String assetName, String package)Creates a BitmapDescriptor object from an asset.
BitmapDescriptor.fromAssetImage(ImageConfiguration configuration, String assetName, AssetBundle bundle, String package, bool mipmaps)Creates a BitmapDescriptor object from an image asset.
Public Constructors
BitmapDescriptor.defaultMarkerWithHue

Creates a BitmapDescriptor objects for default marker icons in different colors using different hue values. This class provides 10 hue values. You can call this method by passing a hue value.

Parameters

NameDescription
hueHue value.
BitmapDescriptor.fromBytes

Creates a BitmapDescriptor object from a Uint8List.

Parameter

NameDescription
byteDataUint8List image data.
BitmapDescriptor.fromAsset

Creates a BitmapDescriptor object from an asset.

Parameter

NameDescription
assetNameAsset name.
packagePackage name.
BitmapDescriptor.fromAssetImage

Creates a BitmapDescriptor object from an image asset.

Parameter

NameDescription
configurationImageConfiguration object.
assetNameAsset name.
bundleAssetBundle object.
packagePackage name.
mipmapsDefines mipmap.

CameraPosition

A class that encapsulates all camera attributes.

Public Properties
NameTypeDescription
bearingdoubleDirection that the camera is pointing in.
targetLatLngLongitude and latitude of the location that the camera is pointing at.
tiltdoubleAngle of the camera from the nadir (directly facing the Earth's surface).
zoomdoubleZoom level near the center of the screen.
Public Constructor Summary
ConstructorDescription
CameraPosition({double bearing, LatLng target, double tilt, double zoom})Default constructor.
CameraPosition.fromMap({dynamic json})Creates a CameraPosition object from a Map.
Public Constructors
CameraPosition

Constructor for CameraPosition object.

ParameterTypeDescription
bearingdoubleDirection that the camera is pointing in.
targetLatLngLongitude and latitude of the location that the camera is pointing at.
tiltdoubleAngle of the camera from the nadir (directly facing the Earth's surface).
zoomdoubleZoom level near the center of the screen.
CameraPosition.fromMap

Creates a CameraPosition object from a Map.

ParameterTypeDescription
jsondynamicMap as a source.

CameraTargetBounds

A class that encapsulates bound attribute.

Public Properties
NameTypeDescription
boundsLatLngBoundsDefines a rectangular area using a pair of longitude and latitude.
Public Constants
ConstantTypeDescription
unboundedCameraTargetBoundsUnbounded camera bounds.
Public Constructor Summary
ConstructorDescription
CameraTargetBounds({LatLngBounds bounds})Default constructor.
Public Constructors
CameraTargetBounds

Constructor for CameraTargetBounds object.

ParameterTypeDescription
boundsLatLngBoundsDefines a rectangular area using a pair of longitude and latitude.

CameraUpdate

Provides various constructors for creating CameraUpdate objects that modify the camera of a map.

Public Constructor Summary
ConstructorDescription
CameraUpdate.newLatLng(LatLng latLng)Creates a CameraUpdate object pointed to a specific coordinate (latitude and longitude).
CameraUpdate.zoomIn()Creates a CameraUpdate object that zooms the camera in.
CameraUpdate.zoomOut()Creates a CameraUpdate object that zooms the camera out.
CameraUpdate.zoomTo(double zoom)Creates a CameraUpdate object that sets the camera zoom level.
CameraUpdate.zoomBy({double amount, Offset focus})Creates a CameraUpdate object that modifies the camera zoom level by the specified amount.
CameraUpdate.newLatLngBounds({LatLngBounds bounds, double padding})Creates a CameraUpdate object pointed to specific bounds and padding.
CameraUpdate.newLatLngZoom({LatLng latLng, double zoom})Creates a CameraUpdate object pointed to a specific coordinate (latitude and longitude) and zoom level.
CameraUpdate.newCameraPosition({CameraPosition cameraPosition})Creates a CameraUpdate object using the CameraPosition object.
CameraUpdate.scrollBy({double dx, double dy})Creates a CameraUpdate object that moves the camera by the specified distance on the screen.
Public Constructors
CameraUpdate.newLatLng

Creates a CameraUpdate object pointed to a specific coordinate (latitude and longitude).

Parameters

NameDescription
latLngDesired longitude and latitude.
CameraUpdate.zoomIn

Creates a CameraUpdate object that zooms the camera in.

CameraUpdate.zoomOut

Creates a CameraUpdate object that zooms the camera out.

CameraUpdate.zoomTo

Creates a CameraUpdate object that sets the camera zoom level.

Parameters

NameDescription
zoomZoom level of the map camera. The value range is 3, 20. If the passed value exceeds the maximum, the maximum value will be used as the value.
CameraUpdate.zoomBy

Creates a CameraUpdate object that modifies the camera zoom level by the specified amount.

Incrementally moves the map camera based on the map center's coordinates on the screen and the zoom level. The distance to the earth surface is shortened if amount has a positive value and prolonged if amount has a negative value. In the method, focus is the center point for zooming in or out.

Parameters

NameDescription
amountIncremental value to change the zoom level.
focusMap center's coordinates on the screen.
CameraUpdate.newLatLngBounds

Creates a CameraUpdate object pointed to specific bounds and padding.

Centers a region on the screen by setting the longitude and latitude bounds and the padding between the region edges and the longitude/latitude bounding box edges

Parameters

NameDescription
boundsLongitude and latitude bounds to be displayed.
paddingSpace between the region edges and bounding box edges, in pixels.
CameraUpdate.newLatLngZoom

Creates a CameraUpdate object pointed to a specific coordinate (latitude and longitude) and zoom level.

Parameters

NameDescription
latLngLongitude and latitude of the center of a map's view.
zoomZoom level of the map camera. The value range is 3, 20. If the passed value exceeds the maximum, the maximum value will be used as the value.
CameraUpdate.newCameraPosition

Creates a CameraUpdate object using the CameraPosition object.

Parameters

NameDescription
cameraPositionCamera position information.
CameraUpdate.scrollBy

Creates a CameraUpdate object that moves the camera by the specified distance on the screen.

Parameters

NameDescription
dxNumber of pixels moved horizontally. A positive value indicates to move the center to the right, while a negative value indicates to move the center to the left.
dyNumber of pixels moved vertically. A positive value indicates to move the center up, while a negative value indicates to move the center down.

InfoWindow

Defines an information window that shows up when a Marker is tapped.

Public Properties
NameTypeDescription
titleStringTitle of a Marker. By default, the title is empty.
snippetStringSnippet of a Marker.
anchorOffsetOffset of an information window.
onClickVoidCallbackFunction to be executed when an information window is tapped.
Public Constants
ConstantTypeDescription
noTextInfoWindowEmpty information window.
Public Constructor Summary
ConstructorDescription
InfoWindow({String title, String snippet, Offset anchor, VoidCallback onClick})Default constructor.
Public Constructors
InfoWindow

Default constructor for InfoWindow object.

ParameterTypeDescription
titleStringTitle of a Marker. By default, the title is empty.
snippetStringSnippet of a Marker.
anchorOffsetOffset of an information window.
onClickVoidCallbackFunction to be executed when an information window is tapped.
Public Method Summary
MethodReturn TypeDescription
InfoWindow.updateCopy({String title, String snippet, Offset anchor, VoidCallback onClick})InfoWindowCopies an existing InfoWindow object and updates the specified attributes.
Public Methods
InfoWindow.updateCopy({String title, String snippet, Offset anchor, VoidCallback onClick})

Copies an existing InfoWindow object and updates the specified attributes.

Parameters

NameDescription
titleTitle of a Marker. By default, the title is empty.
snippetSnippet of a Marker.
anchorOffset of an information window.
onClickFunction to be executed when an information window is tapped.

Return Type

TypeDescription
InfoWindowInfoWindow object.

Call Example

//Define an InfoWindow.
InfoWindow infoWindow;

//Call updateCopy method.
infoWindow = infoWindow.updateCopy(title: "XXX");

LatLng

Defines the longitude and latitude, in degrees.

Public Properties
NameTypeDescription
latdoubleLongitude. The value ranges from –180 to 180 (excluded).
lngdoubleLatitude. The value ranges from –90 to 90.
Public Constructor Summary
ConstructorDescription
LatLng({double lat, double lng})Default constructor.
LatLng.fromJson(dynamic json)Creates LatLng object from Map.
Public Constructors
LatLng

Constructor for LatLng object.

ParameterTypeDescription
latdoubleLongitude. The value ranges from –180 to 180 (excluded).
lngdoubleLatitude. The value ranges from –90 to 90.
LatLng.fromJson

Creates LatLng object from Map.

ParameterTypeDescription
jsondynamicMap as a source.

LatLngBounds

Defines a rectangular area using a pair of longitude and latitude.

Public Properties
NameTypeDescription
southwestLatLngCoordinates of the southwest corner of the bound.
northeastLatLngCoordinates of the northeast corner of the bound.
Public Constructor Summary
ConstructorDescription
LatLngBounds({LatLng southwest, LatLng northeast})Default constructor.
LatLngBounds.fromList(dynamic json)Creates LatLngBounds object from Map.
Public Constructors
LatLngBounds

Constructor for LatLngBounds object.

ParameterTypeDescription
southwestLatLngCoordinates of the southwest corner of the bound.
northeastLatLngCoordinates of the northeast corner of the bound.
LatLngBounds.fromList

Creates LatLngBounds object from Map.

ParameterTypeDescription
jsondynamicMap as a source.
Public Method Summary
MethodReturn TypeDescription
LatLngBounds.contains(LatLng point)boolChecks whether a LatLngBounds object contains a specified location.
Public Methods
LatLngBounds.contains(LatLng point)

Checks whether a LatLngBounds object contains a specified location.

Parameters

NameDescription
pointLocation to be tested.

Return Type

TypeDescription
booltrue if the specified location is contained; false otherwise.

Call Example

//Define a LatLngBounds and LatLng.
LatLngBounds latLngBounds;
LatLng latLng;

//Call contains method with LatLng.
bool status = latLngBounds.contains(latLng);

MinMaxZoomPreference

A class that encapsulates attributes for setting the minimum and maximum zoom levels.

Public Properties
NameTypeDescription
minZoomdoubleMinimum zoom level.
maxZoomdoubleMaximum zoom level.
Public Constants
ConstantTypeDescription
unboundedMinMaxZoomPreferenceUnbounded zoom preference.
Public Constructor Summary
ConstructorDescription
MinMaxZoomPreference({double minZoom, double maxZoom})Default constructor.
Public Constructors
MinMaxZoomPreference

Constructor for MinMaxZoomPreference object.

ParameterTypeDescription
minZoomdoubleMinimum zoom level.
maxZoomdoubleMaximum zoom level.

Circle

Defines a circle on a map.

Public Properties
NameTypeDescription
circleIdCircleIdUnique circle ID.
clickableboolIndicates whether a circle is tappable.
fillColorColorFill color.
centerLatLngLongitude and latitude of the center of a circle.
radiusdoubleRadius of a circle.
strokeColorColorStroke color.
strokeWidthintStroke width of a circle's outline.
visibleboolVisibility of a circle.
zIndexintZ-index of a circle, which indicates the overlapping order of the circle.
onClickVoidCallbackFunction to be executed when a circle is tapped.
Public Constructor Summary
ConstructorDescription
Circle({CircleId circleId, bool clickable, Color fillColor, LatLng center, double radius, Color strokeColor, int strokeWidth, bool visible, int zIndex, VoidCallback onClick})Default constructor.
Public Constructors
Circle

Constructor for Circle object.

ParameterTypeDescription
circleIdCircleIdUnique circle ID.
clickableboolIndicates whether a circle is tappable.
fillColorColorFill color.
centerLatLngLongitude and latitude of the center of a circle.
radiusdoubleRadius of a circle.
strokeColorColorStroke color.
strokeWidthintStroke width of a circle's outline.
visibleboolVisibility of a circle.
zIndexintZ-index of a circle, which indicates the overlapping order of the circle.
onClickVoidCallbackFunction to be executed when a circle is tapped.
Public Method Summary
MethodReturn TypeDescription
Circle.updateCopy({bool clickable, Color fillColor, LatLng center, double radius, Color strokeColor, int strokeWidth, bool visible, int zIndex, VoidCallback onClick})CircleCopies an existing Circle object and updates the specified attributes.
Circle.clone()CircleClones the Circle.
Public Methods
Circle.updateCopy({bool clickable, Color fillColor, LatLng center, double radius, Color strokeColor, int strokeWidth, bool visible, int zIndex, VoidCallback onClick})

Copies an existing Circle object and updates the specified attributes.

Parameters

NameDescription
clickableIndicates whether a circle is tappable.
fillColorFill color.
centerLongitude and latitude of the center of a circle.
radiusRadius of a circle.
strokeColorStroke color.
strokeWidthStroke width of a circle's outline.
visibleVisibility of a circle.
zIndexZ-index of a circle, which indicates the overlapping order of the circle.
onClickFunction to be executed when a circle is tapped.

Return Type

TypeDescription
CircleCircle object.

Call Example

//Define a Circle.
Circle circle;

//Call updateCopy method.
circle = circle.updateCopy(radius: 4000);
Circle.clone()

Clones the Circle.

Return Type

TypeDescription
CircleCircle object.

Call Example

//Define a Circle.
Circle circle;
Circle circle2;

//Call clone method.
circle2 = circle.clone();

Marker

Defines an icon placed at a specified position on a map.

Public Properties
NameTypeDescription
markerIdMarkerIdUnique marker ID.
positionLatLngPosition of a marker.
infoWindowInfoWindowInformation window of a marker.
anchorOffsetAnchor point of a marker.
draggableboolIndicates whether a marker can be dragged. The options are true (yes) and false (no).
flatboolIndicates whether to flatly attach a marker to the map. If the marker is flatly attached to the map, it will stay on the map when the camera rotates or tilts. The marker will remain the same size when the camera zooms in or out. If the marker faces the camera, it will always be drawn facing the camera and rotates or tilts with the camera.
iconBitmapDescriptorMarker icon to render.
rotationdoubleRotation angle of a marker, in degrees.
alphadoubleOpacity. The value ranges from 0 (completely transparent) to 1 (completely opaque).
visibleboolIndicates whether a marker is visible. The options are true (yes) and false (no).
zIndexdoubleZ-index of a marker. The z-index indicates the overlapping order of a marker. A marker with a larger z-index overlaps that with a smaller z-index. Markers with the same z-index overlap each other in a random order. By default, the z-index is 0.
clickableboolIndicates whether a marker can be tapped. The options are true (yes) and false (no).
clusterableboolIndicates whether a marker is clusterable or not.
onClickVoidCallbackCallback method executed when a marker is tapped.
onDragEndValueChanged<LatLng>Callback method executed when marker dragging is finished.
animationSetList<dynamic>Animations.
Public Constructor Summary
ConstructorDescription
Marker({MarkerId markerId, LatLng position, InfoWindow infoWindow, Offset anchor, bool draggable, bool flat, BitmapDescriptor icon, double rotation, double alpha, bool visible, double zIndex, bool clickable, bool clusterable, VoidCallback onClick, ValueChanged<LatLng> onDragEnd, List<dynamic> animationSet})Default constructor.
Public Constructors
Marker

Constructor for Marker object.

ParameterTypeDescription
markerIdMarkerIdUnique marker ID.
positionLatLngPosition of a marker.
infoWindowInfoWindowInformation window of a marker.
anchorOffsetAnchor point of a marker.
draggableboolIndicates whether a marker can be dragged. The options are true (yes) and false (no).
flatboolIndicates whether to flatly attach a marker to the map. If the marker is flatly attached to the map, it will stay on the map when the camera rotates or tilts. The marker will remain the same size when the camera zooms in or out. If the marker faces the camera, it will always be drawn facing the camera and rotates or tilts with the camera.
iconBitmapDescriptorMarker icon to render.
rotationdoubleRotation angle of a marker, in degrees.
alphadoubleOpacity. The value ranges from 0 (completely transparent) to 1 (completely opaque).
visibleboolIndicates whether a marker is visible. The options are true (yes) and false (no).
zIndexdoubleZ-index of a marker. The z-index indicates the overlapping order of a marker. A marker with a larger z-index overlaps that with a smaller z-index. Markers with the same z-index overlap each other in a random order. By default, the z-index is 0.
clickableboolIndicates whether a marker can be tapped. The options are true (yes) and false (no).
clusterableboolIndicates whether a marker is clusterable or not.
onClickVoidCallbackCallback method executed when a marker is tapped.
onDragEndValueChanged<LatLng>Callback method executed when marker dragging is finished.
animationSetList<dynamic>Animations.
Public Method Summary
MethodReturn TypeDescription
Marker.updateCopy({LatLng position, InfoWindow infoWindow, Offset anchor, bool draggable, bool flat, BitmapDescriptor icon, double rotation, double alpha, bool visible, double zIndex, bool clickable, bool clusterable, VoidCallback onClick, ValueChanged<LatLng> onDragEnd, List<dynamic> animationSet})MarkerCopies an existing Marker object and updates the specified attributes.
Marker.clone()MarkerClones the Marker.
Public Methods
Marker.updateCopy({LatLng position, InfoWindow infoWindow, Offset anchor, bool draggable, bool flat, BitmapDescriptor icon, double rotation, double alpha, bool visible, double zIndex, bool clickable, bool clusterable, VoidCallback onClick, ValueChanged<LatLng> onDragEnd, List<dynamic> animationSet})

Copies an existing Marker object and updates the specified attributes.

Parameters

NameDescription
positionPosition of a marker.
infoWindowInformation window of a marker.
anchorAnchor point of a marker.
draggableIndicates whether a marker can be dragged. The options are true (yes) and false (no).
flatIndicates whether to flatly attach a marker to the map. If the marker is flatly attached to the map, it will stay on the map when the camera rotates or tilts. The marker will remain the same size when the camera zooms in or out. If the marker faces the camera, it will always be drawn facing the camera and rotates or tilts with the camera.
iconMarker icon to render.
rotationRotation angle of a marker, in degrees.
alphaOpacity. The value ranges from 0 (completely transparent) to 1 (completely opaque).
visibleIndicates whether a marker is visible. The options are true (yes) and false (no).
zIndexZ-index of a marker. The z-index indicates the overlapping order of a marker. A marker with a larger z-index overlaps that with a smaller z-index. Markers with the same z-index overlap each other in a random order. By default, the z-index is 0.
clickableIndicates whether a marker can be tapped. The options are true (yes) and false (no).
clusterableIndicates whether a marker is clusterable or not.
onClickCallback method executed when a marker is tapped.
onDragEndCallback method executed when marker dragging is finished.
animationSetAnimations.

Return Type

TypeDescription
MarkerMarker object.

Call Example

//Define a Marker.
Marker marker;

//Call updateCopy method.
marker = marker.updateCopy(draggable: true);
Marker.clone()

Clones the Marker.

Return Type

TypeDescription
MarkerMarker object.

Call Example

//Define a Marker.
Marker marker;
Marker marker2;

//Call clone method.
marker2 = marker.clone();

Polygon

Defines a polygon on a map.

Public Properties
NameTypeDescription
polygonIdPolygonIdUnique polygon ID.
clickableboolIndicates whether a polygon is tappable.
fillColorColorFill color.
geodesicboolIndicates whether to draw each segment of a polygon as a geodesic. The options are true (yes) and false (no).
pointsList<LatLng>Vertex coordinate set.
visibleboolVisibility of a polygon.
strokeColorColorStroke color.
strokeWidthintStroke width of a polygon's outline.
zIndexintZ-index of a polygon, which indicates the overlapping order of the polygon.
onClickVoidCallbackFunction to be executed when a polygon is tapped.
Public Constructor Summary
ConstructorDescription
Polygon({PolygonId polygonId, bool clickable, Color fillColor, bool geodesic, List<LatLng> points, bool visible, Color strokeColor, int strokeWidth, int zIndex, VoidCallback onClick})Default constructor.
Public Constructors
Polygon

Constructor for Polygon object.

ParameterTypeDescription
polygonIdPolygonIdUnique polygon ID.
clickableboolIndicates whether a polygon is tappable.
fillColorColorFill color.
geodesicboolIndicates whether to draw each segment of a polygon as a geodesic. The options are true (yes) and false (no).
pointsList<LatLng>Vertex coordinate set.
visibleboolVisibility of a polygon.
strokeColorColorStroke color.
strokeWidthintStroke width of a polygon's outline.
zIndexintZ-index of a polygon, which indicates the overlapping order of the polygon.
onClickVoidCallbackFunction to be executed when a polygon is tapped.
Public Method Summary
MethodReturn TypeDescription
Polygon.updateCopy({bool clickable, Color fillColor, bool geodesic, List<LatLng> points, bool visible, Color strokeColor, int strokeWidth, int zIndex, VoidCallback onClick})PolygonCopies an existing Polygon object and updates the specified attributes.
Polygon.clone()PolygonClones the Polygon.
Public Methods
Polygon.updateCopy({bool clickable, Color fillColor, bool geodesic, List<LatLng> points, bool visible, Color strokeColor, int strokeWidth, int zIndex, VoidCallback onClick})

Copies an existing Polygon object and updates the specified attributes.

Parameters

NameDescription
clickableIndicates whether a polygon is tappable.
fillColorFill color.
geodesicIndicates whether to draw each segment of a polygon as a geodesic. The options are true (yes) and false (no).
pointsVertex coordinate set.
visibleVisibility of a polygon.
strokeColorStroke color.
strokeWidthStroke width of a polygon's outline.
zIndexZ-index of a polygon, which indicates the overlapping order of the polygon.
onClickFunction to be executed when a polygon is tapped.

Return Type

TypeDescription
PolygonPolygon object.
//Define a Polygon.
Polygon polygon;

//Call updateCopy method.
polygon = polygon.updateCopy(clickable: true);
Polygon.clone()

Clones the Polygon.

Return Type

TypeDescription
PolygonPolygon object.

Call Example

//Define a Polygon.
Polygon polygon;
Polygon polygon2;

//Call clone method.
polygon2 = polygon.clone();

Polyline

Defines a polyline on a map.

Public Properties
NameTypeDescription
polylineIdPolylineIdUnique polyline ID.
clickableboolIndicates whether a polyline is tappable.
colorColorStroke color.
geodesicboolIndicates whether to draw each segment of a polyline as a geodesic. The options are true (yes) and false (no).
jointTypeJointTypeJointType of all vertices of a polyline, except the start and end vertices.
patternsList<PatternItem>Stroke pattern of a polyline. The default value is null, indicating that the stroke pattern is solid.
pointsList<LatLng>Vertices of a polyline. Line segments are drawn between consecutive points. A polyline is not closed by default. To form a closed polyline, the start and end vertices must be the same.
startCapCapStart vertex of a polyline.
endCapCapEnd vertex of a polyline.
visibleboolVisibility of a polyline.
widthintStroke width of a polyline.
zIndexintZ-index of a polyline, which indicates the overlapping order of the polyline.
onClickVoidCallbackFunction to be executed when a polyline is tapped.
Public Constructor Summary
ConstructorDescription
Polyline({PolylineId polylineId, bool clickable, Color color, bool geodesic, JointType jointType, List<PatternItem> patterns, List<LatLng> points, Cap startCap, Cap endCap, bool visible, int width, int zIndex, VoidCallback onClick})Default constructor.
Public Constructors
Polyline

Constructor for Polyline object.

ParameterTypeDescription
polylineIdPolylineIdUnique polyline ID.
clickableboolIndicates whether a polyline is tappable.
colorColorStroke color.
geodesicboolIndicates whether to draw each segment of a polyline as a geodesic. The options are true (yes) and false (no).
jointTypeJointTypeJointType of all vertices of a polyline, except the start and end vertices.
patternsList<PatternItem>Stroke pattern of a polyline. The default value is null, indicating that the stroke pattern is solid.
pointsList<LatLng>Vertices of a polyline. Line segments are drawn between consecutive points. A polyline is not closed by default. To form a closed polyline, the start and end vertices must be the same.
startCapCapStart vertex of a polyline.
endCapCapEnd vertex of a polyline.
visibleboolVisibility of a polyline.
widthintStroke width of a polyline.
zIndexintZ-index of a polyline, which indicates the overlapping order of the polyline.
onClickVoidCallbackFunction to be executed when a polyline is tapped.
Public Method Summary
MethodReturn TypeDescription
Polyline.updateCopy({bool clickable, Color color, bool geodesic, JointType jointType, List<PatternItem> patterns, List<LatLng> points, Cap startCap, Cap endCap, bool visible, int width, int zIndex, VoidCallback onClick})PolylineCopies an existing Polyline object and updates the specified attributes.
Polyline.clone()PolylineClones the Polyline.
Public Methods
Polyline.updateCopy({bool clickable, Color color, bool geodesic, JointType jointType, List<PatternItem> patterns, List<LatLng> points, Cap startCap, Cap endCap, bool visible, int width, int zIndex, VoidCallback onClick})

Copies an existing Polyline object and updates the specified attributes.

Parameters

NameDescription
clickableIndicates whether a polyline is tappable.
colorStroke color.
geodesicIndicates whether to draw each segment of a polyline as a geodesic. The options are true (yes) and false (no).
jointTypeJointType of all vertices of a polyline, except the start and end vertices.
patternsStroke pattern of a polyline. The default value is null, indicating that the stroke pattern is solid.
pointsVertices of a polyline. Line segments are drawn between consecutive points. A polyline is not closed by default. To form a closed polyline, the start and end vertices must be the same.
startCapStart vertex of a polyline.
endCapEnd vertex of a polyline.
visibleVisibility of a polyline.
widthStroke width of a polyline.
zIndexZ-index of a polyline, which indicates the overlapping order of the polyline.
onClickFunction to be executed when a polyline is tapped.

Return Type

TypeDescription
PolylinePoyline object.

Call Example

//Define a Polyline.
Polyline polyline;

//Call updateCopy method.
polyline = polyline.updateCopy(clickable: true);
Polyline.clone()

Clones the Polyline.

Return Type

TypeDescription
PolylinePolyline object.

Call Example

//Define a Polyline.
Polyline polyline;
Polyline polyline2;

//Call clone method.
polyline2 = polyline.clone();

GroundOverlay

Class that defines an image on the map.

Public Properties
NameTypeDescription
groundOverlayIdGroundOverlayIdUnique Ground Overlay ID.
bearingdoubleSets the bearing of a ground overlay, in degrees clockwise from north.
clickableboolSets whether a ground overlay is tappable.
widthdoubleWidth of a ground overlay, in meters.
heightdoubleHeight of a ground overlay, in meters.
imageDescriptorBitmapDescriptorSets the image for a ground overlay.
positionLatLngSets the position of a ground overlay.
boundsLatLngBoundsSets bounds of a ground overlay.
anchorOffsetSets anchor of a ground overlay.
transparencydoubleSets the transparency of a ground overlay.
visibleboolSets whether a ground overlay is visible. If the ground overlay is invisible, it will not be drawn but all other states will be preserved.
zIndexdoubleSets the z-index of a ground overlay. The z-index indicates the overlapping order of a ground overlay. A ground overlay with a larger z-index overlaps that with a smaller z-index. Ground overlays with the same z-index overlap each other in a random order.
onClickVoidCallbackFunction to be executed when a ground overlay is tapped.
Public Constructor Summary
ConstructorDescription
GroundOverlay({GroundOverlayId groundOverlayId, double bearing, bool clickable, double width, double height, BitmapDescriptor imageDescriptor, LatLng position, LatLngBounds bounds, Offset anchor, double transparency, bool visible, double zIndex})Default constructor.
Public Constructors
GroundOverlay

Constructor for GroundOverlay object.

ParameterTypeDescription
groundOverlayIdGroundOverlayIdUnique Ground Overlay ID.
bearingdoubleSets the bearing of a ground overlay, in degrees clockwise from north.
clickableboolSets whether a ground overlay is tappable.
widthdoubleWidth of a ground overlay, in meters.
heightdoubleHeight of a ground overlay, in meters.
imageDescriptorBitmapDescriptorSets the image for a ground overlay.
positionLatLngSets the position of a ground overlay.
boundsLatLngBoundsSets bounds of a ground overlay.
anchorOffsetSets anchor of a ground overlay.
transparencydoubleSets the transparency of a ground overlay.
visibleboolSets whether a ground overlay is visible. If the ground overlay is invisible, it will not be drawn but all other states will be preserved.
zIndexdoubleSets the z-index of a ground overlay. The z-index indicates the overlapping order of a ground overlay. A ground overlay with a larger z-index overlaps that with a smaller z-index. Ground overlays with the same z-index overlap each other in a random order.
onClickVoidCallbackFunction to be executed when a ground overlay is tapped.
Public Method Summary
MethodReturn TypeDescription
GroundOverlay.updateCopy({double bearing, bool clickable, double width, double height, BitmapDescriptor imageDescriptor, LatLng position, LatLngBounds bounds, Offset anchor, double transparency, bool visible, double zIndex})GroundOverlayCopies an existing GroundOverlay object and updates the specified attributes.
GroundOverlay.clone()GroundOverlayClones the GroundOverlay.
Public Methods
GroundOverlay.updateCopy({double bearing, bool clickable, double width, double height, BitmapDescriptor imageDescriptor, LatLng position, LatLngBounds bounds, Offset anchor, double transparency, bool visible, double zIndex})

Copies an existing GroundOverlay object and updates the specified attributes.

Parameters

NameDescription
bearingSets the bearing of a ground overlay, in degrees clockwise from north.
clickableSets whether a ground overlay is tappable.
widthWidth of a ground overlay, in meters.
heightHeight of a ground overlay, in meters.
imageDescriptorSets the image for a ground overlay.
positionSets the position of a ground overlay.
boundsSets bounds of a ground overlay.
anchorSets anchor of a ground overlay.
transparencySets the transparency of a ground overlay.
visibleSets whether a ground overlay is visible. If the ground overlay is invisible, it will not be drawn but all other states will be preserved.
zIndexSets the z-index of a ground overlay. The z-index indicates the overlapping order of a ground overlay. A ground overlay with a larger z-index overlaps that with a smaller z-index. Ground overlays with the same z-index overlap each other in a random order.
onClickFunction to be executed when a ground overlay is tapped.

Return Type

TypeDescription
GroundOverlayGroundOverlay object.

Call Example

//Define a GroundOverlay.
GroundOverlay groundOverlay;

//Call updateCopy method.
groundOverlay = groundOverlay.updateCopy(clickable: true);
GroundOverlay.clone()

Clones the GroundOverlay.

Return Type

TypeDescription
GroundOverlayGroundOverlay object.

Call Example

//Define a GroundOverlay.
GroundOverlay groundOverlay;
GroundOverlay groundOverlay2;

//Call clone method.
groundOverlay2 = groundOverlay.clone();

TileOverlay

A tile overlay is a set of images to be displayed on a map. It can be transparent and enable you to add new functions to an existing map.

Public Properties
NameTypeDescription
tileOverlayIdTileOverlayIdUnique Tile Overlay ID.
fadeInboolSets whether a tile overlay fades in.
transparencydoubleSets the transparency of a tile overlay.
visibleboolSets whether a tile overlay is visible. If the tile overlay is invisible, it will not be drawn but all other states will be preserved. By default, a tile overlay is visible.
zIndexdoubleSets the z-index of a tile overlay. The z-index indicates the overlapping order of a tile overlay. A tile overlay with a larger z-index overlaps that with a smaller z-index. Tile overlays with the same z-index overlap each other in any order.
tileProviderdynamicSets the provider of a tile overlay.
typeStringType of providers.
Public Constructor Summary
ConstructorDescription
TileOverlay({TileOverlayId tileOverlayId, String type, dynamic tileProvider, bool fadeIn, double transparency, bool visible, double zIndex})Default constructor.
Public Constructors
TileOverlay

Constructor for TileOverlay object.

ParameterTypeDescription
tileOverlayIdTileOverlayIdUnique Tile Overlay ID.
fadeInboolSets whether a tile overlay fades in.
transparencydoubleSets the transparency of a tile overlay.
visibleboolSets whether a tile overlay is visible. If the tile overlay is invisible, it will not be drawn but all other states will be preserved. By default, a tile overlay is visible.
zIndexdoubleSets the z-index of a tile overlay. The z-index indicates the overlapping order of a tile overlay. A tile overlay with a larger z-index overlaps that with a smaller z-index. Tile overlays with the same z-index overlap each other in any order.
tileProviderdynamicSets the provider of a tile overlay.
typeStringType of providers.
Public Method Summary
MethodReturn TypeDescription
TileOverlay.updateCopy({bool fadeIn, double transparency, bool visible, double zIndex, dynamic tileProvider, String type})TileOverlayCopies an existing TileOverlay object and updates the specified attributes.
TileOverlay.clone()TileOverlayClones the TileOverlay.
Public Methods
TileOverlay.updateCopy({bool fadeIn, double transparency, bool visible, double zIndex, dynamic tileProvider, String type})

Copies an existing TileOverlay object and updates the specified attributes.

Parameters

NameDescription
fadeInSets whether a tile overlay fades in.
transparencySets the transparency of a tile overlay.
visibleSets whether a tile overlay is visible. If the tile overlay is invisible, it will not be drawn but all other states will be preserved. By default, a tile overlay is visible.
zIndexSets the z-index of a tile overlay. The z-index indicates the overlapping order of a tile overlay. A tile overlay with a larger z-index overlaps that with a smaller z-index. Tile overlays with the same z-index overlap each other in any order.
tileProviderSets the provider of a tile overlay.
typeType of providers.

Return Type

TypeDescription
TileOverlayTileOverlay object.

Call Example

//Define a TileOverlay.
TileOverlay tileOverlay;

//Call updateCopy method.
tileOverlay = tileOverlay.updateCopy(visible: true);
TileOverlay.clone()

Clones the TileOverlay.

Return Type

TypeDescription
TileOverlayTileOverlay

Call Example

//Define a TileOverlay.
TileOverlay tileOverlay;
TileOverlay tileOverlay2;

//Call clone method.
tileOverlay2 = tileOverlay.clone();

Tile

Provides tile images for TileOverlay.

Public Properties
NameTypeDescription
xintX value.
yintY value.
zoomintZoom level.
imageDataUint8ListUint8List image data.
Public Constructor Summary
ConstructorDescription
Tile({int x, int y, int zoom, Uint8List imageData})Default constructor.
Public Constructors
Tile({int x, int y, int zoom, Uint8List imageData})

Constructor for Tile object.

ParameterTypeDescription
xintX value.
yintY value
zoomintZoom level.
imageDataUint8ListUint8List image data.

UrlTile

Provides tile images for TileOverlay from URL.

Public Properties
NameTypeDescription
uriStringURL of the image to be used at the specified tile coordinates.
Public Constructor Summary
ConstructorDescription
UrlTile({String uri})Default constructor.
Public Constructors
UrlTile

Constructor for UrlTile object.

ParameterTypeDescription
uriStringURL of the image to be used at specific tile coordinates.

RepetitiveTile

Provides repetitive tile images for TileOverlay.

Public Properties
NameTypeDescription
imageDataUint8ListUint8List image data.
zoomList<int>Zoom levels of repetition.
Public Constructor Summary
ConstructorDescription
RepetitiveTile({Uint8List imageData, List<int> zoom})Default constructor.
Public Constructors
RepetitiveTile

Constructor for RepetitiveTile object.

ParameterTypeDescirption
imageDataUint8ListUint8List image data.
zoomList<int>Zoom levels of repetition.

HmsMarkerAnimation

An abstract class for supporting marker animation.

Public Properties
NameTypeDescription
animationIdStringUnique animation ID.
typeStringAnimation type.
durationintSets the animation duration.
fillModeintSets the status after the animation ends.
repeatCountintSets the number of times that an animation is replayed.
repeatModeintSets the animation replay mode. By default, the animation is replayed from the start.
interpolatorintSets an animation interpolator.
Public Constants
ConstantTypeValueDescription
FORWARDSint0(Fill Mode) The last frame is displayed after the animation ends.
BACKWARDSint1(Fill Mode) The first frame is displayed after the animation ends.
INFINITEint-1(Repeat Mode) The animation is replayed infinitely.
RESTARTint1(Repeat Mode) The animation is replayed from the start after it ends.
REVERSEint2(Repeat Mode) The animation is replayed from the end in reverse order after it ends.
LINEARint0(Interpolator) Linear interpolator.
ACCELERATEint1(Interpolator) Accelerate interpolator.
ANTICIPATEint2(Interpolator) Anticipate interpolator.
BOUNCEint3(Interpolator) Bounce interpolator.
DECELERATEint4(Interpolator) Decelerate interpolator.
OVERSHOOTint5(Interpolator) Overshoot interpolator.
ACCELERATE_DECELERATEint6(Interpolator) Accelerate decelerate interpolator.
FAST_OUT_LINEAR_INint7(Interpolator) Fast out linear in interpolator.
FAST_OUT_SLOW_INint8(Interpolator) Fast out slow in interpolator.
LINEAR_OUT_SLOW_INint9(Interpolator) Linear out slow in interpolator.
Public Constructor Summary
ConstructorDescription
HmsMarkerAnimation({String animationId, String type, int duration, int fillMode, int repeatCount, int repeatMode, int interpolator})Default constructor.
Public Constructors
HmsMarkerAnimation

Constructor for HmsMarkerAnimation object.

ParameterTypeDescription
animationIdStringUnique animation ID.
typeStringAnimation type.
durationintSets the animation duration.
fillModeintSets the status after the animation ends.
repeatCountintSets the number of times that an animation is replayed.
repeatModeintSets the animation replay mode. By default, the animation is replayed from the start.
interpolatorintSets an animation interpolator.

HmsMarkerAlphaAnimation

An animation class that controls the transparency. The transparency value range is 0,1. The value 1 indicates opaque.

Public Properties
NameTypeDescription
animationIdStringUnique animation ID.
fromAlphadoubleInitial transparency.
toAlphadoubleTarget transparency.
durationintSets the animation duration.
fillModeintSets the status after the animation ends.
repeatCountintSets the number of times that an animation is replayed.
repeatModeintSets the animation replay mode. By default, the animation is replayed from the start.
interpolatorintSets an animation interpolator.
onAnimationStartFunctionFunction to be executed when an animation starts.
onAnimationEndFunctionFunction to be executed when an animation ends.
Public Constructor Summary
ConstructorDescription
HmsMarkerAlphaAnimation({String animationId, double fromAlpha, double toAlpha, int duration, int fillMode, int repeatCount, int repeatMode, int interpolator, Function onAnimationStart, Function onAnimationEnd})Default constructor.
Public Constructors
HmsMarkerAlphaAnimation

Constructor for HmsMarkerAlphaAnimation object.

ParameterTypeDescription
animationIdStringUnique animation ID.
fromAlphadoubleInitial transparency.
toAlphadoubleTarget transparency.
durationintSets the animation duration.
fillModeintSets the status after the animation ends.
repeatCountintSets the number of times that an animation is replayed.
repeatModeintSets the animation replay mode. By default, the animation is replayed from the start.
interpolatorintSets an animation interpolator.
onAnimationStartFunctionFunction to be executed when an animation starts.
onAnimationEndFunctionFunction to be executed when an animation ends.

HmsMarkerRotateAnimation

A class that controls the animation rotation.

Public Properties
NameTypeDescription
animationIdStringUnique animation ID.
fromDegreedoubleInitial angle.
toDegreedoubleTarget angle.
durationintSets the animation duration.
fillModeintSets the status after the animation ends.
repeatCountintSets the number of times that an animation is replayed.
repeatModeintSets the animation replay mode. By default, the animation is replayed from the start.
interpolatorintSets an animation interpolator.
onAnimationStartFunctionFunction to be executed when an animation starts.
onAnimationEndFunctionFunction to be executed when an animation ends.
Public Constructor Summary
ConstructorDescription
HmsMarkerRotateAnimation({String animationId, double fromDegree, double toDegree, int duration, int fillMode, int repeatCount, int repeatMode, int interpolator, Function onAnimationStart, Function onAnimationEnd})Default constructor.
Public Constructors
HmsMarkerRotateAnimation

Constructor for HmsMarkerRotateAnimation object.

ParameterTypeDescription
animationIdStringUnique animation ID.
fromDegreedoubleInitial angle.
toDegreedoubleTarget angle.
durationintSets the animation duration.
fillModeintSets the status after the animation ends.
repeatCountintSets the number of times that an animation is replayed.
repeatModeintSets the animation replay mode. By default, the animation is replayed from the start.
interpolatorintSets an animation interpolator.
onAnimationStartFunctionFunction to be executed when an animation starts.
onAnimationEndFunctionFunction to be executed when an animation ends.

HmsMarkerScaleAnimation

A class for controlling the animation scale.

Public Properties
NameTypeDescription
animationIdStringUnique animation ID.
fromXdoubleIndicates the horizontal scale ratio when the animation starts.
toXdoubleIndicates the horizontal scale ratio when the animation ends.
fromYdoubleIndicates the vertical scale ratio when the animation starts.
toYdoubleIndicates the vertical scale ratio when the animation ends.
durationintSets the animation duration.
fillModeintSets the status after the animation ends.
repeatCountintSets the number of times that an animation is replayed.
repeatModeintSets the animation replay mode. By default, the animation is replayed from the start.
interpolatorintSets an animation interpolator.
onAnimationStartFunctionFunction to be executed when an animation starts.
onAnimationEndFunctionFunction to be executed when an animation ends.
Public Constructor Summary
ConstructorDescription
HmsMarkerScaleAnimation({String animationId, double fromX, double toX, double fromY, double toY, int duration, int fillMode, int repeatCount, int repeatMode, int interpolator, Function onAnimationStart, Function onAnimationEnd})Default constructor.
Public Constructors
HmsMarkerScaleAnimation

Constructor for HmMarkerScaleAnimation object.

ParameterTypeDescription
animationIdStringUnique animation ID.
fromXdoubleIndicates the horizontal scale ratio when the animation starts.
toXdoubleIndicates the horizontal scale ratio when the animation ends.
fromYdoubleIndicates the vertical scale ratio when the animation starts.
toYdoubleIndicates the vertical scale ratio when the animation ends.
durationintSets the animation duration.
fillModeintSets the status after the animation ends.
repeatCountintSets the number of times that an animation is replayed.
repeatModeintSets the animation replay mode. By default, the animation is replayed from the start.
interpolatorintSets an animation interpolator.
onAnimationStartFunctionFunction to be executed when an animation starts.
onAnimationEndFunctionFunction to be executed when an animation ends.

HmsMarkerTranslateAnimation

A class that controls the animation movement.

Public Properties
NameTypeDescription
animationIdStringUnique animation ID.
targetLatLngTarget movement position.
durationintSets the animation duration.
fillModeintSets the status after the animation ends.
repeatCountintSets the number of times that an animation is replayed.
repeatModeintSets the animation replay mode. By default, the animation is replayed from the start.
interpolatorintSets an animation interpolator.
onAnimationStartFunctionFunction to be executed when an animation starts.
onAnimationEndFunctionFunction to be executed when an animation ends.
Public Constructor Summary
ConstructorDescription
HmsMarkerTranslateAnimation({String animationId, LatLng target, int duration, int fillMode, int repeatCount, int repeatMode, int interpolator, Function onAnimationStart, Function onAnimationEnd})Default constructor.
Public Constructors
HmsMarkerTranslateAnimation

Constructor for HmsMarkerTranslateAnimation object.

ParameterTypeDescription
animationIdStringUnique animation ID.
targetLatLngTarget movement position.
durationintSets the animation duration.
fillModeintSets the status after the animation ends.
repeatCountintSets the number of times that an animation is replayed.
repeatModeintSets the animation replay mode. By default, the animation is replayed from the start.
interpolatorintSets an animation interpolator.
onAnimationStartFunctionFunction to be executed when an animation starts.
onAnimationEndFunctionFunction to be executed when an animation ends.

4. Configuration and Description

Preparing for Release

Before building a release version of your app you may need to customize the proguard-rules.pro obfuscation configuration file to prevent the HMS Core SDK from being obfuscated. Add the configurations below to exclude the HMS Core SDK from obfuscation. For more information on this topic refer to this Android developer guide.

<flutter_project>/android/app/proguard-rules.pro

-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keep class com.hianalytics.android.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
-keep class com.huawei.hms.flutter.** { *; }

# Flutter wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.**  { *; }
-keep class io.flutter.util.**  { *; }
-keep class io.flutter.view.**  { *; }
-keep class io.flutter.**  { *; }
-keep class io.flutter.plugins.**  { *; }
-dontwarn io.flutter.embedding.**

<flutter_project>/android/app/build.gradle

buildTypes {
    debug {
        signingConfig signingConfigs.config
    }
    release {
        signingConfig signingConfigs.config
        // Enables code shrinking, obfuscation and optimization for release builds
        minifyEnabled true
        // Unused resources will be removed, resources defined in the res/raw/keep.xml will be kept.
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

5. Sample Project

This plugin includes a demo project in the example folder, there you can find more usage examples.


6. Questions or Issues

If you have questions about how to use HMS samples, try the following options:

  • Stack Overflow is the best place for any programming questions. Be sure to tag your question with huawei-mobile-services.
  • Github is the official repository for these plugins, You can open an issue or submit your ideas.
  • Huawei Developer Forum HMS Core Module is great for general questions, or seeking recommendations and opinions.
  • Huawei Developer Docs is place to official documentation for all HMS Core Kits, you can find detailed documentations in there.

If you run into a bug in our samples, please submit an issue to the GitHub repository.


7. Licensing and Terms

Huawei MAP Kit Flutter Plugin is licensed under Apache 2.0 license

Libraries

alphaAnimation
animation
bitmapDescriptor
callbacks
cameraPosition
cameraTargetBounds
cameraUpdate
cap
channel
circle
circle
circleId
circleUpdates
components
events
groundOverlay
groundOverlay
groundOverlayId
groundOverlayUpdates
huaweiMapMethodChannel
huaweiMapOptions
huaweiMapUtilMethodChannel
infoWindow
jointType
latLng
latLngBounds
map
mapEvent
mapEventCoord
mapType
marker
marker
markerId
markerUpdates
method
minMaxZoomPreference
param
patternItem
polygon
polygon
polygonId
polygonUpdates
polyline
polyline
polylineId
polylineUpdates
repetitiveTile
rotateAnimation
scaleAnimation
screenCoordinate
tile
tileOverlay
tileOverlay
tileOverlayId
tileOverlayUpdates
toJson
translateAnimation
urlTile
utils