diff --git a/web/client/plugins/Map.jsx b/web/client/plugins/Map.jsx index 62c36ab984..d7e41f9ced 100644 --- a/web/client/plugins/Map.jsx +++ b/web/client/plugins/Map.jsx @@ -14,7 +14,7 @@ var Spinner = require('react-spinkit'); require('./map/css/map.css'); const Message = require('../components/I18N/Message'); - +const {isString} = require('lodash'); let plugins; const MapPlugin = React.createClass({ @@ -76,6 +76,25 @@ const MapPlugin = React.createClass({ })} ); }, + getTool(tool) { + if (isString(tool)) { + return { + name: tool, + impl: plugins.tools[tool] + }; + } + return tool[this.props.mapType] || tool; + }, + renderLayers() { + const projection = this.props.map.projection || 'EPSG:3857'; + return this.props.layers.map((layer, index) => { + return ( + + {this.renderLayerContent(layer)} + + ); + }).concat(this.props.features && this.props.features.length && this.getHighlightLayer(projection, this.props.layers.length) || []); + }, renderLayerContent(layer) { if (layer.features && layer.type === "vector") { return layer.features.map( (feature) => { @@ -93,21 +112,11 @@ const MapPlugin = React.createClass({ } return null; }, - renderLayers() { - const projection = this.props.map.projection || 'EPSG:3857'; - return this.props.layers.map((layer, index) => { - return ( - - {this.renderLayerContent(layer)} - - ); - }).concat(this.props.features && this.props.features.length && this.getHighlightLayer(projection, this.props.layers.length) || []); - }, renderSupportTools() { return this.props.tools.map((tool) => { - const Tool = plugins.tools[tool]; - const options = (this.props.toolsOptions[tool] && this.props.toolsOptions[tool][this.props.mapType]) || this.props.toolsOptions[tool] || {}; - return ; + const Tool = this.getTool(tool); + const options = (this.props.toolsOptions[Tool.name] && this.props.toolsOptions[Tool.name][this.props.mapType]) || this.props.toolsOptions[Tool.name] || {}; + return ; }); }, render() {