map-actions

Provides a set of actions that perform common tasks on the map.

The interface of this bundle is described in detail in the API documentation.

Usage

This bundle provides an API to trigger common actions on the map.

Bundles have to inject the map-actions.ActionService to trigger actions:

actionService.trigger(["zoomto"], {
    "items": [{ geometry: "..." }],
    "zoomto-scale": 1000
});

Configuration Reference

The following actions are provided by this bundle:

Action ID Description
highlight The geometry of the first item passed to the action's trigger method is drawn to the map. The drawn graphic persists on the map indefinitely unless the highlight-remove-timeout property is set. This removes the graphic from the map after the given amount of milliseconds.
zoomto Sets the map extent to the geometry of the first search result item.
openpopup Opens the popup of the feature.

Highlight action options

The following options can be passed to the highlight action:

Property Type Description
highlight-remove-timeout Integer Number of milliseconds to wait before the highlight graphic is removed from the map again. If the value is not set or set to 0, the highlight graphic is not removed.
highlight-symbol-* Object Styles of the symbols used for the different geometry types. Replace * with the corresponding geometry type: point, polyline, polygon, point-3d, polyline-3d, polygon-3d. See Symbol Objects.

ZoomTo action options

The following options can be passed to the zoomto action:

Property Type Description
zoomto-scale Integer Scale to zoom to. No default value is defined.
zoomto-point-scale Integer Scale to zoom to if geometry is of type point. No default value is defined.
zoomto-extent-expansion-factor Integer Factor applied to the extent of a non-point input geometry. The expanded extent makes up the new zoom target geometry, so for a factor > 1 you get more map context around the input geometry. Only applies if zoomto-scale is not set.

Open Popup action options

The following options can be passed to the openpopup action:

Property Type Description
highlight-remove-timeout Integer Number of milliseconds to wait before the popup is closed. It reuses the option of the highlight action.
source Store If the feature is from a store, this reference to the store is needed to resolve the popup template.

Use Cases

Implementing custom actions

Developers can extend this bundle's functionality by providing custom actions.

An action is a class that must satisfy the following requirements:

class MyCustomAction {
    constructor() {
        // unique ID of the action
        this.id = "my-custom-id";
    }

    // trigger method which is called with the search result items
    trigger(options) {
        const items = options.items;
        const someProperty = options["my-custom-id-some-property"];

        // Do something with the items...
    }
}

To register the action as a service in map.apps add a component that provides the map-actions.Action interface to the manifest.json file of your bundle:

{
    "components": [
        {
            "name": "MyCustomAction",
            "provides": "map-actions.Action"
        }
    ]
}