Interface ActionFactory

Factory for creating Actions.

Hierarchy

  • ActionFactory

Methods

  • Creates an Action instance.

    The returned action must either be an object of type Action or an instance of a class derived from the class popups/Action.

    Parameters

    • type: string

      Type ID of action to be created.

    Returns undefined | Action

    action instance or undefined, if no Action could be created for this type.

    Example

    ActionFactory returning a properties object

    export default function TweetActionFactory() {
    return {
    createAction(type) {
    return {
    id: "tweetablePopups.action.tweet",
    type: "button",
    title: "Tweet Feature",
    className: "esri-icon-share2",
    trigger(context) {
    // Code to be performed, when the action is triggered,
    // for example if someone clicks the link that is displayed in the popup.

    const features = context.features; // All features that are hit by clicking on the map.
    const selectedFeature = context.selectedFeature; // The selected and visible feature in the popup.
    const location = context.location; // The point position where the popup is opened on the map.

    // Tweet it: for example selectedFeature.attributes.description ...
    }
    };
    },
    getTypes() {
    return ["tweet"];
    }
    };
    }

    Example

    ActionFactory returning an instance from a class extending popups/Action

    import Action from "popups/Action";

    class MyCustomAction extends Action {
    trigger(context) {
    // Do something when action is clicked
    }
    }

    class MyCustomActionFactory {
    getTypes() {
    return ["mycustomaction"];
    }
    createAction(type) {
    return new MyCustomAction({
    id: type,
    title: "customAction"
    });
    }
    }
  • Returns string[] | Promise<string[]>

    A list action IDs supported by this factory.

Generated using TypeDoc