2016-12-24 15:24:22 +01:00
|
|
|
import React from 'react'
|
2016-12-24 17:24:24 +01:00
|
|
|
import InputBlock from '../inputs/InputBlock'
|
|
|
|
import StringInput from '../inputs/StringInput'
|
2016-12-25 17:46:18 +01:00
|
|
|
import LayerIcon from '../icons/LayerIcon'
|
2016-12-24 17:24:24 +01:00
|
|
|
|
|
|
|
|
2016-12-25 17:46:18 +01:00
|
|
|
function groupFeaturesBySourceLayer(features) {
|
|
|
|
const sources = {}
|
|
|
|
features.forEach(feature => {
|
|
|
|
sources[feature.layer['source-layer']] = sources[feature.layer['source-layer']] || []
|
|
|
|
sources[feature.layer['source-layer']].push(feature)
|
|
|
|
})
|
|
|
|
return sources
|
|
|
|
}
|
2016-12-24 17:24:24 +01:00
|
|
|
|
2017-01-09 23:04:08 +01:00
|
|
|
class FeatureLayerPopup extends React.Component {
|
2016-12-24 15:24:22 +01:00
|
|
|
render() {
|
2016-12-25 17:46:18 +01:00
|
|
|
const sources = groupFeaturesBySourceLayer(this.props.features)
|
|
|
|
|
|
|
|
const items = Object.keys(sources).map(vectorLayerId => {
|
2017-01-09 23:04:08 +01:00
|
|
|
const layers = sources[vectorLayerId].map((feature, idx) => {
|
|
|
|
return <label
|
|
|
|
key={idx}
|
2017-01-11 11:35:33 +01:00
|
|
|
className="maputnik-popup-layer"
|
|
|
|
>
|
2016-12-25 17:46:18 +01:00
|
|
|
<LayerIcon type={feature.layer.type} style={{
|
2017-01-11 11:35:33 +01:00
|
|
|
width: 14,
|
|
|
|
height: 14,
|
|
|
|
paddingRight: 3
|
2016-12-25 17:46:18 +01:00
|
|
|
}}/>
|
|
|
|
{feature.layer.id}
|
|
|
|
</label>
|
|
|
|
})
|
2017-01-10 09:38:27 +01:00
|
|
|
return <div key={vectorLayerId}>
|
2017-01-11 11:35:33 +01:00
|
|
|
<div className="maputnik-popup-layer-id">{vectorLayerId}</div>
|
2016-12-25 17:46:18 +01:00
|
|
|
{layers}
|
|
|
|
</div>
|
|
|
|
})
|
|
|
|
|
2017-01-11 11:35:33 +01:00
|
|
|
return <div className="maputnik-feature-layer-popup">
|
2016-12-25 17:46:18 +01:00
|
|
|
{items}
|
2016-12-24 17:24:24 +01:00
|
|
|
</div>
|
2016-12-24 15:24:22 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-09 23:04:08 +01:00
|
|
|
export default FeatureLayerPopup
|