32 |
{feature.layer['source']}: {feature.layer['source-layer']}{feature.inspectModeCounter && × {feature.inspectModeCounter}}
33 |
34 |
35 |
36 | {renderFeatureId(feature)}
37 | {renderProperties(feature)}
38 |
39 | }
40 |
41 | function removeDuplicatedFeatures(features) {
42 | let uniqueFeatures = [];
43 |
44 | features.forEach(feature => {
45 | const featureIndex = uniqueFeatures.findIndex(feature2 => {
46 | return feature.layer['source-layer'] === feature2.layer['source-layer']
47 | && JSON.stringify(feature.properties) === JSON.stringify(feature2.properties)
48 | })
49 |
50 | if(featureIndex === -1) {
51 | uniqueFeatures.push(feature)
52 | } else {
53 | if(uniqueFeatures[featureIndex].hasOwnProperty('inspectModeCounter')) {
54 | uniqueFeatures[featureIndex].inspectModeCounter++
55 | } else {
56 | uniqueFeatures[featureIndex].inspectModeCounter = 2
57 | }
58 | }
59 | })
60 |
61 | return uniqueFeatures
62 | }
63 |
64 | class FeaturePropertyPopup extends React.Component {
65 | static propTypes = {
66 | features: PropTypes.array
67 | }
68 |
69 | render() {
70 | const features = removeDuplicatedFeatures(this.props.features)
71 | return
66 |
67 | [propName, propName])}
71 | onChange={newPropertyName => this.onFilterPartChanged(filterOp, newPropertyName, filterArgs)}
72 | />
73 |
74 |
75 | this.onFilterPartChanged(newFilterOp, propertyName, filterArgs)}
79 | options={otherFilterOps}
80 | />
81 |
82 | {filterArgs.length > 0 &&
83 |
84 | this.onFilterPartChanged(filterOp, propertyName, v.split(','))}
88 | />
89 |
90 | }
91 |
92 | }
93 |
94 | }
95 |
96 |
--------------------------------------------------------------------------------
/stories/MapOpenLayers.stories.js:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import MapOpenLayers from '../src/components/MapOpenLayers';
3 | import {action} from '@storybook/addon-actions';
4 | import {Wrapper} from './ui';
5 | import {withA11y} from '@storybook/addon-a11y';
6 |
7 |
8 | export default {
9 | title: 'MapOpenLayers',
10 | component: MapOpenLayers,
11 | decorators: [withA11y],
12 | };
13 |
14 | const mapStyle = {
15 | "version": 8,
16 | "sources": {
17 | "test1": {
18 | "type": "geojson",
19 | "data": {
20 | "type": "FeatureCollection",
21 | "features": [
22 | {
23 | "type": "Feature",
24 | "geometry": {
25 | "type": "Point",
26 | "coordinates": [0, -10]
27 | },
28 | "properties": {}
29 | }
30 | ]
31 | }
32 | },
33 | "test2": {
34 | "type": "geojson",
35 | "data": {
36 | "type": "FeatureCollection",
37 | "features": [
38 | {
39 | "type": "Feature",
40 | "geometry": {
41 | "type": "Point",
42 | "coordinates": [15, 10]
43 | },
44 | "properties": {}
45 | }
46 | ]
47 | }
48 | },
49 | "test3": {
50 | "type": "geojson",
51 | "data": {
52 | "type": "FeatureCollection",
53 | "features": [
54 | {
55 | "type": "Feature",
56 | "geometry": {
57 | "type": "Point",
58 | "coordinates": [-15, 10]
59 | },
60 | "properties": {}
61 | }
62 | ]
63 | }
64 | }
65 | },
66 | "sprite": "",
67 | "glyphs": "https://orangemug.github.io/font-glyphs/glyphs/{fontstack}/{range}.pbf",
68 | "layers": [
69 | {
70 | "id": "test1",
71 | "type": "circle",
72 | "source": "test1",
73 | "paint": {
74 | "circle-radius": 40,
75 | "circle-color": "red"
76 | }
77 | },
78 | {
79 | "id": "test2",
80 | "type": "circle",
81 | "source": "test2",
82 | "paint": {
83 | "circle-radius": 40,
84 | "circle-color": "green"
85 | }
86 | },
87 | {
88 | "id": "test3",
89 | "type": "circle",
90 | "source": "test3",
91 | "paint": {
92 | "circle-radius": 40,
93 | "circle-color": "blue"
94 | }
95 | }
96 | ]
97 | }
98 |
99 | export const Basic = () => {
100 | return