@performant-software/geospatial 1.2.0-beta.0 → 1.2.0-beta.1
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,64 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import React, { useEffect, useState } from 'react';
|
|
4
|
-
import type { FeatureCollection } from '@peripleo/peripleo';
|
|
5
|
-
import { MixedGeoJSONLayer, PulsingMarkerLayer } from '@peripleo/maplibre';
|
|
6
|
-
import { DEFAULT_FILL_STYLE, DEFAULT_POINT_STYLE, DEFAULT_STROKE_STYLE } from '../utils/MapStyles';
|
|
7
|
-
import './CoreDataPlace.css';
|
|
8
|
-
|
|
9
|
-
type Props = {
|
|
10
|
-
url: string,
|
|
11
|
-
fillStyle?: { [key: string]: any },
|
|
12
|
-
pointStyle?: { [key: string]: any },
|
|
13
|
-
strokeStyle?: { [key: string]: any }
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const CoreDataPlace = (props: Props) => {
|
|
17
|
-
const [place, setPlace] = useState<FeatureCollection | undefined>(undefined);
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Fetch the place record from the passed URI.
|
|
21
|
-
*/
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
fetch(props.url)
|
|
24
|
-
.then((res) => res.json())
|
|
25
|
-
.then((data) => setPlace({
|
|
26
|
-
type: 'FeatureCollection',
|
|
27
|
-
features: [{
|
|
28
|
-
...data,
|
|
29
|
-
properties: {
|
|
30
|
-
...data.properties,
|
|
31
|
-
record_id: data.record_id
|
|
32
|
-
}
|
|
33
|
-
}]
|
|
34
|
-
}));
|
|
35
|
-
}, [props.url]);
|
|
36
|
-
|
|
37
|
-
if (!place) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<>
|
|
43
|
-
<PulsingMarkerLayer
|
|
44
|
-
id='current'
|
|
45
|
-
data={place}
|
|
46
|
-
/>
|
|
47
|
-
<MixedGeoJSONLayer
|
|
48
|
-
id={props.url}
|
|
49
|
-
data={place}
|
|
50
|
-
fillStyle={props.fillStyle}
|
|
51
|
-
strokeStyle={props.strokeStyle}
|
|
52
|
-
pointStyle={props.pointStyle}
|
|
53
|
-
/>
|
|
54
|
-
</>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
CoreDataPlace.defaultProps = {
|
|
59
|
-
fillStyle: DEFAULT_FILL_STYLE,
|
|
60
|
-
pointStyle: DEFAULT_POINT_STYLE,
|
|
61
|
-
strokeStyle: DEFAULT_STROKE_STYLE
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export default CoreDataPlace;
|
|
@@ -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;
|