@performant-software/geospatial 2.1.0-beta.3 → 2.1.0-beta.30

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.
Files changed (307) hide show
  1. package/dist/index.cjs.js +1 -1
  2. package/dist/index.cjs10.js +1 -1
  3. package/dist/index.cjs10.js.map +1 -1
  4. package/dist/index.cjs103.js +1 -1
  5. package/dist/index.cjs11.js +1 -1
  6. package/dist/index.cjs11.js.map +1 -1
  7. package/dist/index.cjs12.js +1 -1
  8. package/dist/index.cjs12.js.map +1 -1
  9. package/dist/index.cjs122.js +1 -1
  10. package/dist/index.cjs123.js +1 -1
  11. package/dist/index.cjs125.js +1 -1
  12. package/dist/index.cjs129.js +1 -1
  13. package/dist/index.cjs13.js +1 -1
  14. package/dist/index.cjs13.js.map +1 -1
  15. package/dist/index.cjs14.js +1 -1
  16. package/dist/index.cjs14.js.map +1 -1
  17. package/dist/index.cjs15.js +1 -1
  18. package/dist/index.cjs15.js.map +1 -1
  19. package/dist/index.cjs16.js +1 -1
  20. package/dist/index.cjs16.js.map +1 -1
  21. package/dist/index.cjs162.js +1 -1
  22. package/dist/index.cjs165.js +1 -1
  23. package/dist/index.cjs167.js +1 -1
  24. package/dist/index.cjs17.js +1 -1
  25. package/dist/index.cjs17.js.map +1 -1
  26. package/dist/index.cjs175.js +1 -1
  27. package/dist/index.cjs18.js +1 -1
  28. package/dist/index.cjs18.js.map +1 -1
  29. package/dist/index.cjs19.js +1 -1
  30. package/dist/index.cjs19.js.map +1 -1
  31. package/dist/index.cjs191.js +1 -1
  32. package/dist/index.cjs199.js +1 -1
  33. package/dist/index.cjs2.js +1 -1
  34. package/dist/index.cjs20.js +1 -1
  35. package/dist/index.cjs20.js.map +1 -1
  36. package/dist/index.cjs200.js +1 -1
  37. package/dist/index.cjs201.js +1 -1
  38. package/dist/index.cjs202.js +1 -1
  39. package/dist/index.cjs203.js +1 -1
  40. package/dist/index.cjs205.js +1 -1
  41. package/dist/index.cjs206.js +1 -1
  42. package/dist/index.cjs208.js +1 -1
  43. package/dist/index.cjs209.js +1 -1
  44. package/dist/index.cjs21.js +1 -1
  45. package/dist/index.cjs21.js.map +1 -1
  46. package/dist/index.cjs211.js +1 -1
  47. package/dist/index.cjs216.js +1 -1
  48. package/dist/index.cjs218.js +1 -1
  49. package/dist/index.cjs22.js +1 -1
  50. package/dist/index.cjs22.js.map +1 -1
  51. package/dist/index.cjs220.js +1 -1
  52. package/dist/index.cjs221.js +1 -1
  53. package/dist/index.cjs225.js +1 -1
  54. package/dist/index.cjs226.js +1 -1
  55. package/dist/index.cjs226.js.map +1 -1
  56. package/dist/index.cjs227.js +1 -1
  57. package/dist/index.cjs227.js.map +1 -1
  58. package/dist/index.cjs228.js +1 -1
  59. package/dist/index.cjs228.js.map +1 -1
  60. package/dist/index.cjs229.js +1 -1
  61. package/dist/index.cjs229.js.map +1 -1
  62. package/dist/index.cjs23.js +1 -1
  63. package/dist/index.cjs23.js.map +1 -1
  64. package/dist/index.cjs230.js +1 -1
  65. package/dist/index.cjs230.js.map +1 -1
  66. package/dist/index.cjs238.js +1 -1
  67. package/dist/index.cjs24.js +1 -1
  68. package/dist/index.cjs24.js.map +1 -1
  69. package/dist/index.cjs243.js +1 -1
  70. package/dist/index.cjs246.js +1 -1
  71. package/dist/index.cjs25.js +1 -1
  72. package/dist/index.cjs25.js.map +1 -1
  73. package/dist/index.cjs250.js +1 -1
  74. package/dist/index.cjs250.js.map +1 -1
  75. package/dist/index.cjs251.js +1 -1
  76. package/dist/index.cjs251.js.map +1 -1
  77. package/dist/index.cjs26.js +1 -1
  78. package/dist/index.cjs26.js.map +1 -1
  79. package/dist/index.cjs27.js +1 -1
  80. package/dist/index.cjs27.js.map +1 -1
  81. package/dist/index.cjs28.js +1 -1
  82. package/dist/index.cjs28.js.map +1 -1
  83. package/dist/index.cjs29.js +1 -1
  84. package/dist/index.cjs29.js.map +1 -1
  85. package/dist/index.cjs3.js +1 -1
  86. package/dist/index.cjs3.js.map +1 -1
  87. package/dist/index.cjs30.js +1 -1
  88. package/dist/index.cjs30.js.map +1 -1
  89. package/dist/index.cjs31.js +1 -1
  90. package/dist/index.cjs31.js.map +1 -1
  91. package/dist/index.cjs32.js +1 -1
  92. package/dist/index.cjs32.js.map +1 -1
  93. package/dist/index.cjs33.js +1 -1
  94. package/dist/index.cjs33.js.map +1 -1
  95. package/dist/index.cjs34.js +1 -1
  96. package/dist/index.cjs34.js.map +1 -1
  97. package/dist/index.cjs35.js +1 -1
  98. package/dist/index.cjs35.js.map +1 -1
  99. package/dist/index.cjs36.js +1 -1
  100. package/dist/index.cjs36.js.map +1 -1
  101. package/dist/index.cjs37.js +1 -1
  102. package/dist/index.cjs37.js.map +1 -1
  103. package/dist/index.cjs38.js +1 -1
  104. package/dist/index.cjs38.js.map +1 -1
  105. package/dist/index.cjs39.js +1 -1
  106. package/dist/index.cjs39.js.map +1 -1
  107. package/dist/index.cjs4.js +1 -1
  108. package/dist/index.cjs40.js +1 -1
  109. package/dist/index.cjs40.js.map +1 -1
  110. package/dist/index.cjs41.js +1 -1
  111. package/dist/index.cjs41.js.map +1 -1
  112. package/dist/index.cjs42.js +1 -1
  113. package/dist/index.cjs42.js.map +1 -1
  114. package/dist/index.cjs43.js +1 -1
  115. package/dist/index.cjs43.js.map +1 -1
  116. package/dist/index.cjs44.js +1 -1
  117. package/dist/index.cjs44.js.map +1 -1
  118. package/dist/index.cjs45.js +1 -1
  119. package/dist/index.cjs45.js.map +1 -1
  120. package/dist/index.cjs46.js +1 -1
  121. package/dist/index.cjs5.js +1 -1
  122. package/dist/index.cjs5.js.map +1 -1
  123. package/dist/index.cjs57.js +1 -1
  124. package/dist/index.cjs57.js.map +1 -1
  125. package/dist/index.cjs58.js +1 -1
  126. package/dist/index.cjs58.js.map +1 -1
  127. package/dist/index.cjs59.js +1 -1
  128. package/dist/index.cjs59.js.map +1 -1
  129. package/dist/index.cjs6.js +1 -1
  130. package/dist/index.cjs66.js +1 -1
  131. package/dist/index.cjs67.js +1 -1
  132. package/dist/index.cjs68.js +1 -1
  133. package/dist/index.cjs69.js +1 -1
  134. package/dist/index.cjs7.js +1 -1
  135. package/dist/index.cjs70.js +1 -1
  136. package/dist/index.cjs74.js +1 -1
  137. package/dist/index.cjs75.js +1 -1
  138. package/dist/index.cjs8.js +1 -1
  139. package/dist/index.cjs80.js +1 -1
  140. package/dist/index.cjs89.js +1 -1
  141. package/dist/index.cjs90.js +1 -1
  142. package/dist/index.cjs91.js +1 -1
  143. package/dist/index.cjs92.js +1 -1
  144. package/dist/index.cjs93.js +1 -1
  145. package/dist/index.cjs94.js +1 -1
  146. package/dist/index.cjs96.js +1 -1
  147. package/dist/index.cjs98.js +1 -1
  148. package/dist/index.cjs99.js +1 -1
  149. package/dist/index.es.js +8 -6
  150. package/dist/index.es.js.map +1 -1
  151. package/dist/index.es10.js +39 -2102
  152. package/dist/index.es10.js.map +1 -1
  153. package/dist/index.es103.js +1 -1
  154. package/dist/index.es11.js +2102 -19
  155. package/dist/index.es11.js.map +1 -1
  156. package/dist/index.es12.js +19 -12
  157. package/dist/index.es12.js.map +1 -1
  158. package/dist/index.es122.js +2 -2
  159. package/dist/index.es123.js +1 -1
  160. package/dist/index.es125.js +1 -1
  161. package/dist/index.es129.js +1 -1
  162. package/dist/index.es13.js +12 -6
  163. package/dist/index.es13.js.map +1 -1
  164. package/dist/index.es14.js +6 -5
  165. package/dist/index.es14.js.map +1 -1
  166. package/dist/index.es15.js +6 -28
  167. package/dist/index.es15.js.map +1 -1
  168. package/dist/index.es16.js +6 -8
  169. package/dist/index.es16.js.map +1 -1
  170. package/dist/index.es162.js +1 -1
  171. package/dist/index.es165.js +1 -1
  172. package/dist/index.es167.js +1 -1
  173. package/dist/index.es17.js +5 -5
  174. package/dist/index.es17.js.map +1 -1
  175. package/dist/index.es175.js +1 -1
  176. package/dist/index.es18.js +28 -10
  177. package/dist/index.es18.js.map +1 -1
  178. package/dist/index.es19.js +8 -17
  179. package/dist/index.es19.js.map +1 -1
  180. package/dist/index.es191.js +2 -2
  181. package/dist/index.es199.js +1 -1
  182. package/dist/index.es2.js +3 -3
  183. package/dist/index.es20.js +5 -5
  184. package/dist/index.es20.js.map +1 -1
  185. package/dist/index.es200.js +1 -1
  186. package/dist/index.es201.js +1 -1
  187. package/dist/index.es202.js +1 -1
  188. package/dist/index.es203.js +1 -1
  189. package/dist/index.es205.js +1 -1
  190. package/dist/index.es206.js +2 -2
  191. package/dist/index.es208.js +1 -1
  192. package/dist/index.es209.js +2 -2
  193. package/dist/index.es21.js +9 -4
  194. package/dist/index.es21.js.map +1 -1
  195. package/dist/index.es211.js +2 -2
  196. package/dist/index.es216.js +1 -1
  197. package/dist/index.es218.js +1 -1
  198. package/dist/index.es22.js +17 -5
  199. package/dist/index.es22.js.map +1 -1
  200. package/dist/index.es220.js +1 -1
  201. package/dist/index.es221.js +1 -1
  202. package/dist/index.es225.js +1 -1
  203. package/dist/index.es226.js +3 -46
  204. package/dist/index.es226.js.map +1 -1
  205. package/dist/index.es227.js +5 -22
  206. package/dist/index.es227.js.map +1 -1
  207. package/dist/index.es228.js +8 -3
  208. package/dist/index.es228.js.map +1 -1
  209. package/dist/index.es229.js +44 -6
  210. package/dist/index.es229.js.map +1 -1
  211. package/dist/index.es23.js +5 -7
  212. package/dist/index.es23.js.map +1 -1
  213. package/dist/index.es230.js +22 -5
  214. package/dist/index.es230.js.map +1 -1
  215. package/dist/index.es238.js +1 -1
  216. package/dist/index.es24.js +5 -7
  217. package/dist/index.es24.js.map +1 -1
  218. package/dist/index.es243.js +1 -1
  219. package/dist/index.es246.js +1 -1
  220. package/dist/index.es25.js +5 -4
  221. package/dist/index.es25.js.map +1 -1
  222. package/dist/index.es250.js +4 -15
  223. package/dist/index.es250.js.map +1 -1
  224. package/dist/index.es251.js +15 -4
  225. package/dist/index.es251.js.map +1 -1
  226. package/dist/index.es26.js +7 -4
  227. package/dist/index.es26.js.map +1 -1
  228. package/dist/index.es27.js +6 -6
  229. package/dist/index.es27.js.map +1 -1
  230. package/dist/index.es28.js +4 -15
  231. package/dist/index.es28.js.map +1 -1
  232. package/dist/index.es29.js +4 -12
  233. package/dist/index.es29.js.map +1 -1
  234. package/dist/index.es3.js +22 -63
  235. package/dist/index.es3.js.map +1 -1
  236. package/dist/index.es30.js +7 -15
  237. package/dist/index.es30.js.map +1 -1
  238. package/dist/index.es31.js +14 -6
  239. package/dist/index.es31.js.map +1 -1
  240. package/dist/index.es32.js +12 -5
  241. package/dist/index.es32.js.map +1 -1
  242. package/dist/index.es33.js +15 -4
  243. package/dist/index.es33.js.map +1 -1
  244. package/dist/index.es34.js +6 -17
  245. package/dist/index.es34.js.map +1 -1
  246. package/dist/index.es35.js +5 -18
  247. package/dist/index.es35.js.map +1 -1
  248. package/dist/index.es36.js +4 -14
  249. package/dist/index.es36.js.map +1 -1
  250. package/dist/index.es37.js +17 -5
  251. package/dist/index.es37.js.map +1 -1
  252. package/dist/index.es38.js +17 -6
  253. package/dist/index.es38.js.map +1 -1
  254. package/dist/index.es39.js +12 -8
  255. package/dist/index.es39.js.map +1 -1
  256. package/dist/index.es4.js +8 -8
  257. package/dist/index.es40.js +6 -4
  258. package/dist/index.es40.js.map +1 -1
  259. package/dist/index.es41.js +6 -18
  260. package/dist/index.es41.js.map +1 -1
  261. package/dist/index.es42.js +10 -6
  262. package/dist/index.es42.js.map +1 -1
  263. package/dist/index.es43.js +4 -6
  264. package/dist/index.es43.js.map +1 -1
  265. package/dist/index.es44.js +21 -1
  266. package/dist/index.es44.js.map +1 -1
  267. package/dist/index.es45.js +1 -39
  268. package/dist/index.es45.js.map +1 -1
  269. package/dist/index.es46.js +1 -1
  270. package/dist/index.es5.js +27 -19
  271. package/dist/index.es5.js.map +1 -1
  272. package/dist/index.es57.js +2 -107
  273. package/dist/index.es57.js.map +1 -1
  274. package/dist/index.es58.js +107 -10
  275. package/dist/index.es58.js.map +1 -1
  276. package/dist/index.es59.js +10 -2
  277. package/dist/index.es59.js.map +1 -1
  278. package/dist/index.es6.js +6 -6
  279. package/dist/index.es66.js +1 -1
  280. package/dist/index.es67.js +1 -1
  281. package/dist/index.es68.js +1 -1
  282. package/dist/index.es69.js +1 -1
  283. package/dist/index.es7.js +7 -7
  284. package/dist/index.es70.js +1 -1
  285. package/dist/index.es74.js +26 -26
  286. package/dist/index.es75.js +2 -2
  287. package/dist/index.es8.js +2 -2
  288. package/dist/index.es80.js +1 -1
  289. package/dist/index.es89.js +2 -2
  290. package/dist/index.es90.js +1 -1
  291. package/dist/index.es91.js +1 -1
  292. package/dist/index.es92.js +1 -1
  293. package/dist/index.es93.js +1 -1
  294. package/dist/index.es94.js +1 -1
  295. package/dist/index.es96.js +4 -4
  296. package/dist/index.es98.js +1 -1
  297. package/dist/index.es99.js +1 -1
  298. package/dist/style.css +1 -1
  299. package/package.json +2 -2
  300. package/src/components/GeoJsonLayer.js +10 -66
  301. package/src/components/LocationMarkers.js +51 -8
  302. package/src/index.js +1 -0
  303. package/src/utils/MapStyles.js +9 -3
  304. package/types/components/GeoJsonLayer.js.flow +10 -66
  305. package/types/components/LocationMarkers.js.flow +51 -8
  306. package/types/index.js.flow +1 -0
  307. package/types/utils/MapStyles.js.flow +9 -3
@@ -1,13 +1,11 @@
1
1
  // @flow
2
2
 
3
3
  import React, {
4
- useCallback,
5
4
  useEffect,
6
- useMemo,
7
5
  useState
8
6
  } from 'react';
9
7
  import { Layer, Source } from 'react-map-gl';
10
- import _ from 'underscore';
8
+ import MapStyles from '../utils/MapStyles';
11
9
 
12
10
  type Props = {
13
11
  data?: { [key: string]: any },
@@ -17,69 +15,9 @@ type Props = {
17
15
  url?: string
18
16
  };
19
17
 
20
- const DEFAULT_COLOR = '#CC3333';
21
- const HIGHLIGHT_COLOR = '#990000';
22
-
23
- const DEFAULT_FILL_STYLES = {
24
- 'fill-color': DEFAULT_COLOR,
25
- 'fill-opacity': 0.2
26
- };
27
-
28
- const DEFAULT_LINE_STYLES = {
29
- 'line-color': HIGHLIGHT_COLOR,
30
- 'line-opacity': 0.6
31
- };
32
-
33
- const DEFAULT_POINT_STYLES = {
34
- 'circle-radius': [
35
- 'interpolate',
36
- ['linear'],
37
- ['number', ['get', 'point_count'], 1],
38
- 0, 4,
39
- 10, 14
40
- ],
41
- 'circle-stroke-width': 1,
42
- 'circle-color': DEFAULT_COLOR,
43
- 'circle-stroke-color': HIGHLIGHT_COLOR
44
- };
45
-
46
18
  const GeoJsonLayer = (props: Props) => {
47
19
  const [data, setData] = useState(props.data);
48
20
 
49
- /**
50
- * Returns the layer style for the passed style and default.
51
- *
52
- * @type {function(*, *): *}
53
- */
54
- const getLayerStyles = useCallback((style, defaultStyle) => _.defaults(style, defaultStyle), []);
55
-
56
- /**
57
- * Sets the fill layer style.
58
- *
59
- * @type {*}
60
- */
61
- const fillStyle = useMemo(() => (
62
- getLayerStyles(props.fillStyle, DEFAULT_FILL_STYLES)
63
- ), [getLayerStyles, props.fillStyle]);
64
-
65
- /**
66
- * Sets the line layer style.
67
- *
68
- * @type {*}
69
- */
70
- const lineStyle = useMemo(() => (
71
- getLayerStyles(props.lineStyle, DEFAULT_LINE_STYLES)
72
- ), [getLayerStyles, props.lineStyle]);
73
-
74
- /**
75
- * Sets the point layer style.
76
- *
77
- * @type {*}
78
- */
79
- const pointStyle = useMemo(() => (
80
- getLayerStyles(props.pointStyle, DEFAULT_POINT_STYLES)
81
- ), [getLayerStyles, props.pointStyle]);
82
-
83
21
  /**
84
22
  * If the data is passed as a URL, fetches the passed URL and sets the response on the state.
85
23
  */
@@ -98,21 +36,27 @@ const GeoJsonLayer = (props: Props) => {
98
36
  >
99
37
  <Layer
100
38
  filter={['!=', '$type', 'Point']}
101
- paint={fillStyle}
39
+ paint={props.fillStyle}
102
40
  type='fill'
103
41
  />
104
42
  <Layer
105
43
  filter={['!=', '$type', 'Point']}
106
- paint={lineStyle}
44
+ paint={props.lineStyle}
107
45
  type='line'
108
46
  />
109
47
  <Layer
110
48
  filter={['==', '$type', 'Point']}
111
- paint={pointStyle}
49
+ paint={props.pointStyle}
112
50
  type='circle'
113
51
  />
114
52
  </Source>
115
53
  );
116
54
  };
117
55
 
56
+ GeoJsonLayer.defaultProps = {
57
+ fillStyle: MapStyles.fill,
58
+ pointStyle: MapStyles.point,
59
+ strokeStyle: MapStyles.stroke
60
+ };
61
+
118
62
  export default GeoJsonLayer;
@@ -1,8 +1,8 @@
1
1
  // @flow
2
2
 
3
- import { MixedGeoJSONLayer, PulsingMarkerLayer, useMap } from '@peripleo/maplibre';
3
+ import { GeoJSONLayer, PulsingMarkerLayer, useMap } from '@peripleo/maplibre';
4
4
  import React, { useEffect } from 'react';
5
- import { DEFAULT_FILL_STYLE, DEFAULT_POINT_STYLE, DEFAULT_STROKE_STYLE } from '../utils/MapStyles';
5
+ import MapStyles from '../utils/MapStyles';
6
6
  import MapUtils from '../utils/Map';
7
7
 
8
8
  type Props = {
@@ -16,6 +16,31 @@ type Props = {
16
16
  */
17
17
  buffer: number,
18
18
 
19
+ /**
20
+ * If true, markers will be clustered before the specified zoom level.
21
+ */
22
+ cluster?: boolean,
23
+
24
+ /**
25
+ * Max zoom to cluster points on.
26
+ */
27
+ clusterMaxZoom?: number,
28
+
29
+ /**
30
+ * Minimum number of points necessary to form a cluster.
31
+ */
32
+ clusterMinPoints?: number,
33
+
34
+ /**
35
+ * An object defining custom properties on the generated clusters.
36
+ */
37
+ clusterProperties?: any,
38
+
39
+ /**
40
+ * Radius of each cluster when clustering point.
41
+ */
42
+ clusterRadius?: number,
43
+
19
44
  /**
20
45
  * The GeoJSON data representing the location.
21
46
  */
@@ -26,6 +51,16 @@ type Props = {
26
51
  */
27
52
  fillStyle?: { [key: string]: any },
28
53
 
54
+ /**
55
+ * If `true`, the map will fit the bounding box around the passed data.
56
+ */
57
+ fitBoundingBox?: boolean,
58
+
59
+ /**
60
+ * An ID value to apply to the layer.
61
+ */
62
+ layerId?: string,
63
+
29
64
  /**
30
65
  * GeoJSON layer point style.
31
66
  */
@@ -49,22 +84,29 @@ const LocationMarkers = (props: Props) => {
49
84
  * Sets the bounding box on the map.
50
85
  */
51
86
  useEffect(() => {
52
- if (map && props.data) {
87
+ if (map && props.data && props.fitBoundingBox) {
53
88
  const boundingBox = MapUtils.getBoundingBox(props.data, props.buffer);
54
89
  map.fitBounds(boundingBox);
55
90
  }
56
- }, [map, props.buffer, props.data]);
91
+ }, [map, props.buffer, props.data, props.fitBoundingBox]);
57
92
 
58
93
  return (
59
94
  <>
60
95
  { props.animate && (
61
96
  <PulsingMarkerLayer
62
97
  data={props.data}
98
+ id={props.layerId}
63
99
  />
64
100
  )}
65
- <MixedGeoJSONLayer
101
+ <GeoJSONLayer
102
+ cluster={props.cluster}
103
+ clusterMaxZoom={props.clusterMaxZoom}
104
+ clusterMinPoints={props.clusterMinPoints}
105
+ clusterProperties={props.clusterProperties}
106
+ clusterRadius={props.clusterRadius}
66
107
  data={props.data}
67
108
  fillStyle={props.fillStyle}
109
+ id={props.layerId}
68
110
  strokeStyle={props.strokeStyle}
69
111
  pointStyle={props.pointStyle}
70
112
  />
@@ -74,9 +116,10 @@ const LocationMarkers = (props: Props) => {
74
116
 
75
117
  LocationMarkers.defaultProps = {
76
118
  buffer: DEFAULT_BUFFER,
77
- fillStyle: DEFAULT_FILL_STYLE,
78
- pointStyle: DEFAULT_POINT_STYLE,
79
- strokeStyle: DEFAULT_STROKE_STYLE
119
+ fillStyle: MapStyles.fill,
120
+ fitBoundingBox: true,
121
+ pointStyle: MapStyles.point,
122
+ strokeStyle: MapStyles.stroke
80
123
  };
81
124
 
82
125
  export default LocationMarkers;
package/src/index.js CHANGED
@@ -11,3 +11,4 @@ export { default as RasterLayer } from './components/RasterLayer';
11
11
 
12
12
  // Utils
13
13
  export { default as Map } from './utils/Map';
14
+ export { default as MapStyles } from './utils/MapStyles';
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
 
3
- export const DEFAULT_POINT_STYLE = {
3
+ const point = {
4
4
  type: 'circle',
5
5
  paint: {
6
6
  'circle-radius': [
@@ -21,7 +21,7 @@ export const DEFAULT_POINT_STYLE = {
21
21
  }
22
22
  };
23
23
 
24
- export const DEFAULT_FILL_STYLE = {
24
+ const fill = {
25
25
  type: 'fill',
26
26
  paint: {
27
27
  'fill-color': '#ff623b',
@@ -29,10 +29,16 @@ export const DEFAULT_FILL_STYLE = {
29
29
  }
30
30
  };
31
31
 
32
- export const DEFAULT_STROKE_STYLE = {
32
+ const stroke = {
33
33
  type: 'line',
34
34
  paint: {
35
35
  'line-color': '#ff623b',
36
36
  'line-opacity': 0.6
37
37
  }
38
38
  };
39
+
40
+ export default {
41
+ point,
42
+ fill,
43
+ stroke
44
+ };
@@ -1,13 +1,11 @@
1
1
  // @flow
2
2
 
3
3
  import React, {
4
- useCallback,
5
4
  useEffect,
6
- useMemo,
7
5
  useState
8
6
  } from 'react';
9
7
  import { Layer, Source } from 'react-map-gl';
10
- import _ from 'underscore';
8
+ import MapStyles from '../utils/MapStyles';
11
9
 
12
10
  type Props = {
13
11
  data?: { [key: string]: any },
@@ -17,69 +15,9 @@ type Props = {
17
15
  url?: string
18
16
  };
19
17
 
20
- const DEFAULT_COLOR = '#CC3333';
21
- const HIGHLIGHT_COLOR = '#990000';
22
-
23
- const DEFAULT_FILL_STYLES = {
24
- 'fill-color': DEFAULT_COLOR,
25
- 'fill-opacity': 0.2
26
- };
27
-
28
- const DEFAULT_LINE_STYLES = {
29
- 'line-color': HIGHLIGHT_COLOR,
30
- 'line-opacity': 0.6
31
- };
32
-
33
- const DEFAULT_POINT_STYLES = {
34
- 'circle-radius': [
35
- 'interpolate',
36
- ['linear'],
37
- ['number', ['get', 'point_count'], 1],
38
- 0, 4,
39
- 10, 14
40
- ],
41
- 'circle-stroke-width': 1,
42
- 'circle-color': DEFAULT_COLOR,
43
- 'circle-stroke-color': HIGHLIGHT_COLOR
44
- };
45
-
46
18
  const GeoJsonLayer = (props: Props) => {
47
19
  const [data, setData] = useState(props.data);
48
20
 
49
- /**
50
- * Returns the layer style for the passed style and default.
51
- *
52
- * @type {function(*, *): *}
53
- */
54
- const getLayerStyles = useCallback((style, defaultStyle) => _.defaults(style, defaultStyle), []);
55
-
56
- /**
57
- * Sets the fill layer style.
58
- *
59
- * @type {*}
60
- */
61
- const fillStyle = useMemo(() => (
62
- getLayerStyles(props.fillStyle, DEFAULT_FILL_STYLES)
63
- ), [getLayerStyles, props.fillStyle]);
64
-
65
- /**
66
- * Sets the line layer style.
67
- *
68
- * @type {*}
69
- */
70
- const lineStyle = useMemo(() => (
71
- getLayerStyles(props.lineStyle, DEFAULT_LINE_STYLES)
72
- ), [getLayerStyles, props.lineStyle]);
73
-
74
- /**
75
- * Sets the point layer style.
76
- *
77
- * @type {*}
78
- */
79
- const pointStyle = useMemo(() => (
80
- getLayerStyles(props.pointStyle, DEFAULT_POINT_STYLES)
81
- ), [getLayerStyles, props.pointStyle]);
82
-
83
21
  /**
84
22
  * If the data is passed as a URL, fetches the passed URL and sets the response on the state.
85
23
  */
@@ -98,21 +36,27 @@ const GeoJsonLayer = (props: Props) => {
98
36
  >
99
37
  <Layer
100
38
  filter={['!=', '$type', 'Point']}
101
- paint={fillStyle}
39
+ paint={props.fillStyle}
102
40
  type='fill'
103
41
  />
104
42
  <Layer
105
43
  filter={['!=', '$type', 'Point']}
106
- paint={lineStyle}
44
+ paint={props.lineStyle}
107
45
  type='line'
108
46
  />
109
47
  <Layer
110
48
  filter={['==', '$type', 'Point']}
111
- paint={pointStyle}
49
+ paint={props.pointStyle}
112
50
  type='circle'
113
51
  />
114
52
  </Source>
115
53
  );
116
54
  };
117
55
 
56
+ GeoJsonLayer.defaultProps = {
57
+ fillStyle: MapStyles.fill,
58
+ pointStyle: MapStyles.point,
59
+ strokeStyle: MapStyles.stroke
60
+ };
61
+
118
62
  export default GeoJsonLayer;
@@ -1,8 +1,8 @@
1
1
  // @flow
2
2
 
3
- import { MixedGeoJSONLayer, PulsingMarkerLayer, useMap } from '@peripleo/maplibre';
3
+ import { GeoJSONLayer, PulsingMarkerLayer, useMap } from '@peripleo/maplibre';
4
4
  import React, { useEffect } from 'react';
5
- import { DEFAULT_FILL_STYLE, DEFAULT_POINT_STYLE, DEFAULT_STROKE_STYLE } from '../utils/MapStyles';
5
+ import MapStyles from '../utils/MapStyles';
6
6
  import MapUtils from '../utils/Map';
7
7
 
8
8
  type Props = {
@@ -16,6 +16,31 @@ type Props = {
16
16
  */
17
17
  buffer: number,
18
18
 
19
+ /**
20
+ * If true, markers will be clustered before the specified zoom level.
21
+ */
22
+ cluster?: boolean,
23
+
24
+ /**
25
+ * Max zoom to cluster points on.
26
+ */
27
+ clusterMaxZoom?: number,
28
+
29
+ /**
30
+ * Minimum number of points necessary to form a cluster.
31
+ */
32
+ clusterMinPoints?: number,
33
+
34
+ /**
35
+ * An object defining custom properties on the generated clusters.
36
+ */
37
+ clusterProperties?: any,
38
+
39
+ /**
40
+ * Radius of each cluster when clustering point.
41
+ */
42
+ clusterRadius?: number,
43
+
19
44
  /**
20
45
  * The GeoJSON data representing the location.
21
46
  */
@@ -26,6 +51,16 @@ type Props = {
26
51
  */
27
52
  fillStyle?: { [key: string]: any },
28
53
 
54
+ /**
55
+ * If `true`, the map will fit the bounding box around the passed data.
56
+ */
57
+ fitBoundingBox?: boolean,
58
+
59
+ /**
60
+ * An ID value to apply to the layer.
61
+ */
62
+ layerId?: string,
63
+
29
64
  /**
30
65
  * GeoJSON layer point style.
31
66
  */
@@ -49,22 +84,29 @@ const LocationMarkers = (props: Props) => {
49
84
  * Sets the bounding box on the map.
50
85
  */
51
86
  useEffect(() => {
52
- if (map && props.data) {
87
+ if (map && props.data && props.fitBoundingBox) {
53
88
  const boundingBox = MapUtils.getBoundingBox(props.data, props.buffer);
54
89
  map.fitBounds(boundingBox);
55
90
  }
56
- }, [map, props.buffer, props.data]);
91
+ }, [map, props.buffer, props.data, props.fitBoundingBox]);
57
92
 
58
93
  return (
59
94
  <>
60
95
  { props.animate && (
61
96
  <PulsingMarkerLayer
62
97
  data={props.data}
98
+ id={props.layerId}
63
99
  />
64
100
  )}
65
- <MixedGeoJSONLayer
101
+ <GeoJSONLayer
102
+ cluster={props.cluster}
103
+ clusterMaxZoom={props.clusterMaxZoom}
104
+ clusterMinPoints={props.clusterMinPoints}
105
+ clusterProperties={props.clusterProperties}
106
+ clusterRadius={props.clusterRadius}
66
107
  data={props.data}
67
108
  fillStyle={props.fillStyle}
109
+ id={props.layerId}
68
110
  strokeStyle={props.strokeStyle}
69
111
  pointStyle={props.pointStyle}
70
112
  />
@@ -74,9 +116,10 @@ const LocationMarkers = (props: Props) => {
74
116
 
75
117
  LocationMarkers.defaultProps = {
76
118
  buffer: DEFAULT_BUFFER,
77
- fillStyle: DEFAULT_FILL_STYLE,
78
- pointStyle: DEFAULT_POINT_STYLE,
79
- strokeStyle: DEFAULT_STROKE_STYLE
119
+ fillStyle: MapStyles.fill,
120
+ fitBoundingBox: true,
121
+ pointStyle: MapStyles.point,
122
+ strokeStyle: MapStyles.stroke
80
123
  };
81
124
 
82
125
  export default LocationMarkers;
@@ -11,3 +11,4 @@ export { default as RasterLayer } from './components/RasterLayer';
11
11
 
12
12
  // Utils
13
13
  export { default as Map } from './utils/Map';
14
+ export { default as MapStyles } from './utils/MapStyles';
@@ -1,6 +1,6 @@
1
1
  // @flow
2
2
 
3
- export const DEFAULT_POINT_STYLE = {
3
+ const point = {
4
4
  type: 'circle',
5
5
  paint: {
6
6
  'circle-radius': [
@@ -21,7 +21,7 @@ export const DEFAULT_POINT_STYLE = {
21
21
  }
22
22
  };
23
23
 
24
- export const DEFAULT_FILL_STYLE = {
24
+ const fill = {
25
25
  type: 'fill',
26
26
  paint: {
27
27
  'fill-color': '#ff623b',
@@ -29,10 +29,16 @@ export const DEFAULT_FILL_STYLE = {
29
29
  }
30
30
  };
31
31
 
32
- export const DEFAULT_STROKE_STYLE = {
32
+ const stroke = {
33
33
  type: 'line',
34
34
  paint: {
35
35
  'line-color': '#ff623b',
36
36
  'line-opacity': 0.6
37
37
  }
38
38
  };
39
+
40
+ export default {
41
+ point,
42
+ fill,
43
+ stroke
44
+ };