Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honour layers.featuresCrs also in Feature.jsx #1197

Merged
merged 1 commit into from
Oct 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions web/client/components/map/openlayers/Feature.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,21 @@ 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();
const geometry = this.props.geometry && this.props.geometry.coordinates;

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);
}
},
Expand All @@ -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);
}
}
Expand Down
1 change: 1 addition & 0 deletions web/client/plugins/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }/>
);
Expand Down