Zoom to Features Helper Mode
The Zoom to Features Helper Mode allows users to zoom the map to fit all displayed features within the viewport, making it easier to locate and view all active map features at once.
You can enable Zoom to Features Helper Mode with the following method:
map.gm.enableMode('helper', 'zoom_to_features');
map.gm.disableMode('helper', 'zoom_to_features');
map.gm.toggleMode('helper', 'zoom_to_features');
map.gm.isModeEnabled('helper', 'zoom_to_features');
Events for Zoom to Features Helper Mode
The following events are available on a map instance:
Event | Params | Description | Output |
---|---|---|---|
gm:globalzoom_to_featuresmodetoggled | event | Fired when Zoom to Features Mode is toggled. | enabled , map |
Example Usage
You can listen for specific Zoom to Features Helper Mode events on the map instance like this:
map.on('gm:globalzoom_to_featuresmodetoggled', (event) => {
console.log(event);
});
Behavior
When Zoom to Features Mode is activated:
- Map Adjustment: Automatically calculates the bounding box to encompass all visible features.
- Padding: Adds a 20-pixel padding around the features to ensure they fit well within the view.