@performant-software/geospatial 1.1.3 → 1.1.4-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import type { FeatureCollection } from '@peripleo/peripleo';
|
|
3
|
-
import { Peripleo, Controls } from '@peripleo/peripleo';
|
|
4
|
-
import { Map, MixedGeoJSONLayer, PulsingMarkerLayer, Zoom } from '@peripleo/maplibre';
|
|
5
|
-
import { DEFAULT_FILL_STYLE, DEFAULT_POINT_STYLE, DEFAULT_STROKE_STYLE } from './CoreDataPlaceStyles';
|
|
6
|
-
|
|
7
|
-
type CoreDataPlaceProps = {
|
|
8
|
-
mapStyle: string | object;
|
|
9
|
-
placeURI: string;
|
|
10
|
-
fillStyle?: object;
|
|
11
|
-
pointStyle?: object;
|
|
12
|
-
strokeStyle?: object;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const CoreDataPlace = (props: CoreDataPlaceProps) => {
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<Peripleo>
|
|
19
|
-
<Map style={props.mapStyle}>
|
|
20
|
-
<Controls position="topright">
|
|
21
|
-
<Zoom />
|
|
22
|
-
</Controls>
|
|
23
|
-
|
|
24
|
-
<CoreDataPlaceLayer
|
|
25
|
-
uri={props.placeURI}
|
|
26
|
-
fillStyle={props.fillStyle}
|
|
27
|
-
pointStyle={props.pointStyle}
|
|
28
|
-
strokeStyle={props.strokeStyle} />
|
|
29
|
-
</Map>
|
|
30
|
-
</Peripleo>
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
type CoreDataPlaceLayerProps = {
|
|
36
|
-
uri: string;
|
|
37
|
-
fillStyle?: object;
|
|
38
|
-
pointStyle?: object;
|
|
39
|
-
strokeStyle?: object;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const CoreDataPlaceLayer = (props: CoreDataPlaceLayerProps) => {
|
|
43
|
-
|
|
44
|
-
const [place, setPlace] = useState<FeatureCollection | undefined>(undefined);
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
fetch(props.uri)
|
|
48
|
-
.then(res => res.json())
|
|
49
|
-
.then(data => {
|
|
50
|
-
const place = {
|
|
51
|
-
...data,
|
|
52
|
-
properties: {
|
|
53
|
-
...data.properties,
|
|
54
|
-
record_id: data.record_id
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
setPlace({
|
|
59
|
-
type: 'FeatureCollection',
|
|
60
|
-
features: [place]
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}, [props.uri])
|
|
64
|
-
|
|
65
|
-
return place && (
|
|
66
|
-
<>
|
|
67
|
-
<PulsingMarkerLayer
|
|
68
|
-
id="current"
|
|
69
|
-
data={place} />
|
|
70
|
-
|
|
71
|
-
<MixedGeoJSONLayer
|
|
72
|
-
id={props.uri}
|
|
73
|
-
data={place}
|
|
74
|
-
fillStyle={props.fillStyle || DEFAULT_FILL_STYLE}
|
|
75
|
-
strokeStyle={props.strokeStyle || DEFAULT_STROKE_STYLE}
|
|
76
|
-
pointStyle={props.pointStyle || DEFAULT_POINT_STYLE} />
|
|
77
|
-
</>
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_POINT_STYLE = {
|
|
2
|
-
'type': 'circle',
|
|
3
|
-
'paint': {
|
|
4
|
-
'circle-radius': [
|
|
5
|
-
'interpolate',
|
|
6
|
-
['linear'],
|
|
7
|
-
['number', ['get','point_count'], 1 ],
|
|
8
|
-
0, 4,
|
|
9
|
-
10, 14
|
|
10
|
-
],
|
|
11
|
-
'circle-stroke-width': 1,
|
|
12
|
-
'circle-color': [
|
|
13
|
-
'case',
|
|
14
|
-
['boolean', ['feature-state', 'hover'], false],
|
|
15
|
-
'#3b62ff',
|
|
16
|
-
'#ff623b'
|
|
17
|
-
],
|
|
18
|
-
'circle-stroke-color': '#8d260c'
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const DEFAULT_FILL_STYLE = {
|
|
23
|
-
'type': 'fill',
|
|
24
|
-
'paint': {
|
|
25
|
-
'fill-color': '#ff623b',
|
|
26
|
-
'fill-opacity': 0.2
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const DEFAULT_STROKE_STYLE = {
|
|
31
|
-
'type': 'line',
|
|
32
|
-
'paint': {
|
|
33
|
-
'line-color': '#ff623b',
|
|
34
|
-
'line-opacity': 0.6
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
Children,
|
|
5
|
-
cloneElement,
|
|
6
|
-
useEffect,
|
|
7
|
-
useState
|
|
8
|
-
} from 'react';
|
|
9
|
-
import { createPortal } from 'react-dom';
|
|
10
|
-
import { MapboxMap, useControl } from 'react-map-gl';
|
|
11
|
-
import { IControl } from 'maplibre-gl';
|
|
12
|
-
import _ from 'underscore';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Layer control implementation.
|
|
16
|
-
*/
|
|
17
|
-
class LayerControl implements IControl {
|
|
18
|
-
_map: MapboxMap = null;
|
|
19
|
-
_container: HTMLElement;
|
|
20
|
-
_redraw: () => void;
|
|
21
|
-
|
|
22
|
-
constructor(redraw: () => void) {
|
|
23
|
-
this._redraw = redraw;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
onAdd(map) {
|
|
27
|
-
this._map = map;
|
|
28
|
-
map.on('move', this._redraw);
|
|
29
|
-
|
|
30
|
-
this._container = document.createElement('div');
|
|
31
|
-
this._container.className = 'maplibregl-ctrl-group maplibregl-ctrl';
|
|
32
|
-
this._redraw();
|
|
33
|
-
return this._container;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
onRemove() {
|
|
37
|
-
this._container.remove();
|
|
38
|
-
this._map.off('move', this._redraw);
|
|
39
|
-
this._map = null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
getMap() {
|
|
43
|
-
return this._map;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
getElement() {
|
|
47
|
-
return this._container;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Layer container.
|
|
53
|
-
*
|
|
54
|
-
* @param props
|
|
55
|
-
*
|
|
56
|
-
* @returns {React$Portal}
|
|
57
|
-
*/
|
|
58
|
-
const LayerMenuContainer = (props) => {
|
|
59
|
-
const [, setVersion] = useState(0);
|
|
60
|
-
|
|
61
|
-
const ctrl = useControl(() => {
|
|
62
|
-
const forceUpdate = () => setVersion((v) => v + 1);
|
|
63
|
-
return new LayerControl(forceUpdate);
|
|
64
|
-
}, { position: props.position });
|
|
65
|
-
|
|
66
|
-
const map = ctrl.getMap();
|
|
67
|
-
|
|
68
|
-
const children = Children.map(_.compact(props.children), (child) => cloneElement(child, { map }));
|
|
69
|
-
|
|
70
|
-
useEffect(() => {
|
|
71
|
-
if (props.mapRef) {
|
|
72
|
-
// eslint-disable-next-line no-param-reassign
|
|
73
|
-
props.mapRef.current = map;
|
|
74
|
-
}
|
|
75
|
-
}, [map, props.mapRef]);
|
|
76
|
-
|
|
77
|
-
return map && createPortal(children, ctrl.getElement());
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export default LayerMenuContainer;
|