AMAP

Updated at:

Introduction

The AMAP component is a versatile tool built on the AMAP API for creating geographic information visualizations. It integrates customizable maps, tool plugins, and a diverse marking system to provide an intuitive and professional solution for displaying and analyzing data for location-based services.

image

Configuration items

Category

Configuration

Example

Description

Content

Developer Key

The developer key. This is the API-KEY from the AMAP Open Platform console. Request a key for the web platform (JS API) in the AMAP management console. For more information, see the AMAP API reference.

Center longitude

The longitude of the map's current centroid.

Center latitude

The latitude of the map's current centroid.

Map mode

The map mode. Select 2D or 3D mode for the base map. In 3D mode, the map supports three-dimensional displays, such as city models.

Map zoom

The zoom level of the map's current centroid.

Point markers

image

Configures the point markers on the map. A point marker consists of the following properties:

  • id: The unique identifier for the marker in the code. It can be used in event handling to get the target clicked marker.

  • longitude: The longitude of the marker's coordinate.

  • latitude: The latitude of the marker's coordinate.

  • title: The title displayed for the marker.

Polygon markers

image

Configures the polygon markers on the map. A polygon marker consists of the following properties:

  • id: The unique identifier for the polygon marker in the code. It can be used in event handling to get the target clicked marker.

  • Path: An array that describes the position of the polygon marker. It uses a two-dimensional coordinate array to represent the coordinates of each vertex that forms the polygon. For example, [[116.4,39.9],[120.15,30.2],[121.3,31.2]] can represent a triangular marker with vertices at the coordinates of Beijing, Hangzhou, and Shanghai.

  • Fill color: The fill color inside the polygon marker.

  • Fill opacity: The opacity of the fill color inside the polygon marker.

  • Line width: The width of the polygon marker's outline.

  • Line style: The style of the polygon marker's outline. You can select a solid or dashed line.

  • Line color: The color of the polygon marker's outline.

  • Line opacity: The opacity of the polygon marker's outline color.

Map plugins

image

Select whether to enable the following plugins on the map:

  • Scale bar: Displays a scale bar for the current map zoom level in the lower-left corner of the map.

  • Control bar: Displays a control bar in the upper-left corner of the map for the compass, rotation, and tilt operations.

  • Toolbar: Displays a toolbar in the lower-right corner of the map to change the map's zoom level.

Interaction

Hide

Hides the component. For more information, see Common properties

Keep layout when hidden

Keeps the component's layout space when it is hidden. For more information, see Common properties

Style

Margin

The margin of the component. For more information, see Common properties

Theme style

Sets the display style of the base map. For more information, see AMAP Custom Themes.

Properties and methods

Name

Type

Example

Description

longitude

number

gaodeMap.longitude

The longitude of the map's centroid.

latitude

number

gaodeMap.latitude

The latitude of the map's centroid.

zoom

number

gaodeMap.zoom

The zoom level of the map's centroid.

markers

Array<{

id: string;

longitude: number;

latitude: number;

label: string

}>

gaodeMap.markers

A collection of all point markers on the map.

polygon

Array<{

id: string;

pathArr: (number, number)[];

strokeStyle: string;

fillColor: string;

fillOpacity: string;

strokeWeight: string;

strokeOpacity: string

}>

gaodeMap.polygon

A collection of all polygon markers on the map.

currentSelectedPointId

string

gaodeMap.currentSelectedPointId

The currently selected point marker.

currentSelectedPolygonId

string

gaodeMap.currentSelectedPolygonId

The currently selected polygon marker.

clearLongitude

function

gaodeMap.clearLongitude()

Clears the longitude coordinate of the map's center.

setLongitude

func

gaodeMap.setLongitude(6.4)

Sets the longitude coordinate of the map's center.

clearLatitude

function

gaodeMap.clearLatitude()

Clears the latitude coordinate of the map's center.

setLatitude

function

gaodeMap.setLatitude(39.9)

Sets the latitude coordinate of the map's center.

clearZoom

function

gaodeMap.clearZoom()

Clears the zoom level of the map's center.

setZoom

function

gaodeMap.setZoom(10)

Sets the zoom level of the map's center.

clearCurrentSelectedPointId

func

gaodeMap.clearCurrentSelectedPointId()

Clears the currently selected point marker on the map.

setCurrentSelectedPointId

function

gaodeMap.setCurrentSelectedPointId('Beijing')

Sets the currently selected point marker on the map.

setCurrentSelectedPolygonId

function

gaodeMap.setCurrentSelectedPolygonId('Beijing')

Sets the currently selected polygon marker on the map.

clearCurrentSelectedPolygonId

function

gaodeMap.clearCurrentSelectedPolygonId()

Clears the currently selected polygon marker on the map.

panTo

func

gaodeMap.panTo([116.4,39.9])

Moves the map center to the specified coordinates.

Event callbacks

Configuration

Description

The event that is triggered when a point marker is selected.

The event that is triggered when a polygon marker is selected.