Document Maps JavaScript API Advanced Tutorial Map Interactions and Events of the Map

Interactions and Events of the Map

This article describes map interactions and events:

  1. Map Interaction: Amap JS API 2.0 provides rich map interaction features, including zooming, panning, rotating, and more. Users can operate the map through gestures or a mouse for a better map browsing experience.
  2. Map Events: Briefly introduce map event binding methods and callback content. For more events, please visit Map and Overlay Events.

Map Interaction Instructions

Interactive properties can be added and configured when initializing the map AMap.Map() to enable or disable corresponding properties. If no corresponding property is added, the property will be enabled by default.

2D / 3D Mode

PC End

Interactive Operation

Function

Related properties

Optional value

Mouse wheel

Zoom the map

scrollWheel

true | false

Double-click the left mouse button (right mouse button)

Zoom in the map (Zoom out the map)

doubleClickZoom

true | false

Drag with the mouse

Move the map

dragEnable

true | false

Up, Down, Left, Right on the keyboard

Move the map

keyboardEnable

true | false

Mobile

Interactive Operation

Function

Related properties

Optional value

Pinch with two fingers

Zoom the map

touchZoom

true | false

Single-finger swipe

Move the map

dragEnable

true | false

3D mode

PC End

Interactive Operation

Function

Related properties

Optional value

Right-click + mouse up and down move or Ctrl + left-click up and down move

Change map tilt angle

pitchEnable

true | false

Right-click + mouse circle move or Ctrl + left-click circle move

Change map rotation angle

rotateEnable

true | false

Mobile

Interactive Operation

Function

Related properties

Optional value

Rotate two fingers on the map

Change the map rotation angle

rotateEnable

true | false

Slide two fingers up and down

Change the map tilt

pitchEnable

true | false

Map events

Map events are triggered after operations on the Map's base layer. The event callback returns a MapsEvent object, which contains information such as the target object of the trigger and the latitude and longitude of the trigger.

map.on("click", function (ev) {
  //Object of the triggering event
  var target = ev.target;
  //Geographic coordinates of the triggering event, AMap.LngLat type
  var lnglat = ev.lnglat;
  //Pixel coordinates of the triggering event, AMap.Pixel type
  var pixel = ev.pixel;
  //Trigger Event Type
  var type = ev.type;
});

For more event system usage, please go to the map and overlay events.