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.
- package/LICENSE +20 -0
- package/README.md +203 -0
- package/lib/module/assets/MAP_ASSETS.js +7 -0
- package/lib/module/assets/MAP_ASSETS.js.map +1 -0
- package/lib/module/assets/dark_placeholder.jpg +0 -0
- package/lib/module/assets/light_placeholder.jpg +0 -0
- package/lib/module/components/MapPlaceholder.js +37 -0
- package/lib/module/components/MapPlaceholder.js.map +1 -0
- package/lib/module/components/MapSelectPoint.js +88 -0
- package/lib/module/components/MapSelectPoint.js.map +1 -0
- package/lib/module/components/MapView.js +244 -0
- package/lib/module/components/MapView.js.map +1 -0
- package/lib/module/components/Marker.js +27 -0
- package/lib/module/components/Marker.js.map +1 -0
- package/lib/module/components/Polygon.js +27 -0
- package/lib/module/components/Polygon.js.map +1 -0
- package/lib/module/components/Polyline.js +27 -0
- package/lib/module/components/Polyline.js.map +1 -0
- package/lib/module/components/types.js +2 -0
- package/lib/module/components/types.js.map +1 -0
- package/lib/module/components/webFunctions/addMarkerWeb.js +57 -0
- package/lib/module/components/webFunctions/addMarkerWeb.js.map +1 -0
- package/lib/module/components/webFunctions/addPolygonWeb.js +62 -0
- package/lib/module/components/webFunctions/addPolygonWeb.js.map +1 -0
- package/lib/module/components/webFunctions/addPolylineWeb.js +48 -0
- package/lib/module/components/webFunctions/addPolylineWeb.js.map +1 -0
- package/lib/module/components/webFunctions/fitBoundsWeb.js +11 -0
- package/lib/module/components/webFunctions/fitBoundsWeb.js.map +1 -0
- package/lib/module/components/webFunctions/initWeb.js +156 -0
- package/lib/module/components/webFunctions/initWeb.js.map +1 -0
- package/lib/module/components/webFunctions/removeMarkerWeb.js +12 -0
- package/lib/module/components/webFunctions/removeMarkerWeb.js.map +1 -0
- package/lib/module/components/webFunctions/removePolygonWeb.js +22 -0
- package/lib/module/components/webFunctions/removePolygonWeb.js.map +1 -0
- package/lib/module/components/webFunctions/removePolylineWeb.js +17 -0
- package/lib/module/components/webFunctions/removePolylineWeb.js.map +1 -0
- package/lib/module/index.js +9 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/webContent.js +173 -0
- package/lib/module/webContent.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/assets/MAP_ASSETS.d.ts +5 -0
- package/lib/typescript/src/assets/MAP_ASSETS.d.ts.map +1 -0
- package/lib/typescript/src/components/MapPlaceholder.d.ts +5 -0
- package/lib/typescript/src/components/MapPlaceholder.d.ts.map +1 -0
- package/lib/typescript/src/components/MapSelectPoint.d.ts +12 -0
- package/lib/typescript/src/components/MapSelectPoint.d.ts.map +1 -0
- package/lib/typescript/src/components/MapView.d.ts +41 -0
- package/lib/typescript/src/components/MapView.d.ts.map +1 -0
- package/lib/typescript/src/components/Marker.d.ts +3 -0
- package/lib/typescript/src/components/Marker.d.ts.map +1 -0
- package/lib/typescript/src/components/Polygon.d.ts +3 -0
- package/lib/typescript/src/components/Polygon.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.d.ts +3 -0
- package/lib/typescript/src/components/Polyline.d.ts.map +1 -0
- package/lib/typescript/src/components/types.d.ts +38 -0
- package/lib/typescript/src/components/types.d.ts.map +1 -0
- package/lib/typescript/src/components/webFunctions/addMarkerWeb.d.ts +3 -0
- package/lib/typescript/src/components/webFunctions/addMarkerWeb.d.ts.map +1 -0
- package/lib/typescript/src/components/webFunctions/addPolygonWeb.d.ts +3 -0
- package/lib/typescript/src/components/webFunctions/addPolygonWeb.d.ts.map +1 -0
- package/lib/typescript/src/components/webFunctions/addPolylineWeb.d.ts +3 -0
- package/lib/typescript/src/components/webFunctions/addPolylineWeb.d.ts.map +1 -0
- package/lib/typescript/src/components/webFunctions/fitBoundsWeb.d.ts +3 -0
- package/lib/typescript/src/components/webFunctions/fitBoundsWeb.d.ts.map +1 -0
- package/lib/typescript/src/components/webFunctions/initWeb.d.ts +3 -0
- package/lib/typescript/src/components/webFunctions/initWeb.d.ts.map +1 -0
- package/lib/typescript/src/components/webFunctions/removeMarkerWeb.d.ts +3 -0
- package/lib/typescript/src/components/webFunctions/removeMarkerWeb.d.ts.map +1 -0
- package/lib/typescript/src/components/webFunctions/removePolygonWeb.d.ts +3 -0
- package/lib/typescript/src/components/webFunctions/removePolygonWeb.d.ts.map +1 -0
- package/lib/typescript/src/components/webFunctions/removePolylineWeb.d.ts +3 -0
- package/lib/typescript/src/components/webFunctions/removePolylineWeb.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/webContent.d.ts +3 -0
- package/lib/typescript/src/webContent.d.ts.map +1 -0
- package/package.json +158 -0
- package/src/assets/MAP_ASSETS.ts +4 -0
- package/src/assets/dark_placeholder.jpg +0 -0
- package/src/assets/light_placeholder.jpg +0 -0
- package/src/components/MapPlaceholder.tsx +44 -0
- package/src/components/MapSelectPoint.tsx +131 -0
- package/src/components/MapView.tsx +333 -0
- package/src/components/Marker.tsx +31 -0
- package/src/components/Polygon.tsx +31 -0
- package/src/components/Polyline.tsx +31 -0
- package/src/components/types.ts +46 -0
- package/src/components/webFunctions/addMarkerWeb.ts +54 -0
- package/src/components/webFunctions/addPolygonWeb.ts +59 -0
- package/src/components/webFunctions/addPolylineWeb.ts +45 -0
- package/src/components/webFunctions/fitBoundsWeb.ts +8 -0
- package/src/components/webFunctions/initWeb.ts +153 -0
- package/src/components/webFunctions/removeMarkerWeb.ts +9 -0
- package/src/components/webFunctions/removePolygonWeb.ts +19 -0
- package/src/components/webFunctions/removePolylineWeb.ts +14 -0
- package/src/index.tsx +10 -0
- package/src/webContent.ts +182 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useMapViewContext","Marker","props","addMarker","removeMarker","lastRenderProps","propsRef","current","serialized","JSON","stringify"],"sourceRoot":"../../../src","sources":["components/Marker.tsx"],"mappings":";;AAAA,SACEA,SAAS,EACTC,MAAM,QACD,OAAO;AAEd,SAASC,iBAAiB,QAAQ,cAAW;AAG7C,OAAO,MAAMC,MAAM,GAAIC,KAAkB,IAAK;EAC1C,MAAM;IAAEC,SAAS;IAAEC;EAAa,CAAC,GAAGJ,iBAAiB,CAAC,CAAC;EAEvD,MAAMK,eAAe,GAAGN,MAAM,CAAS,EAAE,CAAC;EAC1C,MAAMO,QAAQ,GAAGP,MAAM,CAACG,KAAK,CAAC;EAC9BI,QAAQ,CAACC,OAAO,GAAGL,KAAK;EAExBJ,SAAS,CAAC,MAAM;IACZ,MAAMU,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACR,KAAK,CAAC;IACxC,IAAIG,eAAe,CAACE,OAAO,KAAKC,UAAU,EAAE;MACxCL,SAAS,CAACD,KAAK,CAAC;MAChBG,eAAe,CAACE,OAAO,GAAGC,UAAU;IACxC;EACJ,CAAC,EAAE,CAACN,KAAK,EAAEC,SAAS,CAAC,CAAC;EAEtBL,SAAS,CAAC,MAAM;IACZ,OAAO,MAAM;MACTM,YAAY,CAACE,QAAQ,CAACC,OAAO,CAAC;IAClC,CAAC;EACL,CAAC,EAAE,CAACH,YAAY,CAAC,CAAC;EAElB,OAAO,IAAI;AACf,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 Polygon = props => {
|
|
6
|
+
const {
|
|
7
|
+
addPolygon,
|
|
8
|
+
removePolygon
|
|
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
|
+
addPolygon(props);
|
|
17
|
+
lastRenderProps.current = serialized;
|
|
18
|
+
}
|
|
19
|
+
}, [props, addPolygon]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
return () => {
|
|
22
|
+
removePolygon(propsRef.current);
|
|
23
|
+
};
|
|
24
|
+
}, [removePolygon]);
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=Polygon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useMapViewContext","Polygon","props","addPolygon","removePolygon","lastRenderProps","propsRef","current","serialized","JSON","stringify"],"sourceRoot":"../../../src","sources":["components/Polygon.tsx"],"mappings":";;AAAA,SACEA,SAAS,EACTC,MAAM,QACD,OAAO;AAEd,SAASC,iBAAiB,QAAQ,cAAW;AAG7C,OAAO,MAAMC,OAAO,GAAIC,KAAmB,IAAK;EAC5C,MAAM;IAAEC,UAAU;IAAEC;EAAc,CAAC,GAAGJ,iBAAiB,CAAC,CAAC;EAEzD,MAAMK,eAAe,GAAGN,MAAM,CAAS,EAAE,CAAC;EAC1C,MAAMO,QAAQ,GAAGP,MAAM,CAACG,KAAK,CAAC;EAC9BI,QAAQ,CAACC,OAAO,GAAGL,KAAK;EAExBJ,SAAS,CAAC,MAAM;IACZ,MAAMU,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACR,KAAK,CAAC;IACxC,IAAIG,eAAe,CAACE,OAAO,KAAKC,UAAU,EAAE;MACxCL,UAAU,CAACD,KAAK,CAAC;MACjBG,eAAe,CAACE,OAAO,GAAGC,UAAU;IACxC;EACJ,CAAC,EAAE,CAACN,KAAK,EAAEC,UAAU,CAAC,CAAC;EAEvBL,SAAS,CAAC,MAAM;IACZ,OAAO,MAAM;MACTM,aAAa,CAACE,QAAQ,CAACC,OAAO,CAAC;IACnC,CAAC;EACL,CAAC,EAAE,CAACH,aAAa,CAAC,CAAC;EAEnB,OAAO,IAAI;AACf,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 Polyline = props => {
|
|
6
|
+
const {
|
|
7
|
+
addPolyline,
|
|
8
|
+
removePolyline
|
|
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
|
+
addPolyline(props);
|
|
17
|
+
lastRenderProps.current = serialized;
|
|
18
|
+
}
|
|
19
|
+
}, [props, addPolyline]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
return () => {
|
|
22
|
+
removePolyline(propsRef.current);
|
|
23
|
+
};
|
|
24
|
+
}, [removePolyline]);
|
|
25
|
+
return null;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=Polyline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useMapViewContext","Polyline","props","addPolyline","removePolyline","lastRenderProps","propsRef","current","serialized","JSON","stringify"],"sourceRoot":"../../../src","sources":["components/Polyline.tsx"],"mappings":";;AAAA,SACEA,SAAS,EACTC,MAAM,QACD,OAAO;AAEd,SAASC,iBAAiB,QAAQ,cAAW;AAG7C,OAAO,MAAMC,QAAQ,GAAIC,KAAoB,IAAK;EAC9C,MAAM;IAAEC,WAAW;IAAEC;EAAe,CAAC,GAAGJ,iBAAiB,CAAC,CAAC;EAE3D,MAAMK,eAAe,GAAGN,MAAM,CAAS,EAAE,CAAC;EAC1C,MAAMO,QAAQ,GAAGP,MAAM,CAACG,KAAK,CAAC;EAC9BI,QAAQ,CAACC,OAAO,GAAGL,KAAK;EAExBJ,SAAS,CAAC,MAAM;IACZ,MAAMU,UAAU,GAAGC,IAAI,CAACC,SAAS,CAACR,KAAK,CAAC;IACxC,IAAIG,eAAe,CAACE,OAAO,KAAKC,UAAU,EAAE;MACxCL,WAAW,CAACD,KAAK,CAAC;MAClBG,eAAe,CAACE,OAAO,GAAGC,UAAU;IACxC;EACJ,CAAC,EAAE,CAACN,KAAK,EAAEC,WAAW,CAAC,CAAC;EAExBL,SAAS,CAAC,MAAM;IACZ,OAAO,MAAM;MACTM,cAAc,CAACE,QAAQ,CAACC,OAAO,CAAC;IACpC,CAAC;EACL,CAAC,EAAE,CAACH,cAAc,CAAC,CAAC;EAEpB,OAAO,IAAI;AACf,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["components/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default /*js*/`
|
|
4
|
+
|
|
5
|
+
if(functionName === 'addMarker') {
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
if(markers[params.uniqueId]){
|
|
9
|
+
markers[params.uniqueId].remove();
|
|
10
|
+
delete markers[params.uniqueId];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if(!params?.iconUrl){
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
markers[params.uniqueId] = new maplibregl.Marker({
|
|
18
|
+
color: params.color ?? undefined,
|
|
19
|
+
}).setLngLat([params.longitude, params.latitude])
|
|
20
|
+
.addTo(map);
|
|
21
|
+
markers[params.uniqueId].getElement().addEventListener('click', function() {
|
|
22
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({
|
|
23
|
+
type: 'markerClick',
|
|
24
|
+
uniqueId: params.uniqueId
|
|
25
|
+
}));
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return;
|
|
29
|
+
|
|
30
|
+
}else{
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
const el = document.createElement('div');
|
|
34
|
+
el.className = 'marker';
|
|
35
|
+
el.style.backgroundImage = 'url(' + params.iconUrl + ')';
|
|
36
|
+
el.style.width = params.iconWidth + 'px';
|
|
37
|
+
el.style.height = params.iconHeight + 'px';
|
|
38
|
+
|
|
39
|
+
el.addEventListener('click', () => {
|
|
40
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({
|
|
41
|
+
type: 'markerClick',
|
|
42
|
+
uniqueId: params.uniqueId
|
|
43
|
+
}));
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
markers[params.uniqueId] = new maplibregl.Marker({element: el})
|
|
48
|
+
.setLngLat([params.longitude, params.latitude])
|
|
49
|
+
.addTo(map);
|
|
50
|
+
|
|
51
|
+
return;
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
`;
|
|
57
|
+
//# sourceMappingURL=addMarkerWeb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/webFunctions/addMarkerWeb.ts"],"mappings":";;AAAA,eAAgB,MAAM;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default /*js*/`
|
|
4
|
+
|
|
5
|
+
if(functionName === 'addPolygon') {
|
|
6
|
+
|
|
7
|
+
var sourceId = params.uniqueId + '-polygons-source';
|
|
8
|
+
var fillLayerId = params.uniqueId + '-polygons-fill';
|
|
9
|
+
var strokeLayerId = params.uniqueId + '-polygons-stroke';
|
|
10
|
+
|
|
11
|
+
if(map.getLayer(strokeLayerId)) {
|
|
12
|
+
map.removeLayer(strokeLayerId);
|
|
13
|
+
}
|
|
14
|
+
if(map.getLayer(fillLayerId)) {
|
|
15
|
+
map.removeLayer(fillLayerId);
|
|
16
|
+
}
|
|
17
|
+
if(map.getSource(sourceId)) {
|
|
18
|
+
map.removeSource(sourceId);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
map.addSource(sourceId, {
|
|
22
|
+
'type': 'geojson',
|
|
23
|
+
'data': {
|
|
24
|
+
'type': 'Feature',
|
|
25
|
+
'geometry': {
|
|
26
|
+
'type': 'Polygon',
|
|
27
|
+
'coordinates': [params.coordinates]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
var fillPaint = {};
|
|
33
|
+
fillPaint['fill-color'] = params.fillColor || 'rgba(0,0,0,0)';
|
|
34
|
+
if(params.fillOpacity != null) fillPaint['fill-opacity'] = params.fillOpacity;
|
|
35
|
+
if(params.strokeColor) fillPaint['fill-outline-color'] = params.strokeColor;
|
|
36
|
+
|
|
37
|
+
map.addLayer({
|
|
38
|
+
'id': fillLayerId,
|
|
39
|
+
'type': 'fill',
|
|
40
|
+
'source': sourceId,
|
|
41
|
+
'layout': {},
|
|
42
|
+
'paint': fillPaint
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
if(params.strokeColor || params.strokeWidth) {
|
|
46
|
+
var linePaint = {};
|
|
47
|
+
if(params.strokeColor) linePaint['line-color'] = params.strokeColor;
|
|
48
|
+
if(params.strokeOpacity != null) linePaint['line-opacity'] = params.strokeOpacity;
|
|
49
|
+
if(params.strokeWidth != null) linePaint['line-width'] = params.strokeWidth;
|
|
50
|
+
|
|
51
|
+
map.addLayer({
|
|
52
|
+
'id': strokeLayerId,
|
|
53
|
+
'type': 'line',
|
|
54
|
+
'source': sourceId,
|
|
55
|
+
'layout': {},
|
|
56
|
+
'paint': linePaint
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
//# sourceMappingURL=addPolygonWeb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/webFunctions/addPolygonWeb.ts"],"mappings":";;AAAA,eAAgB,MAAM;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default /*js*/`
|
|
4
|
+
|
|
5
|
+
if(functionName === 'addPolyline') {
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var sourceId = params.uniqueId + '-polylines-source';
|
|
10
|
+
var layerId = params.uniqueId + '-polylines-layout';
|
|
11
|
+
|
|
12
|
+
if(map.getLayer(layerId)) {
|
|
13
|
+
map.removeLayer(layerId);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if(map.getSource(sourceId)) {
|
|
17
|
+
map.removeSource(sourceId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
map.addSource(sourceId, {
|
|
21
|
+
'type': 'geojson',
|
|
22
|
+
'data': {
|
|
23
|
+
'type': 'Feature',
|
|
24
|
+
'properties': {},
|
|
25
|
+
'geometry': {
|
|
26
|
+
'type': 'LineString',
|
|
27
|
+
'coordinates': params.coordinates
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
map.addLayer({
|
|
33
|
+
'id': layerId,
|
|
34
|
+
'type': 'line',
|
|
35
|
+
'source': sourceId,
|
|
36
|
+
'layout': {
|
|
37
|
+
'line-join': 'round',
|
|
38
|
+
'line-cap': 'round'
|
|
39
|
+
},
|
|
40
|
+
'paint': {
|
|
41
|
+
'line-color': params.color ?? '#000000',
|
|
42
|
+
'line-width': params.width ?? 4
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
//# sourceMappingURL=addPolylineWeb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/webFunctions/addPolylineWeb.ts"],"mappings":";;AAAA,eAAgB,MAAM;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/webFunctions/fitBoundsWeb.ts"],"mappings":";;AAAA,eAAgB,MAAM;AACtB;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default /*js*/`
|
|
4
|
+
|
|
5
|
+
if(functionName === 'init') {
|
|
6
|
+
|
|
7
|
+
function simplifyStyle(mapInstance, aggressive){
|
|
8
|
+
if(!mapInstance) return;
|
|
9
|
+
var style = mapInstance.getStyle();
|
|
10
|
+
var layers = style && style.layers ? style.layers : [];
|
|
11
|
+
for(var i = 0; i < layers.length; i++){
|
|
12
|
+
var layer = layers[i];
|
|
13
|
+
var layerId = layer.id;
|
|
14
|
+
var layerType = layer.type;
|
|
15
|
+
var shouldHide = false;
|
|
16
|
+
|
|
17
|
+
if(layerType === 'symbol' || layerType === 'fill-extrusion' || layerType === 'hillshade'){
|
|
18
|
+
shouldHide = true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if(aggressive && (layerType === 'line' || layerType === 'circle')){
|
|
22
|
+
var layerIdLower = String(layerId || '').toLowerCase();
|
|
23
|
+
if(
|
|
24
|
+
layerIdLower.indexOf('road-label') !== -1 ||
|
|
25
|
+
layerIdLower.indexOf('poi') !== -1 ||
|
|
26
|
+
layerIdLower.indexOf('label') !== -1 ||
|
|
27
|
+
layerIdLower.indexOf('boundary') !== -1 ||
|
|
28
|
+
layerIdLower.indexOf('admin') !== -1
|
|
29
|
+
){
|
|
30
|
+
shouldHide = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if(shouldHide){
|
|
35
|
+
try{
|
|
36
|
+
mapInstance.setLayoutProperty(layerId, 'visibility', 'none');
|
|
37
|
+
} catch (_) {}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function setOverlayLayersVisibility(mapInstance, visibility){
|
|
43
|
+
if(!mapInstance) return;
|
|
44
|
+
var style = mapInstance.getStyle();
|
|
45
|
+
var layers = style && style.layers ? style.layers : [];
|
|
46
|
+
for(var i = 0; i < layers.length; i++){
|
|
47
|
+
var layer = layers[i];
|
|
48
|
+
var layerId = String(layer.id || '');
|
|
49
|
+
var isCustomOverlay =
|
|
50
|
+
layerId.indexOf('-polylines-layout') !== -1 ||
|
|
51
|
+
layerId.indexOf('-polygons-fill') !== -1 ||
|
|
52
|
+
layerId.indexOf('-polygons-stroke') !== -1;
|
|
53
|
+
|
|
54
|
+
if(isCustomOverlay){
|
|
55
|
+
try{
|
|
56
|
+
mapInstance.setLayoutProperty(layerId, 'visibility', visibility);
|
|
57
|
+
} catch (_) {}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
map = new maplibregl.Map({
|
|
64
|
+
container: 'map',
|
|
65
|
+
style: params.style,
|
|
66
|
+
//Moscow coordinates
|
|
67
|
+
center: params.center, // starting position [lng, lat]
|
|
68
|
+
zoom: params.zoom, // starting zoom
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
// общий выключатель
|
|
72
|
+
zoomControl: params.zoomEnabled,
|
|
73
|
+
// точнее
|
|
74
|
+
scrollZoom: params.scrollEnabled, // колесо мыши / трекпад
|
|
75
|
+
doubleClickZoom: params.zoomEnabled,
|
|
76
|
+
touchZoomRotate: params.zoomEnabled,
|
|
77
|
+
minZoom: params.minZoom,
|
|
78
|
+
maxZoom: params.maxZoom,
|
|
79
|
+
dragPan: params.scrollEnabled, // запрет перетаскивания
|
|
80
|
+
dragRotate: params.zoomEnabled,
|
|
81
|
+
antialias: params.antialias ?? false,
|
|
82
|
+
crossSourceCollisions: params.crossSourceCollisions ?? true,
|
|
83
|
+
fadeDuration: params.fadeDuration ?? 120,
|
|
84
|
+
pixelRatio: params.pixelRatio,
|
|
85
|
+
renderWorldCopies: params.renderWorldCopies ?? true
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
if (typeof params.maxPitch === 'number') {
|
|
89
|
+
map.setMaxPitch(params.maxPitch);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (params.maxPitch === 0) {
|
|
93
|
+
map.dragRotate.disable();
|
|
94
|
+
map.touchZoomRotate.disableRotation();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
function getEventParams(){
|
|
100
|
+
if(!map) return {
|
|
101
|
+
center: null,
|
|
102
|
+
zoom: null
|
|
103
|
+
}
|
|
104
|
+
var center = map.getCenter();
|
|
105
|
+
var zoom = map.getZoom();
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
center,
|
|
110
|
+
zoom
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//movestart moveend
|
|
115
|
+
map.on("movestart",(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",(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",(event)=>{
|
|
129
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'zoomstart', params: getEventParams() }));
|
|
130
|
+
})
|
|
131
|
+
map.on("zoomend",(event)=>{
|
|
132
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({ type: 'event', event: 'zoomend', params: getEventParams() }));
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
map.on("idle",(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
|
+
`;
|
|
156
|
+
//# sourceMappingURL=initWeb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/webFunctions/initWeb.ts"],"mappings":";;AAAA,eAAgB,MAAM;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/webFunctions/removeMarkerWeb.ts"],"mappings":";;AAAA,eAAgB,MAAM;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default /*js*/`
|
|
4
|
+
|
|
5
|
+
if(functionName === 'removePolygon') {
|
|
6
|
+
var sourceId = params.uniqueId + '-polygons-source';
|
|
7
|
+
var fillLayerId = params.uniqueId + '-polygons-fill';
|
|
8
|
+
var strokeLayerId = params.uniqueId + '-polygons-stroke';
|
|
9
|
+
|
|
10
|
+
if(map.getLayer(strokeLayerId)) {
|
|
11
|
+
map.removeLayer(strokeLayerId);
|
|
12
|
+
}
|
|
13
|
+
if(map.getLayer(fillLayerId)) {
|
|
14
|
+
map.removeLayer(fillLayerId);
|
|
15
|
+
}
|
|
16
|
+
if(map.getSource(sourceId)) {
|
|
17
|
+
map.removeSource(sourceId);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
//# sourceMappingURL=removePolygonWeb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/webFunctions/removePolygonWeb.ts"],"mappings":";;AAAA,eAAgB,MAAM;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export default /*js*/`
|
|
4
|
+
|
|
5
|
+
if(functionName === 'removePolyline') {
|
|
6
|
+
var sourceId = params.uniqueId + '-polylines-source';
|
|
7
|
+
var layerId = params.uniqueId + '-polylines-layout';
|
|
8
|
+
|
|
9
|
+
if(map.getLayer(layerId)) {
|
|
10
|
+
map.removeLayer(layerId);
|
|
11
|
+
}
|
|
12
|
+
if(map.getSource(sourceId)) {
|
|
13
|
+
map.removeSource(sourceId);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
//# sourceMappingURL=removePolylineWeb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/webFunctions/removePolylineWeb.ts"],"mappings":";;AAAA,eAAgB,MAAM;AACtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { MapView } from "./components/MapView.js";
|
|
4
|
+
import { Marker } from "./components/Marker.js";
|
|
5
|
+
import { Polygon } from "./components/Polygon.js";
|
|
6
|
+
import { Polyline } from "./components/Polyline.js";
|
|
7
|
+
export { MapView, Marker, Polygon, Polyline };
|
|
8
|
+
export default MapView;
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MapView","Marker","Polygon","Polyline"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,yBAAsB;AAC9C,SAASC,MAAM,QAAQ,wBAAqB;AAC5C,SAASC,OAAO,QAAQ,yBAAsB;AAC9C,SAASC,QAAQ,QAAQ,0BAAuB;AAEhD,SAASH,OAAO,EAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ;AAC3C,eAAeH,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|