diff --git a/web/client/components/map/openlayers/Feature.jsx b/web/client/components/map/openlayers/Feature.jsx index d5f4645456..b3bd7c5abe 100644 --- a/web/client/components/map/openlayers/Feature.jsx +++ b/web/client/components/map/openlayers/Feature.jsx @@ -16,7 +16,13 @@ let Feature = React.createClass({ properties: React.PropTypes.object, container: React.PropTypes.object, // TODO it must be a ol.layer.vector (maybe pass the source is more correct here?) geometry: React.PropTypes.object, // TODO check for geojson format for geometry - msId: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]) + msId: React.PropTypes.oneOfType([React.PropTypes.string, React.PropTypes.number]), + featuresCrs: React.PropTypes.string + }, + getDefaultProps() { + return { + featuresCrs: "EPSG:4326" + }; }, componentDidMount() { const format = new ol.format.GeoJSON(); @@ -24,7 +30,7 @@ let Feature = React.createClass({ if (this.props.container && geometry) { this._feature = format.readFeatures({type: this.props.type, properties: this.props.properties, geometry: this.props.geometry, id: this.props.msId}); - this._feature.forEach((f) => f.getGeometry().transform('EPSG:4326', 'EPSG:3857')); // TODO support map reference system + this._feature.forEach((f) => f.getGeometry().transform(this.props.featuresCrs, 'EPSG:3857')); this.props.container.getSource().addFeatures(this._feature); } }, @@ -36,7 +42,7 @@ let Feature = React.createClass({ if (newProps.container && geometry) { this._feature = format.readFeatures({type: newProps.type, properties: newProps.properties, geometry: newProps.geometry, id: this.props.msId}); - this._feature.forEach((f) => f.getGeometry().transform('EPSG:4326', 'EPSG:3857')); // TODO support map reference system + this._feature.forEach((f) => f.getGeometry().transform(newProps.featuresCrs, 'EPSG:3857')); newProps.container.getSource().addFeatures(this._feature); } } diff --git a/web/client/plugins/Map.jsx b/web/client/plugins/Map.jsx index 5deb11a528..6644f214e0 100644 --- a/web/client/plugins/Map.jsx +++ b/web/client/plugins/Map.jsx @@ -74,6 +74,7 @@ const MapPlugin = React.createClass({ type={feature.type} geometry={feature.geometry} msId={feature.id} + featuresCrs={ layer.featuresCrs || 'EPSG:4326' } // FEATURE STYLE OVERWRITE LAYER STYLE style={ feature.style || layer.style || null }/> );