目录

HuaweiMapController

Map controller for HuaweiMap.

Method Summary

Method

Return Type

Description

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.

stopAnimation()

Future<void>

Stops the current animation of the camera. When this method is called, the camera stops moving immediately and remains in that position.

moveCamera(CameraUpdate cameraUpdate)

Future<void>

Updates the camera position. The movement is instantaneous.

setMapStyle(String mapStyle)

Future<void>

Sets the map style.

setLocation(LatLng latlng)

Future<void>

Sets the location for the location source.

setLocationSource()

Future<void>

Sets the location source for the my-location layer.

deactivateLocationSource()

Future<void>

Deactivates the location source.

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 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 the zoom level of a map.

takeSnapshot()

Future<Uint8List?>

Takes a snapshot of a map.

Methods

[h2]clearTileCache

Clears the cache of a tile overlay. The method is asynchronous.

Parameter

Type

Description

tileOverlay

TileOverlay

TileOverlay object.

Return Type

Description

Future<void>

Future result of an execution that returns no value.

Call example:

// Define HuaweiMapController and TileOverlay.
HuaweiMapController mapController; 
TileOverlay tileOverlay; 
 
// Call the clearTileCache API.
await mapController.clearTileCache(tileOverlay);

[h2]startAnimationOnMarker

Starts the animation of a marker. The method is asynchronous.

Parameter

Type

Description

marker

Marker

Marker object.

Return Type

Description

Future<void>

Future result of an execution that returns no value.

Call example:

// Define HuaweiMapController and a Marker object with an animation.
HuaweiMapController mapController; 
Marker marker; 
 
// Call the startAnimationOnMarker API.
await mapController.startAnimationOnMarker(marker!);

[h2]animateCamera

Updates the camera position in animation mode. The method is asynchronous.

Parameter

Type

Description

cameraUpdate

CameraUpdate

Camera position change.

Return Type

Description

Future<void>

Future result of an execution that returns no value.

Call example:

// Define HuaweiMapController and a CameraUpdate object.
HuaweiMapController mapController; 
CameraUpdate cameraUpdate; 
 
// Call the animateCamera API.
await mapController.animateCamera(cameraUpdate);

[h2]stopAnimation

Stops the current animation of the camera. When this method is called, the camera stops moving immediately and remains in that position.

Return Type

Description

Future<void>

Future result of an execution that returns no value.

Call example:

// Define HuaweiMapController.
HuaweiMapController mapController; 
 
// Call the stopAnimation API.
await mapController.stopAnimation();

[h2]moveCamera

Updates the camera position in instantaneous mode. The method is asynchronous.

Parameter

Type

Description

cameraUpdate

CameraUpdate

Camera position change.

Return Type

Description

Future<void>

Future result of an execution that returns no value.

Call example:

// Define HuaweiMapController and a CameraUpdate object.
HuaweiMapController mapController; 
CameraUpdate cameraUpdate; 
 
// Call the moveCamera API.
await mapController.moveCamera(cameraUpdate);

[h2]setMapStyle

Sets the map style. The method is asynchronous.

Parameter

Type

Description

mapStyle

String

Map style as a JSON string.

Return Type

Description

Future<void>

Future result of an execution that returns no value.

Call example:

// Define HuaweiMapController.
HuaweiMapController mapController; 
 
// Call the setMapStyle API.
await mapController.setMapStyle("YOUR_MAP_STYLE_AS_JSON");

[h2]setLocation

Sets the location for the location source.

Parameter

Type

Description

latLng

LatLng

Preferred location.

Return Type

Description

Future<void>

Future result of an execution that returns no value.

Call example:

// Define HuaweiMapController.
HuaweiMapController mapController; 
 
// Call the setLocation API.
await mapController.setLocation(latLng);

[h2]setLocationSource

Sets the location source for the my-location layer.

Return Type

Description

Future<void>

Future result of an execution that returns no value.

Call example:

// Define HuaweiMapController.
HuaweiMapController mapController; 
 
// Call the setLocationSource API.
await mapController.setLocationSource();

[h2]deactivateLocationSource

Deactivates the location source.

Return Type

Description

Future<void>

Future result of an execution that returns no value.

Call example:

// Define HuaweiMapController.
HuaweiMapController mapController; 
 
// Call the deactivateLocationSource API.
await mapController.deactivateLocationSource();

[h2]getVisibleRegion

Obtains the visible region after conversion between the screen coordinates and longitude-latitude coordinates. The method is asynchronous.

Return Type

Description

Future<LatLngBounds>

Smallest bounding box that includes the visible region.

Call example:

// Define HuaweiMapController.
HuaweiMapController mapController; 
 
// Call the getVisibleRegion API.
LatLngBounds bounds = await mapController.getVisibleRegion();

[h2]getScreenCoordinate

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). The method is asynchronous.

Parameter

Type

Description

latLng

LatLng

Longitude and latitude of a location on the map.

Return Type

Description

Future<ScreenCoordinate>

Coordinates of a location on the screen, in pixels.

Call example:

// Define HuaweiMapController and a LatLng object.
HuaweiMapController mapController; 
LatLng latLng; 
 
// Call the getScreenCoordinate API.
ScreenCoordinate coordinate = await mapController.getScreenCoordinate(latLng);

[h2]getLatLng

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). The method is asynchronous.

Parameter

Type

Description

screenCoordinate

ScreenCoordinate

Coordinates of a location on the screen, in pixels.

Return Type

Description

Future<LatLng>

LatLng object that contains the corresponding longitude and latitude.

Call example:

// Define HuaweiMapController and a ScreenCoordinate object.
HuaweiMapController mapController; 
ScreenCoordinate screenCoordinate; 
 
// Call the getLatLng API.
LatLng latLng = await mapController.getLatLng(screenCoordinate);

[h2]showMarkerInfoWindow

Displays the information window for a marker. The method is asynchronous.

Parameter

Type

Description

markerId

MarkerId

Marker ID.

Return Type

Description

Future<void>

Future result of an execution that returns no value.

Call example:

// Define HuaweiMapController and a Marker object with an information window.
HuaweiMapController mapController; 
Marker marker; 
 
// Call the showMarkerInfoWindow API.
await mapController.showMarkerInfoWindow(marker.markerId);

[h2]hideMarkerInfoWindow

Hides the information window for a marker. This method is asynchronous and invalid for invisible markers.

Parameter

Type

Description

markerId

MarkerId

Marker ID.

Return Type

Description

Future<void>

Future result of an execution that returns no value.

Call example:

// Define HuaweiMapController and a Marker object with an information window.
HuaweiMapController mapController; 
Marker marker; 
 
// Call the hideMarkerInfoWindow API.
await mapController.hideMarkerInfoWindow(marker.markerId);

[h2]isMarkerInfoWindowShown

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

Parameter

Type

Description

markerId

MarkerId

Marker ID.

Return Type

Description

Future<bool?>

true if an information window is currently displayed for a marker; false otherwise.

Call example:

// Define HuaweiMapController and a Marker object with an information window.
HuaweiMapController mapController; 
Marker marker; 
 
// Call the isMarkerInfoWindowShown API.
bool? status = await mapController.isMarkerInfoWindowShown(marker.markerId);

[h2]isMarkerClusterable

Checks whether a marker can be clustered. The method is asynchronous.

Parameter

Type

Description

markerId

MarkerId

Marker ID.

Return Type

Description

Future<bool?>

true if the marker can be clustered; false otherwise.

Call example:

// Define HuaweiMapController and a Marker object with the clusterable feature.
HuaweiMapController mapController; 
Marker marker; 
 
// Call the isMarkerClusterable API.
bool? isClusterable = await mapController.isMarkerClusterable(marker.markerId);

[h2]getZoomLevel

Obtains the zoom level of a map. The method is asynchronous.

Return Type

Description

Future<double?>

Zoom level.

Call example:

// Define HuaweiMapController.
HuaweiMapController mapController; 
 
// Call the getZoomLevel API.
double? zoomLevel = await mapController.getZoomLevel();

[h2]takeSnapshot

Takes a snapshot of a map. The method is asynchronous.

Return Type

Description

Future<Uint8List?>

Uint8List data of an image.

Call example:

// Define HuaweiMapController.
HuaweiMapController mapController; 
 
// Call the takeSnapshot API.
Uint8List? imageData = await mapController.takeSnapshot();