Skip to content

Commit

Permalink
Fixes and improvements to identify on vector layers (#2051)
Browse files Browse the repository at this point in the history
* Fixes and improvements to identify on vector layers

* Fixed lint issues
  • Loading branch information
mbarto authored Jul 24, 2017
1 parent b170c52 commit 008969b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const PropTypes = require('prop-types');
*/

const React = require('react');
const {isString} = require('lodash');

const alwaysExcluded = ["exclude", "titleStyle", "listStyle", "componentStyle", "title"];

Expand Down Expand Up @@ -47,7 +48,7 @@ class PropertiesViewer extends React.Component {
.filter(this.toExlude)
.map((key) => {
return (
<p key={key} style={this.props.listStyle}><b>{key}</b> {this.props[key]}</p>
<p key={key} style={this.props.listStyle}><b>{key}</b> {this.renderProperty(this.props[key])}</p>
);
});
};
Expand Down Expand Up @@ -80,6 +81,12 @@ class PropertiesViewer extends React.Component {
);
};

renderProperty = (prop) => {
if (isString(prop)) {
return prop;
}
return JSON.stringify(prop);
};
render() {
return (
<div style={this.props.componentStyle}>
Expand Down
5 changes: 4 additions & 1 deletion web/client/components/map/leaflet/Feature.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ class Feature extends React.Component {
this._layer.on('click', (event) => {
if (this.props.onClick) {
this.props.onClick({
pixel: event.containerPoint,
pixel: {
x: event.originalEvent && event.originalEvent.x,
y: event.originalEvent && event.originalEvent.y
},
latlng: event.latlng
});
}
Expand Down
2 changes: 1 addition & 1 deletion web/client/reducers/mapInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function mapInfo(state = {}, action) {
}
let resolution = action.metadata && action.metadata.resolution || 1;
let bufferedPoint = buffer(point, (action.metadata.buffer || 1) * resolution, unit);
const intersected = action.layer.features.filter(
const intersected = (action.layer.features || []).filter(
(feature) => {
try {
// TODO: instead of create a fixed buffer, we should check the feature style to create the proper buffer.
Expand Down
2 changes: 1 addition & 1 deletion web/client/utils/mapinfo/vector.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
lng: props.point.latlng.lng
},
metadata: {
fields: Object.keys(layer.features[0].properties),
fields: layer.features && layer.features.length && Object.keys(layer.features[0].properties) || [],
title: layer.name,
resolution: props.map && props.map && props.map.zoom && MapUtils.getCurrentResolution(props.map.zoom, 0, 21, 96),
buffer: props.buffer,
Expand Down

0 comments on commit 008969b

Please sign in to comment.