origo-map / multiselect-plugin

Multiselect plugin for Origo
MIT License
2 stars 10 forks source link
plugin

Multiselect plugin

PLEASE NOTE THAT THIS IS A BETA VERSION

Multiselect plugin for Origo. It adds a new toolbox that contains tools for selecting features using more advanced methods than origo natively supports.

Features can be selected using:

Usage

The plugin is added to origo by including the multiselect.min.js script. It contains one publicly available function Multiselect(), which creates a origo component, which in turn is added to origo. The plugin is configured in javascript using an optional argument to Multiselect().

Example usage of Multiselect plugin

index.html:

    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
        <meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1">
        <title>Origo exempel</title>
        <link href="https://github.com/origo-map/multiselect-plugin/blob/main/css/style.css" rel="stylesheet">
    </head>
    <body>
    <div id="app-wrapper">
    </div>
    <script src="https://github.com/origo-map/multiselect-plugin/raw/main/js/origo.js"></script>
    <script src="https://github.com/origo-map/multiselect-plugin/raw/main/plugins/multiselect.min.js"></script>

    <script type="text/javascript">
      //Init origo
      var origo = Origo('index.json');
      origo.on('load', function (viewer) {
        const msConfig = {
          lineBufferFactor: 5
        };
        var multiselect = Multiselect(msConfig);
        viewer.addComponent(multiselect);
      });
    </script>

Options

The optional argument to Multiselect is an object which can have the following properties:

Property Description Default value
tools Which tools are available. Array of ['click', 'box', 'circle', 'polygon', 'buffer', 'line']. All
default Which tool is default (string) 'click'
lineBufferFactor How much a line should be buffered before intersecting (pixels) 1
selectableLayers Array of available layerConfigurations. If more than one layerConfiguration is present, a configuration selector tool is available. All visible
currentLayerConfig Index of the selected layerConfiguration at startup 0
pointBufferFactor How much a point should be buffered before intersecting when using click tool. Does not apply if active configuration is All visible, as that uses featureInfo hitTolerance setting. 1
bufferSymbol Name of a symbol in origo configuration to use as symbol for buffered objects. Symbol is always a polygon. A built-in symbol
chooseSymbol Name of a symbol in origo configuration to use as symbol for highlighted features when choosing which feature to buffer. Symbol should handle point, line and polygon. A built-in symbol
warnOnNoHits Wether an alert should be displayed or not when no features to select is found. (bool) false

layerConfiguration

A layerConfiguration specifies in which layers features are selected. The default behaviour is to select features in all currently visible layers, but when a layerConfiguration that specifies layers or groups, features are always selected from those layers regardeless of their visibility and not from any other layers.

Property Description Required
name Name of the configuration. Displayed in the configuration selection tool Yes
layers Array of layer names that features are selected from. If omitted all visible layers are used. If layer name is a group layer, all layers in the group are included unless explicitly excluded. No
exclude Array of layer names that are excluded from feature selection. No

Example:

const selectableLayers = [
            {
                name: 'All visible'
            },
            {
                name: 'The big selection',
                layers: [
                    "InterestingPoints",
                    "InterestingLines",
                    "sketchgroup"
                ],
                exclude: [
                    "SketchPoint"
                ]
            },
            {
                name: 'Something completely different',
                layers: [
                    "Junkyards",
                    "Campsites"
                ]
            }
        ];

Known limitations