Document Maps JavaScript API Reference Manual Map Controls ControlBar

ControlBar

AMap.ControlBar

A map control that combines rotation, tilt, and reset. Construct a control compass object

new AMap.ControlBar(opts: ControlConfig)

Parameter

opts (ControlConfig)Control compass control parameters

Attribute

Type

Description

position

string | object

Control docking position { top: "5px", left: "5px", right: "5px", bottom: "5px" } or 'LT': top-left corner, 'RT': top-right corner, 'LB': bottom-left corner, 'RB': bottom-right corner. Default 'LT': top-left corner

offset

[number, number]

The offset relative to the position, a positive offset means an offset within the map, i.e., moving inward

showControlButton

boolean

Whether to display the tilt and rotate buttons. Default value: true

Demo

map.plugin(["AMap.ControlBar"], function () {
  //Instantiate control
  var controlBar = new AMap.ControlBar({
    position: "LT",
    offset: [10, 10],
  });
  map.addControl(controlBar);
});

Method

addTo(map)

Add control to map

Parametermap (Map) 地图实例

Demo:

controlBar.addTo(map);

remove()

Remove control from map

Demo:

controlBar.remove();

show()

Set control visibility

Demo:

controlBar.show();

hide()

Hide control settings

Demo:

controlBar.hide();

Event

Event Name

Description

show

Trigger this event when displayed

hide

This event is triggered when hidden

For event object property descriptions, go to:MapsEvent