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
:
Method | Returns | Description |
---|---|---|
enableGlobalScaleMode() | - | Enables global Scale Mode. |
disableGlobalScaleMode() | - | Disables global Scale Mode. |
toggleGlobalScaleMode() | - | Toggles global Scale Mode. |
globalScaleModeEnabled() | Boolean | Returns true if global Scale Mode is enabled. false when disabled. |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:scalestart | event | Fired when a layer starts being scaled. | map , feature , shape |
gm:scale | event | Fired when a layer is being scaled. | map , feature , shape |
gm:scaleend | event | Fired when a layer stops being scaled. | map , feature , shape |
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:globalscalemodetoggled | event | Fired 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.