Scale Mode
You can handle Scale Mode for all layers on a map 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 |
|---|---|---|
enableMode('edit', 'scale') | - | Enables global Scale Mode. |
disableMode('edit', 'scale') | - | Disables global Scale Mode. |
toggleMode('edit', 'scale') | - | Toggles global Scale Mode. |
isModeEnabled('edit', 'scale') | 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.
Live Scale Example
Building something complex? Our team can help with architecture and integration. Get in touch →