react-native-maplibre-lite 0.1.3 → 0.1.5

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 (73) hide show
  1. package/README.md +133 -45
  2. package/lib/module/components/MapView.js +58 -21
  3. package/lib/module/components/MapView.js.map +1 -1
  4. package/lib/module/components/webMapBuild.js +4 -0
  5. package/lib/module/components/webMapBuild.js.map +1 -0
  6. package/lib/typescript/src/components/MapView.d.ts +29 -2
  7. package/lib/typescript/src/components/MapView.d.ts.map +1 -1
  8. package/lib/typescript/src/components/types.d.ts +30 -5
  9. package/lib/typescript/src/components/types.d.ts.map +1 -1
  10. package/lib/typescript/src/components/webMapBuild.d.ts +2 -0
  11. package/lib/typescript/src/components/webMapBuild.d.ts.map +1 -0
  12. package/lib/typescript/src/index.d.ts +1 -1
  13. package/lib/typescript/src/index.d.ts.map +1 -1
  14. package/package.json +3 -2
  15. package/src/components/MapView.tsx +90 -48
  16. package/src/components/types.ts +37 -6
  17. package/src/components/webMapBuild.ts +4 -0
  18. package/src/index.tsx +13 -1
  19. package/lib/module/components/webContent.js +0 -159
  20. package/lib/module/components/webContent.js.map +0 -1
  21. package/lib/module/components/webFunctions/addMarkerWeb.js +0 -83
  22. package/lib/module/components/webFunctions/addMarkerWeb.js.map +0 -1
  23. package/lib/module/components/webFunctions/addPolygonWeb.js +0 -62
  24. package/lib/module/components/webFunctions/addPolygonWeb.js.map +0 -1
  25. package/lib/module/components/webFunctions/addPolylineWeb.js +0 -48
  26. package/lib/module/components/webFunctions/addPolylineWeb.js.map +0 -1
  27. package/lib/module/components/webFunctions/fitBoundsWeb.js +0 -15
  28. package/lib/module/components/webFunctions/fitBoundsWeb.js.map +0 -1
  29. package/lib/module/components/webFunctions/flyToWeb.js +0 -14
  30. package/lib/module/components/webFunctions/flyToWeb.js.map +0 -1
  31. package/lib/module/components/webFunctions/initWeb.js +0 -188
  32. package/lib/module/components/webFunctions/initWeb.js.map +0 -1
  33. package/lib/module/components/webFunctions/removeMarkerWeb.js +0 -12
  34. package/lib/module/components/webFunctions/removeMarkerWeb.js.map +0 -1
  35. package/lib/module/components/webFunctions/removePolygonWeb.js +0 -22
  36. package/lib/module/components/webFunctions/removePolygonWeb.js.map +0 -1
  37. package/lib/module/components/webFunctions/removePolylineWeb.js +0 -17
  38. package/lib/module/components/webFunctions/removePolylineWeb.js.map +0 -1
  39. package/lib/module/components/webFunctions/updateWeb.js +0 -78
  40. package/lib/module/components/webFunctions/updateWeb.js.map +0 -1
  41. package/lib/typescript/src/components/webContent.d.ts +0 -3
  42. package/lib/typescript/src/components/webContent.d.ts.map +0 -1
  43. package/lib/typescript/src/components/webFunctions/addMarkerWeb.d.ts +0 -3
  44. package/lib/typescript/src/components/webFunctions/addMarkerWeb.d.ts.map +0 -1
  45. package/lib/typescript/src/components/webFunctions/addPolygonWeb.d.ts +0 -3
  46. package/lib/typescript/src/components/webFunctions/addPolygonWeb.d.ts.map +0 -1
  47. package/lib/typescript/src/components/webFunctions/addPolylineWeb.d.ts +0 -3
  48. package/lib/typescript/src/components/webFunctions/addPolylineWeb.d.ts.map +0 -1
  49. package/lib/typescript/src/components/webFunctions/fitBoundsWeb.d.ts +0 -3
  50. package/lib/typescript/src/components/webFunctions/fitBoundsWeb.d.ts.map +0 -1
  51. package/lib/typescript/src/components/webFunctions/flyToWeb.d.ts +0 -2
  52. package/lib/typescript/src/components/webFunctions/flyToWeb.d.ts.map +0 -1
  53. package/lib/typescript/src/components/webFunctions/initWeb.d.ts +0 -3
  54. package/lib/typescript/src/components/webFunctions/initWeb.d.ts.map +0 -1
  55. package/lib/typescript/src/components/webFunctions/removeMarkerWeb.d.ts +0 -3
  56. package/lib/typescript/src/components/webFunctions/removeMarkerWeb.d.ts.map +0 -1
  57. package/lib/typescript/src/components/webFunctions/removePolygonWeb.d.ts +0 -3
  58. package/lib/typescript/src/components/webFunctions/removePolygonWeb.d.ts.map +0 -1
  59. package/lib/typescript/src/components/webFunctions/removePolylineWeb.d.ts +0 -3
  60. package/lib/typescript/src/components/webFunctions/removePolylineWeb.d.ts.map +0 -1
  61. package/lib/typescript/src/components/webFunctions/updateWeb.d.ts +0 -3
  62. package/lib/typescript/src/components/webFunctions/updateWeb.d.ts.map +0 -1
  63. package/src/components/webContent.ts +0 -163
  64. package/src/components/webFunctions/addMarkerWeb.ts +0 -80
  65. package/src/components/webFunctions/addPolygonWeb.ts +0 -59
  66. package/src/components/webFunctions/addPolylineWeb.ts +0 -45
  67. package/src/components/webFunctions/fitBoundsWeb.ts +0 -12
  68. package/src/components/webFunctions/flyToWeb.ts +0 -11
  69. package/src/components/webFunctions/initWeb.ts +0 -185
  70. package/src/components/webFunctions/removeMarkerWeb.ts +0 -9
  71. package/src/components/webFunctions/removePolygonWeb.ts +0 -19
  72. package/src/components/webFunctions/removePolylineWeb.ts +0 -14
  73. package/src/components/webFunctions/updateWeb.ts +0 -75
@@ -1,185 +0,0 @@
1
- export default /*js*/`
2
-
3
- if(functionName === 'init') {
4
-
5
- function simplifyStyle(mapInstance, aggressive){
6
- if(!mapInstance) return;
7
- var style = mapInstance.getStyle();
8
- var layers = style && style.layers ? style.layers : [];
9
- for(var i = 0; i < layers.length; i++){
10
- var layer = layers[i];
11
- var layerId = layer.id;
12
- var layerType = layer.type;
13
- var shouldHide = false;
14
-
15
- // Keep labels (streets / addresses) visible — hide only expensive visual layers by default.
16
- if(layerType === 'fill-extrusion' || layerType === 'hillshade'){
17
- shouldHide = true;
18
- }
19
-
20
- if(layerType === 'symbol' && aggressive){
21
- var idLower = String(layerId || '').toLowerCase();
22
- var sourceLayerLower = String(layer['source-layer'] || '').toLowerCase();
23
-
24
- // Keep road + address/house number labels.
25
- var keepLabel =
26
- idLower.indexOf('road') !== -1 ||
27
- idLower.indexOf('street') !== -1 ||
28
- idLower.indexOf('housenumber') !== -1 ||
29
- idLower.indexOf('house_number') !== -1 ||
30
- idLower.indexOf('house-number') !== -1 ||
31
- idLower.indexOf('address') !== -1 ||
32
- sourceLayerLower.indexOf('housenumber') !== -1 ||
33
- sourceLayerLower.indexOf('house') !== -1 ||
34
- sourceLayerLower.indexOf('address') !== -1;
35
-
36
- // Hide most POI/other symbols in aggressive mode.
37
- var hideSymbol =
38
- idLower.indexOf('poi') !== -1 ||
39
- idLower.indexOf('transit') !== -1 ||
40
- idLower.indexOf('airport') !== -1 ||
41
- idLower.indexOf('rail') !== -1 ||
42
- idLower.indexOf('ferry') !== -1;
43
-
44
- if(!keepLabel && hideSymbol){
45
- shouldHide = true;
46
- }
47
- }
48
-
49
- if(aggressive && (layerType === 'line' || layerType === 'circle')){
50
- var layerIdLower = String(layerId || '').toLowerCase();
51
- if(
52
- layerIdLower.indexOf('road-label') !== -1 ||
53
- layerIdLower.indexOf('poi') !== -1 ||
54
- layerIdLower.indexOf('label') !== -1 ||
55
- layerIdLower.indexOf('boundary') !== -1 ||
56
- layerIdLower.indexOf('admin') !== -1
57
- ){
58
- shouldHide = true;
59
- }
60
- }
61
-
62
- if(shouldHide){
63
- try{
64
- mapInstance.setLayoutProperty(layerId, 'visibility', 'none');
65
- } catch (_) {}
66
- }
67
- }
68
- }
69
-
70
- function setOverlayLayersVisibility(mapInstance, visibility){
71
- if(!mapInstance) return;
72
- var style = mapInstance.getStyle();
73
- var layers = style && style.layers ? style.layers : [];
74
- for(var i = 0; i < layers.length; i++){
75
- var layer = layers[i];
76
- var layerId = String(layer.id || '');
77
- var isCustomOverlay =
78
- layerId.indexOf('-polylines-layout') !== -1 ||
79
- layerId.indexOf('-polygons-fill') !== -1 ||
80
- layerId.indexOf('-polygons-stroke') !== -1;
81
-
82
- if(isCustomOverlay){
83
- try{
84
- mapInstance.setLayoutProperty(layerId, 'visibility', visibility);
85
- } catch (_) {}
86
- }
87
- }
88
- }
89
-
90
-
91
-
92
-
93
- map = new maplibregl.Map({
94
- container: 'map',
95
- style: params.mapStyle,
96
- center: params.center,
97
- zoom: params.zoom,
98
- scrollZoom: params.scrollEnabled,
99
- doubleClickZoom: params.zoomEnabled,
100
- touchZoomRotate: params.zoomEnabled,
101
- minZoom: params.minZoom,
102
- maxZoom: params.maxZoom,
103
- dragPan: params.scrollEnabled,
104
- dragRotate: params.zoomEnabled,
105
- antialias: params.antialias ?? false,
106
- crossSourceCollisions: params.crossSourceCollisions ?? true,
107
- fadeDuration: params.fadeDuration ?? 120,
108
- pixelRatio: params.pixelRatio,
109
- renderWorldCopies: params.renderWorldCopies ?? true
110
- });
111
-
112
- if (typeof params.maxPitch === 'number') {
113
- map.setMaxPitch(params.maxPitch);
114
- }
115
-
116
- if (params.maxPitch === 0) {
117
- map.dragRotate.disable();
118
- map.touchZoomRotate.disableRotation();
119
- }
120
-
121
-
122
-
123
- function getEventParams(){
124
- if(!map) return {
125
- center: null,
126
- zoom: null
127
- }
128
- var center = map.getCenter();
129
- var zoom = map.getZoom();
130
-
131
-
132
- return {
133
- center: center,
134
- zoom: zoom
135
- }
136
- }
137
-
138
- map.on('error', function(event){
139
-
140
-
141
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'error', params: event }));
142
- })
143
-
144
- //movestart moveend
145
- map.on("movestart", function(event){
146
- if(params.turboWhileMoving){
147
- setOverlayLayersVisibility(map, 'none');
148
- }
149
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'movestart', params: getEventParams() }));
150
- })
151
- map.on("moveend", function(event){
152
- if(params.turboWhileMoving){
153
- setOverlayLayersVisibility(map, 'visible');
154
- }
155
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'moveend', params: getEventParams() }));
156
- })
157
- /*zoomstart zoomend*/
158
- map.on("zoomstart", function(event){
159
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'zoomstart', params: getEventParams() }));
160
- })
161
- map.on("zoomend", function(event){
162
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'zoomend', params: getEventParams() }));
163
- })
164
-
165
-
166
- map.on("idle", function(event){
167
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'idle', params: getEventParams() }));
168
- })
169
-
170
-
171
-
172
-
173
-
174
- map.on('load', function () {
175
- if(params.simplifyStyle){
176
- simplifyStyle(map, Boolean(params.aggressiveSimplifyStyle));
177
- }
178
-
179
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'inited' }));
180
- });
181
-
182
-
183
-
184
- }
185
- `
@@ -1,9 +0,0 @@
1
- export default /*js*/`
2
-
3
- if(functionName === 'removeMarker') {
4
- if(markers[params.uniqueId]){
5
- markers[params.uniqueId].remove();
6
- delete markers[params.uniqueId];
7
- }
8
- }
9
- `
@@ -1,19 +0,0 @@
1
- export default /*js*/`
2
-
3
- if(functionName === 'removePolygon') {
4
- var sourceId = params.uniqueId + '-polygons-source';
5
- var fillLayerId = params.uniqueId + '-polygons-fill';
6
- var strokeLayerId = params.uniqueId + '-polygons-stroke';
7
-
8
- if(map.getLayer(strokeLayerId)) {
9
- map.removeLayer(strokeLayerId);
10
- }
11
- if(map.getLayer(fillLayerId)) {
12
- map.removeLayer(fillLayerId);
13
- }
14
- if(map.getSource(sourceId)) {
15
- map.removeSource(sourceId);
16
- }
17
-
18
- }
19
- `
@@ -1,14 +0,0 @@
1
- export default /*js*/`
2
-
3
- if(functionName === 'removePolyline') {
4
- var sourceId = params.uniqueId + '-polylines-source';
5
- var layerId = params.uniqueId + '-polylines-layout';
6
-
7
- if(map.getLayer(layerId)) {
8
- map.removeLayer(layerId);
9
- }
10
- if(map.getSource(sourceId)) {
11
- map.removeSource(sourceId);
12
- }
13
- }
14
- `;
@@ -1,75 +0,0 @@
1
- export default /*js*/`
2
-
3
- function centersAreEqual(a, b, epsilon = 1e-6) {
4
- return (
5
- Math.abs(a.lng - b[0]) < epsilon &&
6
- Math.abs(a.lat - b[1]) < epsilon
7
- );
8
- }
9
-
10
- if(functionName === 'update') {
11
-
12
- /* if(params && params.center) {
13
- var newCenter = params.center;
14
- var currentCenter = map.getCenter();
15
-
16
- if (!centersAreEqual(currentCenter, newCenter)) {
17
- map.setCenter(newCenter);
18
- }
19
- }
20
-
21
- if(params && params.zoom != null) {
22
- var newZoom = params.zoom;
23
- var currentZoom = map.getZoom();
24
-
25
- if(currentZoom !== newZoom) {
26
- map.setZoom(newZoom);
27
- }
28
- }*/
29
-
30
- if(params && params.minZoom != null) {
31
- var newMinZoom = params.minZoom;
32
- var currentMinZoom = map.getMinZoom();
33
-
34
- if(currentMinZoom !== newMinZoom) {
35
- map.setMinZoom(newMinZoom);
36
- }
37
- }
38
-
39
- if(params && params.maxZoom != null) {
40
- var newMaxZoom = params.maxZoom;
41
- var currentMaxZoom = map.getMaxZoom();
42
-
43
- if(currentMaxZoom !== newMaxZoom) {
44
- map.setMaxZoom(newMaxZoom);
45
- }
46
- }
47
-
48
- if(params && params.zoomEnabled != null) {
49
- if(params.zoomEnabled) {
50
- map.doubleClickZoom.enable();
51
- map.touchZoomRotate.enable();
52
- map.dragRotate.enable();
53
- } else {
54
- map.doubleClickZoom.disable();
55
- map.touchZoomRotate.disable();
56
- map.dragRotate.disable();
57
- }
58
- }
59
-
60
- if(params && params.scrollEnabled != null) {
61
- if(params.scrollEnabled) {
62
- map.scrollZoom.enable();
63
- map.dragPan.enable();
64
- } else {
65
- map.scrollZoom.disable();
66
- map.dragPan.disable();
67
- }
68
- }
69
-
70
- if(params && params.mapStyle) {
71
- map.setStyle(params.mapStyle);
72
- }
73
-
74
- }
75
- `;