react-native-maplibre-lite 0.1.2 → 0.1.4

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 +55 -20
  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 +28 -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 +72 -33
  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 -158
  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 -155
  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,155 +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
- if(layerType === 'symbol' || layerType === 'fill-extrusion' || layerType === 'hillshade'){
16
- shouldHide = true;
17
- }
18
-
19
- if(aggressive && (layerType === 'line' || layerType === 'circle')){
20
- var layerIdLower = String(layerId || '').toLowerCase();
21
- if(
22
- layerIdLower.indexOf('road-label') !== -1 ||
23
- layerIdLower.indexOf('poi') !== -1 ||
24
- layerIdLower.indexOf('label') !== -1 ||
25
- layerIdLower.indexOf('boundary') !== -1 ||
26
- layerIdLower.indexOf('admin') !== -1
27
- ){
28
- shouldHide = true;
29
- }
30
- }
31
-
32
- if(shouldHide){
33
- try{
34
- mapInstance.setLayoutProperty(layerId, 'visibility', 'none');
35
- } catch (_) {}
36
- }
37
- }
38
- }
39
-
40
- function setOverlayLayersVisibility(mapInstance, visibility){
41
- if(!mapInstance) return;
42
- var style = mapInstance.getStyle();
43
- var layers = style && style.layers ? style.layers : [];
44
- for(var i = 0; i < layers.length; i++){
45
- var layer = layers[i];
46
- var layerId = String(layer.id || '');
47
- var isCustomOverlay =
48
- layerId.indexOf('-polylines-layout') !== -1 ||
49
- layerId.indexOf('-polygons-fill') !== -1 ||
50
- layerId.indexOf('-polygons-stroke') !== -1;
51
-
52
- if(isCustomOverlay){
53
- try{
54
- mapInstance.setLayoutProperty(layerId, 'visibility', visibility);
55
- } catch (_) {}
56
- }
57
- }
58
- }
59
-
60
-
61
-
62
-
63
- map = new maplibregl.Map({
64
- container: 'map',
65
- style: params.mapStyle,
66
- center: params.center,
67
- zoom: params.zoom,
68
- scrollZoom: params.scrollEnabled,
69
- doubleClickZoom: params.zoomEnabled,
70
- touchZoomRotate: params.zoomEnabled,
71
- minZoom: params.minZoom,
72
- maxZoom: params.maxZoom,
73
- dragPan: params.scrollEnabled,
74
- dragRotate: params.zoomEnabled,
75
- antialias: params.antialias ?? false,
76
- crossSourceCollisions: params.crossSourceCollisions ?? true,
77
- fadeDuration: params.fadeDuration ?? 120,
78
- pixelRatio: params.pixelRatio,
79
- renderWorldCopies: params.renderWorldCopies ?? true
80
- });
81
-
82
- if (typeof params.maxPitch === 'number') {
83
- map.setMaxPitch(params.maxPitch);
84
- }
85
-
86
- if (params.maxPitch === 0) {
87
- map.dragRotate.disable();
88
- map.touchZoomRotate.disableRotation();
89
- }
90
-
91
-
92
-
93
- function getEventParams(){
94
- if(!map) return {
95
- center: null,
96
- zoom: null
97
- }
98
- var center = map.getCenter();
99
- var zoom = map.getZoom();
100
-
101
-
102
- return {
103
- center: center,
104
- zoom: zoom
105
- }
106
- }
107
-
108
- map.on('error', function(event){
109
-
110
-
111
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'error', params: event }));
112
- })
113
-
114
- //movestart moveend
115
- map.on("movestart", function(event){
116
- if(params.turboWhileMoving){
117
- setOverlayLayersVisibility(map, 'none');
118
- }
119
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'movestart', params: getEventParams() }));
120
- })
121
- map.on("moveend", function(event){
122
- if(params.turboWhileMoving){
123
- setOverlayLayersVisibility(map, 'visible');
124
- }
125
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'moveend', params: getEventParams() }));
126
- })
127
- /*zoomstart zoomend*/
128
- map.on("zoomstart", function(event){
129
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'zoomstart', params: getEventParams() }));
130
- })
131
- map.on("zoomend", function(event){
132
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'zoomend', params: getEventParams() }));
133
- })
134
-
135
-
136
- map.on("idle", function(event){
137
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'idle', params: getEventParams() }));
138
- })
139
-
140
-
141
-
142
-
143
-
144
- map.on('load', function () {
145
- if(params.simplifyStyle){
146
- simplifyStyle(map, Boolean(params.aggressiveSimplifyStyle));
147
- }
148
-
149
- window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'inited' }));
150
- });
151
-
152
-
153
-
154
- }
155
- `
@@ -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
- `;