Skip to main content

Scale Mode

You can handle Scale Mode for all layers on a map like this:

map.gm.enableGlobalScaleMode();
map.gm.disableGlobalScaleMode();
map.gm.toggleGlobalScaleMode();
map.gm.globalScaleModeEnabled();

// Or like this:
map.gm.enableMode('edit', 'scale');
map.gm.disableMode('edit', 'scale');
map.gm.toggleMode('edit', 'scale');
map.gm.isModeEnabled('edit', 'scale');

The following methods are available on map.gm:

MethodReturnsDescription
enableGlobalScaleMode()-Enables global Scale Mode.
disableGlobalScaleMode()-Disables global Scale Mode.
toggleGlobalScaleMode()-Toggles global Scale Mode.
globalScaleModeEnabled()BooleanReturns true if global Scale Mode is enabled. false when disabled.

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:scalestarteventFired when a layer starts being scaled.map, feature, shape
gm:scaleeventFired when a layer is being scaled.map, feature, shape
gm:scaleendeventFired when a layer stops being scaled.map, feature, shape

The following events are available on a map instance:

EventParamsDescriptionOutput
gm:globalscalemodetoggledeventFired when Scale Mode is toggled.enabled, map

You can also listen to specific Scale Mode events on the map instance like this:

map.on('gm:globalscalemodetoggled', (event) => {
console.log(event);
});

Supported Features

Scale mode supports the following feature types:

  • Polygons
  • Rectangles
  • Lines
  • Circles

When scaling, the feature will maintain its proportions relative to its centroid point. For rectangles, the scaling operation preserves the rectangular shape while adjusting its size.

Live Scale Example