react-native-maplibre-lite 0.1.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.
Files changed (99) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +203 -0
  3. package/lib/module/assets/MAP_ASSETS.js +7 -0
  4. package/lib/module/assets/MAP_ASSETS.js.map +1 -0
  5. package/lib/module/assets/dark_placeholder.jpg +0 -0
  6. package/lib/module/assets/light_placeholder.jpg +0 -0
  7. package/lib/module/components/MapPlaceholder.js +37 -0
  8. package/lib/module/components/MapPlaceholder.js.map +1 -0
  9. package/lib/module/components/MapSelectPoint.js +88 -0
  10. package/lib/module/components/MapSelectPoint.js.map +1 -0
  11. package/lib/module/components/MapView.js +244 -0
  12. package/lib/module/components/MapView.js.map +1 -0
  13. package/lib/module/components/Marker.js +27 -0
  14. package/lib/module/components/Marker.js.map +1 -0
  15. package/lib/module/components/Polygon.js +27 -0
  16. package/lib/module/components/Polygon.js.map +1 -0
  17. package/lib/module/components/Polyline.js +27 -0
  18. package/lib/module/components/Polyline.js.map +1 -0
  19. package/lib/module/components/types.js +2 -0
  20. package/lib/module/components/types.js.map +1 -0
  21. package/lib/module/components/webFunctions/addMarkerWeb.js +57 -0
  22. package/lib/module/components/webFunctions/addMarkerWeb.js.map +1 -0
  23. package/lib/module/components/webFunctions/addPolygonWeb.js +62 -0
  24. package/lib/module/components/webFunctions/addPolygonWeb.js.map +1 -0
  25. package/lib/module/components/webFunctions/addPolylineWeb.js +48 -0
  26. package/lib/module/components/webFunctions/addPolylineWeb.js.map +1 -0
  27. package/lib/module/components/webFunctions/fitBoundsWeb.js +11 -0
  28. package/lib/module/components/webFunctions/fitBoundsWeb.js.map +1 -0
  29. package/lib/module/components/webFunctions/initWeb.js +156 -0
  30. package/lib/module/components/webFunctions/initWeb.js.map +1 -0
  31. package/lib/module/components/webFunctions/removeMarkerWeb.js +12 -0
  32. package/lib/module/components/webFunctions/removeMarkerWeb.js.map +1 -0
  33. package/lib/module/components/webFunctions/removePolygonWeb.js +22 -0
  34. package/lib/module/components/webFunctions/removePolygonWeb.js.map +1 -0
  35. package/lib/module/components/webFunctions/removePolylineWeb.js +17 -0
  36. package/lib/module/components/webFunctions/removePolylineWeb.js.map +1 -0
  37. package/lib/module/index.js +9 -0
  38. package/lib/module/index.js.map +1 -0
  39. package/lib/module/package.json +1 -0
  40. package/lib/module/webContent.js +173 -0
  41. package/lib/module/webContent.js.map +1 -0
  42. package/lib/typescript/package.json +1 -0
  43. package/lib/typescript/src/assets/MAP_ASSETS.d.ts +5 -0
  44. package/lib/typescript/src/assets/MAP_ASSETS.d.ts.map +1 -0
  45. package/lib/typescript/src/components/MapPlaceholder.d.ts +5 -0
  46. package/lib/typescript/src/components/MapPlaceholder.d.ts.map +1 -0
  47. package/lib/typescript/src/components/MapSelectPoint.d.ts +12 -0
  48. package/lib/typescript/src/components/MapSelectPoint.d.ts.map +1 -0
  49. package/lib/typescript/src/components/MapView.d.ts +41 -0
  50. package/lib/typescript/src/components/MapView.d.ts.map +1 -0
  51. package/lib/typescript/src/components/Marker.d.ts +3 -0
  52. package/lib/typescript/src/components/Marker.d.ts.map +1 -0
  53. package/lib/typescript/src/components/Polygon.d.ts +3 -0
  54. package/lib/typescript/src/components/Polygon.d.ts.map +1 -0
  55. package/lib/typescript/src/components/Polyline.d.ts +3 -0
  56. package/lib/typescript/src/components/Polyline.d.ts.map +1 -0
  57. package/lib/typescript/src/components/types.d.ts +38 -0
  58. package/lib/typescript/src/components/types.d.ts.map +1 -0
  59. package/lib/typescript/src/components/webFunctions/addMarkerWeb.d.ts +3 -0
  60. package/lib/typescript/src/components/webFunctions/addMarkerWeb.d.ts.map +1 -0
  61. package/lib/typescript/src/components/webFunctions/addPolygonWeb.d.ts +3 -0
  62. package/lib/typescript/src/components/webFunctions/addPolygonWeb.d.ts.map +1 -0
  63. package/lib/typescript/src/components/webFunctions/addPolylineWeb.d.ts +3 -0
  64. package/lib/typescript/src/components/webFunctions/addPolylineWeb.d.ts.map +1 -0
  65. package/lib/typescript/src/components/webFunctions/fitBoundsWeb.d.ts +3 -0
  66. package/lib/typescript/src/components/webFunctions/fitBoundsWeb.d.ts.map +1 -0
  67. package/lib/typescript/src/components/webFunctions/initWeb.d.ts +3 -0
  68. package/lib/typescript/src/components/webFunctions/initWeb.d.ts.map +1 -0
  69. package/lib/typescript/src/components/webFunctions/removeMarkerWeb.d.ts +3 -0
  70. package/lib/typescript/src/components/webFunctions/removeMarkerWeb.d.ts.map +1 -0
  71. package/lib/typescript/src/components/webFunctions/removePolygonWeb.d.ts +3 -0
  72. package/lib/typescript/src/components/webFunctions/removePolygonWeb.d.ts.map +1 -0
  73. package/lib/typescript/src/components/webFunctions/removePolylineWeb.d.ts +3 -0
  74. package/lib/typescript/src/components/webFunctions/removePolylineWeb.d.ts.map +1 -0
  75. package/lib/typescript/src/index.d.ts +9 -0
  76. package/lib/typescript/src/index.d.ts.map +1 -0
  77. package/lib/typescript/src/webContent.d.ts +3 -0
  78. package/lib/typescript/src/webContent.d.ts.map +1 -0
  79. package/package.json +158 -0
  80. package/src/assets/MAP_ASSETS.ts +4 -0
  81. package/src/assets/dark_placeholder.jpg +0 -0
  82. package/src/assets/light_placeholder.jpg +0 -0
  83. package/src/components/MapPlaceholder.tsx +44 -0
  84. package/src/components/MapSelectPoint.tsx +131 -0
  85. package/src/components/MapView.tsx +333 -0
  86. package/src/components/Marker.tsx +31 -0
  87. package/src/components/Polygon.tsx +31 -0
  88. package/src/components/Polyline.tsx +31 -0
  89. package/src/components/types.ts +46 -0
  90. package/src/components/webFunctions/addMarkerWeb.ts +54 -0
  91. package/src/components/webFunctions/addPolygonWeb.ts +59 -0
  92. package/src/components/webFunctions/addPolylineWeb.ts +45 -0
  93. package/src/components/webFunctions/fitBoundsWeb.ts +8 -0
  94. package/src/components/webFunctions/initWeb.ts +153 -0
  95. package/src/components/webFunctions/removeMarkerWeb.ts +9 -0
  96. package/src/components/webFunctions/removePolygonWeb.ts +19 -0
  97. package/src/components/webFunctions/removePolylineWeb.ts +14 -0
  98. package/src/index.tsx +10 -0
  99. package/src/webContent.ts +182 -0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Anton Seagull
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,203 @@
1
+ # react-native-maplibre-lite
2
+
3
+ Lightweight MapLibre for React Native powered by `WebView`.
4
+
5
+ `react-native-maplibre-lite` renders MapLibre GL JS inside a React Native app with a small, practical API:
6
+
7
+ - `MapView`
8
+ - `Marker`
9
+ - `Polyline`
10
+ - `Polygon`
11
+
12
+ It is designed for teams that want a simple MapLibre integration without native SDK setup complexity.
13
+
14
+ ## Features
15
+
16
+ - MapLibre GL JS in a React Native component
17
+ - Declarative overlays (`Marker`, `Polyline`, `Polygon`)
18
+ - Imperative `fitBounds()` via ref
19
+ - Built-in JS/CSS asset caching using `AsyncStorage`
20
+ - Android performance controls (`performanceMode`, `turboWhileMoving`, `pixelRatio`)
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install react-native-maplibre-lite react-native-webview @react-native-async-storage/async-storage
26
+ ```
27
+
28
+ or
29
+
30
+ ```bash
31
+ yarn add react-native-maplibre-lite react-native-webview @react-native-async-storage/async-storage
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ```tsx
37
+ import React, { useRef } from 'react';
38
+ import { View } from 'react-native';
39
+ import MapView, {
40
+ Marker,
41
+ Polyline,
42
+ Polygon,
43
+ type MapViewRef,
44
+ } from 'react-native-maplibre-lite';
45
+
46
+ const SOURCES = {
47
+ maplibreJS: 'https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.js',
48
+ maplibreCSS: 'https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.css',
49
+ pmtilesJS: 'https://unpkg.com/pmtiles@3.0.7/dist/pmtiles.js',
50
+ };
51
+
52
+ export function MapScreen() {
53
+ const mapRef = useRef<MapViewRef>(null);
54
+
55
+ return (
56
+ <View style={{ flex: 1 }}>
57
+ <MapView
58
+ ref={mapRef}
59
+ style={{ flex: 1 }}
60
+ theme="light"
61
+ center={[37.6173, 55.7558]}
62
+ zoom={11}
63
+ mapStyle="https://demotiles.maplibre.org/style.json"
64
+ zoomEnabled
65
+ scrollEnabled
66
+ sources={SOURCES}
67
+ >
68
+ <Marker
69
+ uniqueId="m-1"
70
+ latitude={55.7558}
71
+ longitude={37.6173}
72
+ color="#1D4ED8"
73
+ />
74
+
75
+ <Polyline
76
+ uniqueId="line-1"
77
+ color="#2563EB"
78
+ width={4}
79
+ coordinates={[
80
+ [37.61, 55.75],
81
+ [37.63, 55.76],
82
+ [37.65, 55.74],
83
+ ]}
84
+ />
85
+
86
+ <Polygon
87
+ uniqueId="poly-1"
88
+ fillColor="#2563EB"
89
+ fillOpacity={0.15}
90
+ strokeColor="#2563EB"
91
+ strokeWidth={2}
92
+ coordinates={[
93
+ [37.60, 55.75],
94
+ [37.62, 55.77],
95
+ [37.66, 55.75],
96
+ [37.60, 55.75],
97
+ ]}
98
+ />
99
+ </MapView>
100
+ </View>
101
+ );
102
+ }
103
+ ```
104
+
105
+ ## API
106
+
107
+ ### `MapView` props
108
+
109
+ | Prop | Type | Required | Description |
110
+ | --- | --- | --- | --- |
111
+ | `theme` | `'light' \| 'dark'` | yes | Placeholder theme before map init |
112
+ | `center` | `[number, number]` | yes | Initial map center as `[lng, lat]` |
113
+ | `zoom` | `number` | yes | Initial zoom level |
114
+ | `mapStyle` | `string` | yes | MapLibre style URL |
115
+ | `style` | `StyleProp<ViewStyle>` | yes | Container style |
116
+ | `sources` | `{ maplibreJS; maplibreCSS; pmtilesJS }` | yes | URLs for MapLibre/PMTiles runtime assets |
117
+ | `minZoom` | `number` | no | Minimum zoom |
118
+ | `maxZoom` | `number` | no | Maximum zoom |
119
+ | `zoomEnabled` | `boolean` | no | Enable zoom gestures |
120
+ | `scrollEnabled` | `boolean` | no | Enable pan/scroll gestures |
121
+ | `showSelectPoint` | `boolean` | no | Show animated center pointer |
122
+ | `selectPointColor` | `string` | no | Center pointer color |
123
+ | `selectPointBackgroundColor` | `string` | no | Center pointer background |
124
+ | `onMoveStart` | `(params) => void` | no | `movestart` event |
125
+ | `onMoveEnd` | `(params) => void` | no | `moveend` event |
126
+ | `onZoomStart` | `(params) => void` | no | `zoomstart` event |
127
+ | `onZoomEnd` | `(params) => void` | no | `zoomend` event |
128
+ | `onIdle` | `(params) => void` | no | `idle` event |
129
+ | `performanceMode` | `'quality' \| 'balanced' \| 'performance'` | no | Rendering quality/performance profile |
130
+ | `pixelRatio` | `number` | no | Manual renderer pixel ratio override |
131
+ | `turboWhileMoving` | `boolean` | no | Hide polyline/polygon overlays while map moves |
132
+
133
+ ### `MapView` ref
134
+
135
+ | Method | Description |
136
+ | --- | --- |
137
+ | `fitBounds()` | Fits camera to all current markers/polylines/polygons |
138
+
139
+ ### `Marker` props
140
+
141
+ | Prop | Type | Required | Description |
142
+ | --- | --- | --- | --- |
143
+ | `uniqueId` | `string` | yes | Unique overlay id |
144
+ | `latitude` | `number` | yes | Marker latitude |
145
+ | `longitude` | `number` | yes | Marker longitude |
146
+ | `onPress` | `() => void` | no | Press callback |
147
+ | `color` | `string` | no | Default marker color |
148
+ | `iconUrl` | `string` | no | Custom marker image URL |
149
+ | `iconWidth` | `number` | no | Custom icon width |
150
+ | `iconHeight` | `number` | no | Custom icon height |
151
+
152
+ ### `Polyline` props
153
+
154
+ | Prop | Type | Required |
155
+ | --- | --- | --- |
156
+ | `uniqueId` | `string` | yes |
157
+ | `coordinates` | `[number, number][]` | yes |
158
+ | `color` | `string` | no |
159
+ | `width` | `number` | no |
160
+
161
+ ### `Polygon` props
162
+
163
+ | Prop | Type | Required |
164
+ | --- | --- | --- |
165
+ | `uniqueId` | `string` | yes |
166
+ | `coordinates` | `[number, number][]` | yes |
167
+ | `fillColor` | `string` | no |
168
+ | `fillOpacity` | `number` | no |
169
+ | `strokeColor` | `string` | no |
170
+ | `strokeOpacity` | `number` | no |
171
+ | `strokeWidth` | `number` | no |
172
+
173
+ ## Performance Tuning (Android)
174
+
175
+ Start with:
176
+
177
+ ```tsx
178
+ <MapView
179
+ // ...
180
+ performanceMode="performance"
181
+ turboWhileMoving
182
+ />
183
+ ```
184
+
185
+ Profiles:
186
+
187
+ - `quality`: best visual quality
188
+ - `balanced`: default on Android; better FPS with moderate quality reduction
189
+ - `performance`: aggressive optimizations (lower renderer resolution, simplified style, reduced map effects)
190
+
191
+ Tips:
192
+
193
+ - If you still see frame drops, pass a lower `pixelRatio` (example: `0.75`)
194
+ - Keep number of simultaneously visible overlays moderate
195
+ - Prefer simpler map styles (fewer labels/3D layers)
196
+
197
+ ## Contributing
198
+
199
+ See the [contributing guide](CONTRIBUTING.md) for local setup and development workflow.
200
+
201
+ ## License
202
+
203
+ MIT
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ export const MAP_ASSETS = {
4
+ DARK_MAP_PLACEHOLDER: require('./dark_placeholder.jpg'),
5
+ LIGHT_MAP_PLACEHOLDER: require('./light_placeholder.jpg')
6
+ };
7
+ //# sourceMappingURL=MAP_ASSETS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MAP_ASSETS","DARK_MAP_PLACEHOLDER","require","LIGHT_MAP_PLACEHOLDER"],"sourceRoot":"../../../src","sources":["assets/MAP_ASSETS.ts"],"mappings":";;AAAA,OAAO,MAAMA,UAAU,GAAG;EACtBC,oBAAoB,EAAEC,OAAO,CAAC,wBAAwB,CAAC;EACvDC,qBAAqB,EAAED,OAAO,CAAC,yBAAyB;AAC5D,CAAC","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ import { useEffect, useRef } from 'react';
4
+ import { Animated } from 'react-native';
5
+ import { MAP_ASSETS } from "../assets/MAP_ASSETS.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const MapPlaceholder = props => {
8
+ const opacityAnim = useRef(new Animated.Value(0.5)).current;
9
+ useEffect(() => {
10
+ const animate = () => {
11
+ Animated.sequence([Animated.timing(opacityAnim, {
12
+ toValue: 1,
13
+ duration: 1000,
14
+ useNativeDriver: true
15
+ }), Animated.timing(opacityAnim, {
16
+ toValue: 0.5,
17
+ duration: 1000,
18
+ useNativeDriver: true
19
+ })]).start(() => animate());
20
+ };
21
+ animate();
22
+ }, [opacityAnim]);
23
+ return /*#__PURE__*/_jsx(Animated.Image, {
24
+ source: props.theme === 'dark' ? MAP_ASSETS.DARK_MAP_PLACEHOLDER : MAP_ASSETS.LIGHT_MAP_PLACEHOLDER,
25
+ style: {
26
+ position: 'absolute',
27
+ top: 0,
28
+ left: 0,
29
+ width: '100%',
30
+ height: '100%',
31
+ zIndex: 1000,
32
+ opacity: opacityAnim
33
+ }
34
+ });
35
+ };
36
+ export default MapPlaceholder;
37
+ //# sourceMappingURL=MapPlaceholder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useRef","Animated","MAP_ASSETS","jsx","_jsx","MapPlaceholder","props","opacityAnim","Value","current","animate","sequence","timing","toValue","duration","useNativeDriver","start","Image","source","theme","DARK_MAP_PLACEHOLDER","LIGHT_MAP_PLACEHOLDER","style","position","top","left","width","height","zIndex","opacity"],"sourceRoot":"../../../src","sources":["components/MapPlaceholder.tsx"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAe,cAAc;AAE9C,SAASC,UAAU,QAAQ,yBAAsB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAElD,MAAMC,cAAc,GAAIC,KAAkC,IAAK;EAC3D,MAAMC,WAAW,GAAGP,MAAM,CAAC,IAAIC,QAAQ,CAACO,KAAK,CAAC,GAAG,CAAC,CAAC,CAACC,OAAO;EAE3DV,SAAS,CAAC,MAAM;IACZ,MAAMW,OAAO,GAAGA,CAAA,KAAM;MAClBT,QAAQ,CAACU,QAAQ,CAAC,CACdV,QAAQ,CAACW,MAAM,CAACL,WAAW,EAAE;QACzBM,OAAO,EAAE,CAAC;QACVC,QAAQ,EAAE,IAAI;QACdC,eAAe,EAAE;MACrB,CAAC,CAAC,EACFd,QAAQ,CAACW,MAAM,CAACL,WAAW,EAAE;QACzBM,OAAO,EAAE,GAAG;QACZC,QAAQ,EAAE,IAAI;QACdC,eAAe,EAAE;MACrB,CAAC,CAAC,CACL,CAAC,CAACC,KAAK,CAAC,MAAMN,OAAO,CAAC,CAAC,CAAC;IAC7B,CAAC;IAEDA,OAAO,CAAC,CAAC;EACb,CAAC,EAAE,CAACH,WAAW,CAAC,CAAC;EAEjB,oBACIH,IAAA,CAACH,QAAQ,CAACgB,KAAK;IACXC,MAAM,EAAEZ,KAAK,CAACa,KAAK,KAAK,MAAM,GAAGjB,UAAU,CAACkB,oBAAoB,GAAGlB,UAAU,CAACmB,qBAAsB;IACpGC,KAAK,EAAE;MACHC,QAAQ,EAAE,UAAU;MACpBC,GAAG,EAAE,CAAC;MACNC,IAAI,EAAE,CAAC;MACPC,KAAK,EAAE,MAAM;MACbC,MAAM,EAAE,MAAM;MACdC,MAAM,EAAE,IAAI;MACZC,OAAO,EAAEtB;IACb;EAAE,CACL,CAAC;AAEV,CAAC;AAED,eAAeF,cAAc","ignoreList":[]}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ import React, { forwardRef, useImperativeHandle, useRef } from 'react';
4
+ import { Animated, StyleSheet, View } from 'react-native';
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ const BORDER_WIDTH_UP = 6;
7
+ const BORDER_WIDTH_DOWN = 3;
8
+ const UP_POSITION = 10;
9
+ const DURATION = 200;
10
+ export const MapSelectPoint = /*#__PURE__*/forwardRef((_props, ref) => {
11
+ const position = useRef('down');
12
+ const borderWidth = useRef(new Animated.Value(BORDER_WIDTH_DOWN)).current;
13
+ const shadowHeight = useRef(new Animated.Value(0)).current;
14
+ const shadowMarginTop = useRef(new Animated.Value(0)).current;
15
+ const handleMarginTop = useRef(new Animated.Value(0)).current;
16
+ useImperativeHandle(ref, () => ({
17
+ up: () => moveMarker('up'),
18
+ down: () => moveMarker('down')
19
+ }));
20
+ const animateTo = (animatedValue, toValue) => {
21
+ return Animated.timing(animatedValue, {
22
+ toValue,
23
+ duration: DURATION,
24
+ useNativeDriver: false
25
+ });
26
+ };
27
+ const moveMarker = direction => {
28
+ if (position.current === direction) return;
29
+ position.current = direction;
30
+ if (direction === 'up') {
31
+ Animated.parallel([animateTo(borderWidth, BORDER_WIDTH_UP), animateTo(shadowHeight, 4), animateTo(shadowMarginTop, UP_POSITION), animateTo(handleMarginTop, -UP_POSITION)]).start();
32
+ } else {
33
+ Animated.parallel([animateTo(borderWidth, BORDER_WIDTH_DOWN), animateTo(shadowHeight, 0), animateTo(shadowMarginTop, 0), animateTo(handleMarginTop, 0)]).start();
34
+ }
35
+ };
36
+ return /*#__PURE__*/_jsxs(View, {
37
+ style: styles.container,
38
+ children: [/*#__PURE__*/_jsx(Animated.View, {
39
+ style: {
40
+ marginTop: handleMarginTop
41
+ },
42
+ children: /*#__PURE__*/_jsxs(View, {
43
+ style: styles.center,
44
+ children: [/*#__PURE__*/_jsx(Animated.View, {
45
+ style: [styles.circle, {
46
+ borderWidth: borderWidth,
47
+ borderColor: _props.color,
48
+ backgroundColor: _props.backgroundColor
49
+ }]
50
+ }), /*#__PURE__*/_jsx(View, {
51
+ style: [styles.line, {
52
+ backgroundColor: _props.color
53
+ }]
54
+ })]
55
+ })
56
+ }), /*#__PURE__*/_jsx(Animated.View, {
57
+ style: [styles.shadow, {
58
+ height: shadowHeight,
59
+ marginTop: shadowMarginTop,
60
+ backgroundColor: _props.color
61
+ }]
62
+ })]
63
+ });
64
+ });
65
+ const styles = StyleSheet.create({
66
+ container: {
67
+ alignItems: 'center'
68
+ },
69
+ center: {
70
+ alignItems: 'center'
71
+ },
72
+ circle: {
73
+ borderRadius: 100,
74
+ width: 28,
75
+ height: 28
76
+ },
77
+ line: {
78
+ width: 2,
79
+ height: 15
80
+ },
81
+ shadow: {
82
+ opacity: 0.6,
83
+ width: 4,
84
+ borderRadius: 100
85
+ }
86
+ });
87
+ export default MapSelectPoint;
88
+ //# sourceMappingURL=MapSelectPoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","forwardRef","useImperativeHandle","useRef","Animated","StyleSheet","View","jsx","_jsx","jsxs","_jsxs","BORDER_WIDTH_UP","BORDER_WIDTH_DOWN","UP_POSITION","DURATION","MapSelectPoint","_props","ref","position","borderWidth","Value","current","shadowHeight","shadowMarginTop","handleMarginTop","up","moveMarker","down","animateTo","animatedValue","toValue","timing","duration","useNativeDriver","direction","parallel","start","style","styles","container","children","marginTop","center","circle","borderColor","color","backgroundColor","line","shadow","height","create","alignItems","borderRadius","width","opacity"],"sourceRoot":"../../../src","sources":["components/MapSelectPoint.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,UAAU,EACVC,mBAAmB,EACnBC,MAAM,QACD,O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,CAACS,IAAI,EAAE;YAAED,eAAe,EAAE9B,MAAM,CAAC6B;UAAM,CAAC;QAAE,CAAE,CAAC;MAAA,CAC7D;IAAC,CACM,CAAC,eAChBrC,IAAA,CAACJ,QAAQ,CAACE,IAAI;MACZ+B,KAAK,EAAE,CACLC,MAAM,CAACU,MAAM,EACb;QACEC,MAAM,EAAE3B,YAAY;QACpBmB,SAAS,EAAElB,eAAe;QAC1BuB,eAAe,EAAE9B,MAAM,CAAC6B;MAC1B,CAAC;IACD,CACH,CAAC;EAAA,CACE,CAAC;AAEX,CACF,CAAC;AAED,MAAMP,MAAM,GAAGjC,UAAU,CAAC6C,MAAM,CAAC;EAC/BX,SAAS,EAAE;IACTY,UAAU,EAAE;EACd,CAAC;EACDT,MAAM,EAAE;IACNS,UAAU,EAAE;EACd,CAAC;EACDR,MAAM,EAAE;IACNS,YAAY,EAAE,GAAG;IACjBC,KAAK,EAAE,EAAE;IACTJ,MAAM,EAAE;EACV,CAAC;EACDF,IAAI,EAAE;IACJM,KAAK,EAAE,CAAC;IACRJ,MAAM,EAAE;EAEV,CAAC;EACDD,MAAM,EAAE;IACNM,OAAO,EAAE,GAAG;IACZD,KAAK,EAAE,CAAC;IACRD,YAAY,EAAE;EAChB;AACF,CAAC,CAAC;AAEF,eAAerC,cAAc","ignoreList":[]}
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+
3
+ import { createContext, forwardRef, useCallback, useContext, useEffect, useImperativeHandle, useRef, useState } from 'react';
4
+ import { Platform, View } from 'react-native';
5
+ import { WebView } from 'react-native-webview';
6
+ import { maplibreHtmlMap } from "../webContent.js";
7
+ import MapPlaceholder from "./MapPlaceholder.js";
8
+ import MapSelectPoint from "./MapSelectPoint.js";
9
+ import addMarkerWeb from "./webFunctions/addMarkerWeb.js";
10
+ import addPolygonWeb from "./webFunctions/addPolygonWeb.js";
11
+ import addPolylineWeb from "./webFunctions/addPolylineWeb.js";
12
+ import fitBoundsWeb from "./webFunctions/fitBoundsWeb.js";
13
+ import initWeb from "./webFunctions/initWeb.js";
14
+ import removeMarkerWeb from "./webFunctions/removeMarkerWeb.js";
15
+ import removePolygonWeb from "./webFunctions/removePolygonWeb.js";
16
+ import removePolylineWeb from "./webFunctions/removePolylineWeb.js";
17
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
18
+ const MapViewContext = /*#__PURE__*/createContext(null);
19
+ export const useMapViewContext = () => {
20
+ const ctx = useContext(MapViewContext);
21
+ if (!ctx) throw new Error('useMapViewContext must be used within <MapView>');
22
+ return ctx;
23
+ };
24
+ const webFunctionsString = [initWeb, addMarkerWeb, removeMarkerWeb, addPolylineWeb, removePolylineWeb, addPolygonWeb, removePolygonWeb, fitBoundsWeb].join('\n');
25
+ const getBoundsFromCoords = coords => {
26
+ if (!coords.length) {
27
+ throw new Error('Empty coordinates array');
28
+ }
29
+ let minLng = coords[0][0];
30
+ let maxLng = coords[0][0];
31
+ let minLat = coords[0][1];
32
+ let maxLat = coords[0][1];
33
+ for (const [lng, lat] of coords) {
34
+ if (lng < minLng) minLng = lng;
35
+ if (lng > maxLng) maxLng = lng;
36
+ if (lat < minLat) minLat = lat;
37
+ if (lat > maxLat) maxLat = lat;
38
+ }
39
+ return [[minLng, minLat], [maxLng, maxLat]];
40
+ };
41
+ export const MapView = /*#__PURE__*/forwardRef((props, ref) => {
42
+ const webViewRef = useRef(null);
43
+ const [inited, setInited] = useState(false);
44
+ const [html, setHtml] = useState('');
45
+ const coordsInMapRef = useRef({});
46
+ const markersClickHandlers = useRef({});
47
+ const mapSelectPointRef = useRef(null);
48
+ const performanceMode = props.performanceMode ?? (Platform.OS === 'android' ? 'balanced' : 'quality');
49
+ const fallbackPixelRatio = performanceMode === 'performance' ? 0.85 : performanceMode === 'balanced' && Platform.OS === 'android' ? 1 : undefined;
50
+ const sendToWebView = useCallback(message => {
51
+ webViewRef.current?.postMessage(JSON.stringify(message));
52
+ }, []);
53
+ const initMap = useCallback(() => {
54
+ sendToWebView({
55
+ function: 'init',
56
+ params: {
57
+ style: props.mapStyle,
58
+ zoomEnabled: props.zoomEnabled ?? false,
59
+ scrollEnabled: props.scrollEnabled ?? false,
60
+ theme: props.theme,
61
+ center: props.center,
62
+ zoom: props.zoom,
63
+ minZoom: props.minZoom,
64
+ maxZoom: props.maxZoom,
65
+ antialias: false,
66
+ crossSourceCollisions: performanceMode !== 'performance',
67
+ fadeDuration: performanceMode === 'performance' ? 0 : 120,
68
+ pixelRatio: props.pixelRatio ?? fallbackPixelRatio,
69
+ simplifyStyle: performanceMode !== 'quality',
70
+ aggressiveSimplifyStyle: performanceMode === 'performance',
71
+ maxPitch: performanceMode === 'performance' ? 0 : 45,
72
+ renderWorldCopies: performanceMode === 'quality',
73
+ turboWhileMoving: props.turboWhileMoving ?? performanceMode === 'performance'
74
+ }
75
+ });
76
+ }, [sendToWebView, props.zoomEnabled, props.scrollEnabled, props.theme, props.center, props.zoom, props.minZoom, props.maxZoom, props.mapStyle, performanceMode, props.pixelRatio, fallbackPixelRatio, props.turboWhileMoving]);
77
+ const addMarker = useCallback(propsMarker => {
78
+ if (propsMarker.latitude && propsMarker.longitude) {
79
+ coordsInMapRef.current[propsMarker.uniqueId] = [[propsMarker.longitude, propsMarker.latitude]];
80
+ }
81
+ if (propsMarker.onPress) {
82
+ markersClickHandlers.current[propsMarker.uniqueId] = propsMarker.onPress;
83
+ } else {
84
+ delete markersClickHandlers.current[propsMarker.uniqueId];
85
+ }
86
+ sendToWebView({
87
+ function: 'addMarker',
88
+ params: propsMarker
89
+ });
90
+ }, [sendToWebView]);
91
+ const removeMarker = useCallback(propsMarker => {
92
+ delete coordsInMapRef.current[propsMarker.uniqueId];
93
+ delete markersClickHandlers.current[propsMarker.uniqueId];
94
+ sendToWebView({
95
+ function: 'removeMarker',
96
+ params: propsMarker
97
+ });
98
+ }, [sendToWebView]);
99
+ const addPolyline = useCallback(propsPolyline => {
100
+ if (propsPolyline.coordinates) {
101
+ coordsInMapRef.current[propsPolyline.uniqueId] = propsPolyline.coordinates;
102
+ }
103
+ sendToWebView({
104
+ function: 'addPolyline',
105
+ params: propsPolyline
106
+ });
107
+ }, [sendToWebView]);
108
+ const removePolyline = useCallback(propsPolyline => {
109
+ delete coordsInMapRef.current[propsPolyline.uniqueId];
110
+ sendToWebView({
111
+ function: 'removePolyline',
112
+ params: propsPolyline
113
+ });
114
+ }, [sendToWebView]);
115
+ const addPolygon = useCallback(propsPolygon => {
116
+ if (propsPolygon.coordinates) {
117
+ coordsInMapRef.current[propsPolygon.uniqueId] = propsPolygon.coordinates;
118
+ }
119
+ sendToWebView({
120
+ function: 'addPolygon',
121
+ params: propsPolygon
122
+ });
123
+ }, [sendToWebView]);
124
+ const removePolygon = useCallback(propsPolygon => {
125
+ delete coordsInMapRef.current[propsPolygon.uniqueId];
126
+ sendToWebView({
127
+ function: 'removePolygon',
128
+ params: propsPolygon
129
+ });
130
+ }, [sendToWebView]);
131
+ const fitBounds = useCallback(() => {
132
+ const coords = Object.values(coordsInMapRef.current).flat();
133
+ if (coords.length === 0) return;
134
+ const bounds = getBoundsFromCoords(coords);
135
+ sendToWebView({
136
+ function: 'fitBounds',
137
+ params: {
138
+ bounds
139
+ }
140
+ });
141
+ }, [sendToWebView]);
142
+ useImperativeHandle(ref, () => ({
143
+ fitBounds
144
+ }), [fitBounds]);
145
+ useEffect(() => {
146
+ if (html) return;
147
+ maplibreHtmlMap(webFunctionsString, props.sources).then(setHtml);
148
+ }, [html, props.sources]);
149
+ const onReceiveMessageFromWebView = useCallback(data => {
150
+ try {
151
+ const msg = JSON.parse(data);
152
+ if (msg.type === 'event') {
153
+ switch (msg.event) {
154
+ case 'movestart':
155
+ mapSelectPointRef.current?.up();
156
+ props.onMoveStart?.(msg.params);
157
+ break;
158
+ case 'moveend':
159
+ props.onMoveEnd?.(msg.params);
160
+ mapSelectPointRef.current?.down();
161
+ break;
162
+ case 'zoomstart':
163
+ props.onZoomStart?.(msg.params);
164
+ break;
165
+ case 'zoomend':
166
+ props.onZoomEnd?.(msg.params);
167
+ break;
168
+ case 'idle':
169
+ props.onIdle?.(msg.params);
170
+ break;
171
+ }
172
+ return;
173
+ }
174
+ if (msg.type === 'inited') {
175
+ setInited(true);
176
+ return;
177
+ }
178
+ if (msg.type === 'scriptReady') {
179
+ initMap();
180
+ return;
181
+ }
182
+ if (msg.type === 'markerClick') {
183
+ const handler = markersClickHandlers.current[msg.uniqueId];
184
+ if (typeof handler === 'function') {
185
+ handler();
186
+ }
187
+ return;
188
+ }
189
+ } catch (e) {
190
+ if (__DEV__) {
191
+ console.warn('MapView: failed to parse WebView message', e);
192
+ }
193
+ }
194
+ }, [props.onMoveStart, props.onMoveEnd, props.onZoomStart, props.onZoomEnd, props.onIdle, initMap]);
195
+ return /*#__PURE__*/_jsxs(View, {
196
+ style: props.style,
197
+ children: [!inited && /*#__PURE__*/_jsx(MapPlaceholder, {
198
+ theme: props.theme
199
+ }), /*#__PURE__*/_jsxs(MapViewContext.Provider, {
200
+ value: {
201
+ addPolygon,
202
+ removePolygon,
203
+ addMarker,
204
+ removeMarker,
205
+ addPolyline,
206
+ removePolyline
207
+ },
208
+ children: [/*#__PURE__*/_jsx(WebView, {
209
+ ref: webViewRef,
210
+ style: {
211
+ flex: 1,
212
+ backgroundColor: 'transparent'
213
+ },
214
+ originWhitelist: ['*'],
215
+ source: {
216
+ html
217
+ },
218
+ onMessage: event => {
219
+ onReceiveMessageFromWebView(event.nativeEvent.data);
220
+ },
221
+ javaScriptEnabled: true,
222
+ domStorageEnabled: true,
223
+ scrollEnabled: false
224
+ }), inited && props.children, inited && props.showSelectPoint && /*#__PURE__*/_jsx(View, {
225
+ pointerEvents: "none",
226
+ style: {
227
+ justifyContent: 'center',
228
+ alignItems: 'center',
229
+ position: 'absolute',
230
+ top: 0,
231
+ left: 0,
232
+ width: '100%',
233
+ height: '100%'
234
+ },
235
+ children: /*#__PURE__*/_jsx(MapSelectPoint, {
236
+ ref: mapSelectPointRef,
237
+ color: props.selectPointColor ?? '#000',
238
+ backgroundColor: props.selectPointBackgroundColor ?? '#fff'
239
+ })
240
+ })]
241
+ })]
242
+ });
243
+ });
244
+ //# sourceMappingURL=MapView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","forwardRef","useCallback","useContext","useEffect","useImperativeHandle","useRef","useState","Platform","View","WebView","maplibreHtmlMap","MapPlaceholder","MapSelectPoint","addMarkerWeb","addPolygonWeb","addPolylineWeb","fitBoundsWeb","initWeb","removeMarkerWeb","removePolygonWeb","removePolylineWeb","jsx","_jsx","jsxs","_jsxs","MapViewContext","useMapViewContext","ctx","Error","webFunctionsString","join","getBoundsFromCoords","coords","length","minLng","maxLng","minLat","maxLat","lng","lat","MapView","props","ref","webViewRef","inited","setInited","html","setHtml","coordsInMapRef","markersClickHandlers","mapSelectPointRef","performanceMode","OS","fallbackPixelRatio","undefined","sendToWebView","message","current","postMessage","JSON","stringify","initMap","function","params","style","mapStyle","zoomEnabled","scrollEnabled","theme","center","zoom","minZoom","maxZoom","antialias","crossSourceCollisions","fadeDuration","pixelRatio","simplifyStyle","aggressiveSimplifyStyle","maxPitch","renderWorldCopies","turboWhileMoving","addMarker","propsMarker","latitude","longitude","uniqueId","onPress","removeMarker","addPolyline","propsPolyline","coordinates","removePolyline","addPolygon","propsPolygon","removePolygon","fitBounds","Object","values","flat","bounds","sources","then","onReceiveMessageFromWebView","data","msg","parse","type","event","up","onMoveStart","onMoveEnd","down","onZoomStart","onZoomEnd","onIdle","handler","e","__DEV__","console","warn","children","Provider","value","flex","backgroundColor","originWhitelist","source","onMessage","nativeEvent","javaScriptEnabled","domStorageEnabled","showSelectPoint","pointerEvents","justifyContent","alignItems","position","top","left","width","height","color","selectPointColor","selectPointBackgroundColor"],"sourceRoot":"../../../src","sources":["components/MapView.tsx"],"mappings":";;AAAA,SACEA,aAAa,EACbC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,mBAAmB,EACnBC,MAAM,EACNC,QAAQ,QACH,OAAO;AAEd,SAEE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AAA6B,QAAA,gBAEFnG,IAAA,CAACb,OAAO;QACJiC,GAAG,EAAEC,UAAW;QAChBqB,KAAK,EAAE;UAAE4D,IAAI,EAAE,CAAC;UAAEC,eAAe,EAAE;QAAc,CAAE;QACnDC,eAAe,EAAE,CAAC,GAAG,CAAE;QACvBC,MAAM,EAAE;UAAEjF;QAAK,CAAE;QACjBkF,SAAS,EAAEpB,KAAK,IAAI;UAChBL,2BAA2B,CAACK,KAAK,CAACqB,WAAW,CAACzB,IAAI,CAAC;QACvD,CAAE;QACF0B,iBAAiB;QACjBC,iBAAiB;QACjBhE,aAAa,EAAE;MAAM,CACxB,CAAC,EAEDvB,MAAM,IAAIH,KAAK,CAACgF,QAAQ,EAExB7E,MAAM,IAAIH,KAAK,CAAC2F,eAAe,iBAC5B9G,IAAA,CAACd,IAAI;QACD6H,aAAa,EAAC,MAAM;QACpBrE,KAAK,EAAE;UACHsE,cAAc,EAAE,QAAQ;UACxBC,UAAU,EAAE,QAAQ;UACpBC,QAAQ,EAAE,UAAU;UACpBC,GAAG,EAAE,CAAC;UACNC,IAAI,EAAE,CAAC;UACPC,KAAK,EAAE,MAAM;UACbC,MAAM,EAAE;QACZ,CAAE;QAAAnB,QAAA,eAEFnG,IAAA,CAACV,cAAc;UACX8B,GAAG,EAAEQ,iBAAkB;UACvB2F,KAAK,EAAEpG,KAAK,CAACqG,gBAAgB,IAAI,MAAO;UACxCjB,eAAe,EAAEpF,KAAK,CAACsG,0BAA0B,IAAI;QAAO,CAC/D;MAAC,CACA,CACT;IAAA,CACoB,CAAC;EAAA,CACxB,CAAC;AAEf,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ import { useEffect, useRef } from 'react';
4
+ import { useMapViewContext } from "./MapView.js";
5
+ export const Marker = props => {
6
+ const {
7
+ addMarker,
8
+ removeMarker
9
+ } = useMapViewContext();
10
+ const lastRenderProps = useRef('');
11
+ const propsRef = useRef(props);
12
+ propsRef.current = props;
13
+ useEffect(() => {
14
+ const serialized = JSON.stringify(props);
15
+ if (lastRenderProps.current !== serialized) {
16
+ addMarker(props);
17
+ lastRenderProps.current = serialized;
18
+ }
19
+ }, [props, addMarker]);
20
+ useEffect(() => {
21
+ return () => {
22
+ removeMarker(propsRef.current);
23
+ };
24
+ }, [removeMarker]);
25
+ return null;
26
+ };
27
+ //# sourceMappingURL=Marker.js.map