Document Maps JavaScript API Reference Manual Map Controls Scale

Scale

AMap.Scale

Scale control. Located at the bottom-right corner of the map, users can control its display and hide. Inherits from AMap.Control. Constructs a scale object.

new AMap.Scale(opts: ControlConfig)

Parameter

opts (ControlConfig)Scale plugin parameters

Attribute

Type

Description

position

string | object

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

offset

[number, number]

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

Demo

AMap.plugin(["AMap.Scale"], function () {
  //Add a scale control to display the scale of the map at the current level and latitude
  var scale = new AMap.Scale();
  scale.addTo(map);
});

Method

addTo(map)

Add control to map

Parametermap (Map) Map instance

Demo:

scale.addTo(map);

remove()

Remove control from map

Demo:

scale.remove();

show()

Set control to visible

Demo:

scale.show();

hide()

Set control to hidden

Demo:

scale.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