Scale Mode ⭐
Scale Mode ⭐
You can enable Scale Mode for all layers on a map like this:
map.pm.enableGlobalScaleMode();
With the option centerScaling the scale origin cen be the center of the layer or the opposite corner of the dragged marker. If false Alt-Key can be used.
The option uniformScaling the scales the width and the height with the same ratio. If false Shift-Key can be used.
The following methods are available on map.pm:
| 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. |
| cancelGlobalScaleMode() | - | Reverts the layers to the state before changing. |
The following methods are available for layers under layer.pm:
| Method | Returns | Description |
|---|---|---|
| enableScale() | - | Enables Scale Mode on the layer. |
| disableScale() | - | Disables Scale Mode on the layer. |
| scaleEnabled() | Boolean | Returns if Scale Mode is enabled for the layer. |
scaleLayer(percent) | - | Scale the layer by x percent. Also an Object with {w: width, h: height} can be passed. Scale up > 0 , scale down < 0. |
| cancel() | - | Reverts the layer to the state before changing. |
The following events are available on a layer instance:
| Event | Params | Description | Output |
|---|---|---|---|
| pm:scaleenable | e | Fired when scale is enabled for a layer. | layer, helpLayer |
| pm:scaledisable | e | Fired when scale is disabled for a layer. | layer |
| pm:scalestart | e | Fired when scale starts on a layer. | layer, helpLayer, originLatLngs |
| pm:scale | e | Fired when a layer is scaled. | layer, helpLayer, oldLatLngs, newLatLngs |
| pm:scaleend | e | Fired when scale ends on a layer. | layer, helpLayer, originLatLngs, newLatLngs |
| pm:change | e | Fired coordinates of the layer changed. | layer, latlngs, shape |
| pm:cancel | e | Fired when the layer changes are canceled. | layer |
The following events are available on a map instance:
| Event | Params | Description | Output |
|---|---|---|---|
| pm:globalscalemodetoggled | e | Fired when Scale Mode is toggled. | enabled, map |
| pm:scaleenable | e | Fired when scale is enabled for a layer. | layer, helpLayer |
| pm:scaledisable | e | Fired when scale is disabled for a layer. | layer |
| pm:scalestart | e | Fired when scale starts on a layer. | layer, helpLayer, originLatLngs, originLatLngs |
| pm:scale | e | Fired when a layer is scaled. | layer, helpLayer, oldLatLngs, newLatLngs |
| pm:scaleend | e | Fired when scale ends on a layer. | layer, helpLayer, originLatLngs, newLatLngs |
| pm:globalcancel | e | Fired when cancel of a Mode is called. | map |
Example
Loading...