@performant-software/geospatial 1.1.3-beta.8 → 1.1.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@performant-software/geospatial",
3
- "version": "1.1.3-beta.8",
3
+ "version": "1.1.3",
4
4
  "description": "TODO: ADD",
5
5
  "license": "MIT",
6
6
  "main": "./build/index.js",
@@ -0,0 +1,80 @@
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
+ };
@@ -0,0 +1,36 @@
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
+ }