Support Tools


The Map plugin allows adding mapping library dependent functionality using support tools. Some are already available for the supported mapping libraries (openlayers, leaflet, cesium), but it's possible to develop new ones.

An example is the MeasurementSupport tool that allows implementing measurement on a map.

The list of enabled tools can be configured using the tools property, as in the following example:

{
      "name": "Map",
      "cfg": {
        "tools": ["measurement", "locate", "overview", "scalebar", "draw", "highlight"]
        ...
      }
}

Each tool can be configured using the toolsOptions. Tool configuration can be mapping library dependent:

"toolsOptions": {
    "scalebar": {
        "leaflet": {
            "position": "bottomright"
        }
        ...
    }
    ...
}

or not:

"toolsOptions": {
    "scalebar": {
        "position": "bottomright"
        ...
    }
    ...
}

Custom Support Tools

In addition to standard tools, you can also develop your own, ad configure them to be used. To do that you need to:

const React = require('react');

class TestSupport extends React.Component {
    static propTypes = {
        label: PropTypes.string
    };

    render() {
        alert(this.props.label);
        return null;
    }
}

module.exports = TestSupport;
module.exports = {
    plugins: {
        MapPlugin: require('../plugins/Map'),
        ...
    },
    requires: {
        ...
        TestSupportLeaflet: require('../components/map/leaflet/TestSupport')
    }
};
{
  "name": "Map",
  "cfg": {
    "tools": ["measurement", "locate", "overview", "scalebar", "draw", {
      "leaflet": {
        "name": "test",
        "impl": "{context.TestSupportLeaflet}"
      }
      }],
    "toolsOptions": {
      "test": {
        "label": "Hello"
      }
      ...
    }
  }
}

NOTE: When using the "impl" configuration you are responsible for the correct configuration of such tool, remember to add any other property it may require in the configuration.