Skip to main content

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:

EventParamsDescriptionOutput
gm:globalzoom_to_featuresmodetoggledeventFired 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:

  1. Map Adjustment: Automatically calculates the bounding box to encompass all visible features.
  2. Padding: Adds a 20-pixel padding around the features to ensure they fit well within the view.

Live Zoom to Features Example