@performant-software/geospatial 1.2.0-beta.15 → 1.2.0-beta.16
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,77 +0,0 @@
|
|
|
1
|
-
// @flow
|
|
2
|
-
|
|
3
|
-
import React, { useEffect } from 'react';
|
|
4
|
-
import { MixedGeoJSONLayer, PulsingMarkerLayer, useMap } from '@peripleo/maplibre';
|
|
5
|
-
import { DEFAULT_FILL_STYLE, DEFAULT_POINT_STYLE, DEFAULT_STROKE_STYLE } from '../utils/MapStyles';
|
|
6
|
-
import MapUtils from '../utils/Map';
|
|
7
|
-
|
|
8
|
-
type Props = {
|
|
9
|
-
/**
|
|
10
|
-
* The number of miles to buffer the GeoJSON data.
|
|
11
|
-
*/
|
|
12
|
-
buffer: number,
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The GeoJSON data representing the location.
|
|
16
|
-
*/
|
|
17
|
-
data: { [key: string]: any },
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* GeoJSON layer fill style.
|
|
21
|
-
*/
|
|
22
|
-
fillStyle?: { [key: string]: any },
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* GeoJSON layer point style.
|
|
26
|
-
*/
|
|
27
|
-
pointStyle?: { [key: string]: any },
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* GeoJSON layer stroke style
|
|
31
|
-
*/
|
|
32
|
-
strokeStyle?: { [key: string]: any }
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const DEFAULT_BUFFER = 2;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* This component renders a location marker to be used in a Peripleo context.
|
|
39
|
-
*/
|
|
40
|
-
const LocationMarker = (props: Props) => {
|
|
41
|
-
const map = useMap();
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Sets the bounding box on the map.
|
|
45
|
-
*/
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (map && props.data) {
|
|
48
|
-
const boundingBox = MapUtils.getBoundingBox(props.data, props.buffer);
|
|
49
|
-
map.fitBounds(boundingBox);
|
|
50
|
-
}
|
|
51
|
-
}, [map, props.buffer, props.data]);
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<>
|
|
55
|
-
<PulsingMarkerLayer
|
|
56
|
-
id='current'
|
|
57
|
-
data={props.data}
|
|
58
|
-
/>
|
|
59
|
-
<MixedGeoJSONLayer
|
|
60
|
-
id='current'
|
|
61
|
-
data={props.data}
|
|
62
|
-
fillStyle={props.fillStyle}
|
|
63
|
-
strokeStyle={props.strokeStyle}
|
|
64
|
-
pointStyle={props.pointStyle}
|
|
65
|
-
/>
|
|
66
|
-
</>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
LocationMarker.defaultProps = {
|
|
71
|
-
buffer: DEFAULT_BUFFER,
|
|
72
|
-
fillStyle: DEFAULT_FILL_STYLE,
|
|
73
|
-
pointStyle: DEFAULT_POINT_STYLE,
|
|
74
|
-
strokeStyle: DEFAULT_STROKE_STYLE
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export default LocationMarker;
|