@lugg/maps 0.2.0-alpha.9 → 1.0.0-beta.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/README.md +21 -20
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/luggmaps/LuggCalloutView.kt +74 -0
- package/android/src/main/java/com/luggmaps/LuggCalloutViewManager.kt +38 -0
- package/android/src/main/java/com/luggmaps/LuggMapView.kt +290 -0
- package/android/src/main/java/com/luggmaps/{LuggGoogleMapViewManager.kt → LuggMapViewManager.kt} +99 -36
- package/android/src/main/java/com/luggmaps/LuggMapWrapperView.kt +11 -14
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +187 -21
- package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +28 -0
- package/android/src/main/java/com/luggmaps/LuggPackage.kt +8 -4
- package/android/src/main/java/com/luggmaps/LuggPolygonView.kt +85 -0
- package/android/src/main/java/com/luggmaps/LuggPolygonViewManager.kt +100 -0
- package/android/src/main/java/com/luggmaps/LuggPolylineView.kt +16 -0
- package/android/src/main/java/com/luggmaps/LuggPolylineViewManager.kt +22 -0
- package/android/src/main/java/com/luggmaps/core/GoogleMapProvider.kt +874 -0
- package/android/src/main/java/com/luggmaps/core/MapProviderDelegate.kt +60 -0
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +89 -24
- package/android/src/main/java/com/luggmaps/events/LongPressEvent.kt +29 -0
- package/android/src/main/java/com/luggmaps/events/MarkerDragEvent.kt +41 -0
- package/android/src/main/java/com/luggmaps/events/MarkerPressEvent.kt +34 -0
- package/android/src/main/java/com/luggmaps/events/PolygonPressEvent.kt +12 -0
- package/android/src/main/java/com/luggmaps/events/PressEvent.kt +29 -0
- package/ios/LuggCalloutView.h +23 -0
- package/ios/LuggCalloutView.mm +145 -0
- package/ios/LuggMapView.h +9 -0
- package/ios/LuggMapView.mm +343 -0
- package/ios/LuggMarkerView.h +15 -0
- package/ios/LuggMarkerView.mm +136 -2
- package/ios/LuggPolygonView.h +31 -0
- package/ios/LuggPolygonView.mm +151 -0
- package/ios/LuggPolylineView.h +4 -0
- package/ios/LuggPolylineView.mm +23 -0
- package/ios/core/AppleMapProvider.h +15 -0
- package/ios/core/AppleMapProvider.mm +1173 -0
- package/ios/core/GMSPolylineAnimator.h +3 -0
- package/ios/core/GMSPolylineAnimator.m +101 -15
- package/ios/core/GoogleMapProvider.h +13 -0
- package/ios/core/GoogleMapProvider.mm +798 -0
- package/ios/core/LuggAnnotationView.h +12 -0
- package/ios/core/LuggAnnotationView.mm +55 -0
- package/ios/core/MKPolylineAnimator.h +4 -0
- package/ios/core/MKPolylineAnimator.m +167 -42
- package/ios/core/MapProviderDelegate.h +84 -0
- package/ios/core/PolylineAnimatorBase.h +24 -1
- package/ios/core/PolylineAnimatorBase.m +82 -19
- package/ios/events/LongPressEvent.h +29 -0
- package/ios/events/MarkerDragEvent.h +69 -0
- package/ios/events/MarkerPressEvent.h +29 -0
- package/ios/events/PolygonPressEvent.h +20 -0
- package/ios/events/PressEvent.h +29 -0
- package/ios/extensions/MKMapView+Zoom.h +2 -0
- package/ios/extensions/MKMapView+Zoom.m +14 -4
- package/lib/module/MapProvider.js +2 -4
- package/lib/module/MapProvider.js.map +1 -1
- package/lib/module/MapProvider.web.js +14 -7
- package/lib/module/MapProvider.web.js.map +1 -1
- package/lib/module/MapView.js +33 -16
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +296 -181
- package/lib/module/MapView.web.js.map +1 -1
- package/lib/module/components/GeoJson.js +159 -0
- package/lib/module/components/GeoJson.js.map +1 -0
- package/lib/module/components/GeoJson.types.js +4 -0
- package/lib/module/components/GeoJson.types.js.map +1 -0
- package/lib/module/components/Marker.js +49 -8
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.types.js +4 -0
- package/lib/module/components/Marker.types.js.map +1 -0
- package/lib/module/components/Marker.web.js +159 -24
- package/lib/module/components/Marker.web.js.map +1 -1
- package/lib/module/components/Polygon.js +46 -0
- package/lib/module/components/Polygon.js.map +1 -0
- package/lib/module/components/Polygon.types.js +4 -0
- package/lib/module/components/Polygon.types.js.map +1 -0
- package/lib/module/components/Polygon.web.js +87 -0
- package/lib/module/components/Polygon.web.js.map +1 -0
- package/lib/module/components/Polyline.js +17 -4
- package/lib/module/components/Polyline.js.map +1 -1
- package/lib/module/components/Polyline.types.js +4 -0
- package/lib/module/components/Polyline.types.js.map +1 -0
- package/lib/module/components/Polyline.web.js +108 -31
- package/lib/module/components/Polyline.web.js.map +1 -1
- package/lib/module/components/index.js +4 -2
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/index.web.js +2 -0
- package/lib/module/components/index.web.js.map +1 -1
- package/lib/module/fabric/LuggCalloutViewNativeComponent.ts +20 -0
- package/lib/module/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +43 -7
- package/lib/module/fabric/LuggMarkerViewNativeComponent.ts +49 -1
- package/lib/module/fabric/LuggPolygonViewNativeComponent.ts +25 -0
- package/lib/module/fabric/LuggPolylineViewNativeComponent.ts +8 -0
- package/lib/module/index.js +4 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +4 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/typescript/src/MapProvider.d.ts +1 -1
- package/lib/typescript/src/MapProvider.d.ts.map +1 -1
- package/lib/typescript/src/MapProvider.web.d.ts +23 -1
- package/lib/typescript/src/MapProvider.web.d.ts.map +1 -1
- package/lib/typescript/src/MapView.d.ts +4 -4
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/MapView.types.d.ts +35 -9
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts +2 -11
- package/lib/typescript/src/MapView.web.d.ts.map +1 -1
- package/lib/typescript/src/components/GeoJson.d.ts +4 -0
- package/lib/typescript/src/components/GeoJson.d.ts.map +1 -0
- package/lib/typescript/src/components/GeoJson.types.d.ts +89 -0
- package/lib/typescript/src/components/GeoJson.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Marker.d.ts +6 -33
- package/lib/typescript/src/components/Marker.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.types.d.ts +100 -0
- package/lib/typescript/src/components/Marker.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Marker.web.d.ts +2 -5
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -1
- package/lib/typescript/src/components/Polygon.d.ts +10 -0
- package/lib/typescript/src/components/Polygon.d.ts.map +1 -0
- package/lib/typescript/src/components/Polygon.types.d.ts +33 -0
- package/lib/typescript/src/components/Polygon.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Polygon.web.d.ts +3 -0
- package/lib/typescript/src/components/Polygon.web.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.d.ts +6 -21
- package/lib/typescript/src/components/Polyline.d.ts.map +1 -1
- package/lib/typescript/src/components/Polyline.types.d.ts +53 -0
- package/lib/typescript/src/components/Polyline.types.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.web.d.ts +2 -5
- package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -1
- package/lib/typescript/src/components/index.d.ts +8 -2
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/index.web.d.ts +6 -2
- package/lib/typescript/src/components/index.web.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts +13 -0
- package/lib/typescript/src/fabric/LuggCalloutViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/{LuggGoogleMapViewNativeComponent.d.ts → LuggMapViewNativeComponent.d.ts} +30 -4
- package/lib/typescript/src/fabric/LuggMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts +45 -1
- package/lib/typescript/src/fabric/LuggMarkerViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggPolygonViewNativeComponent.d.ts +18 -0
- package/lib/typescript/src/fabric/LuggPolygonViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts +7 -0
- package/lib/typescript/src/fabric/LuggPolylineViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +11 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +9 -1
- package/lib/typescript/src/index.web.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +11 -0
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +11 -9
- package/src/MapProvider.tsx +1 -3
- package/src/MapProvider.web.tsx +22 -3
- package/src/MapView.tsx +32 -26
- package/src/MapView.types.ts +43 -9
- package/src/MapView.web.tsx +368 -210
- package/src/components/GeoJson.tsx +221 -0
- package/src/components/GeoJson.types.ts +118 -0
- package/src/components/Marker.tsx +75 -38
- package/src/components/Marker.types.ts +102 -0
- package/src/components/Marker.web.tsx +197 -19
- package/src/components/Polygon.tsx +52 -0
- package/src/components/Polygon.types.ts +33 -0
- package/src/components/Polygon.web.tsx +104 -0
- package/src/components/Polyline.tsx +23 -22
- package/src/components/Polyline.types.ts +55 -0
- package/src/components/Polyline.web.tsx +151 -37
- package/src/components/index.ts +17 -2
- package/src/components/index.web.ts +6 -2
- package/src/fabric/LuggCalloutViewNativeComponent.ts +20 -0
- package/src/fabric/{LuggGoogleMapViewNativeComponent.ts → LuggMapViewNativeComponent.ts} +43 -7
- package/src/fabric/LuggMarkerViewNativeComponent.ts +49 -1
- package/src/fabric/LuggPolygonViewNativeComponent.ts +25 -0
- package/src/fabric/LuggPolylineViewNativeComponent.ts +8 -0
- package/src/index.ts +30 -1
- package/src/index.web.ts +16 -1
- package/src/types.ts +13 -0
- package/android/src/main/java/com/luggmaps/LuggGoogleMapView.kt +0 -511
- package/ios/LuggAppleMapView.h +0 -16
- package/ios/LuggAppleMapView.mm +0 -592
- package/ios/LuggGoogleMapView.h +0 -13
- package/ios/LuggGoogleMapView.mm +0 -455
- package/lib/module/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts +0 -54
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +0 -1
- package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +0 -1
- package/src/fabric/LuggAppleMapViewNativeComponent.ts +0 -83
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React, { useMemo } from 'react';
|
|
4
|
+
import { Marker } from './Marker';
|
|
5
|
+
import { Polygon } from './Polygon';
|
|
6
|
+
import { Polyline } from './Polyline';
|
|
7
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
|
+
const toCoordinate = position => ({
|
|
9
|
+
latitude: position[1],
|
|
10
|
+
longitude: position[0]
|
|
11
|
+
});
|
|
12
|
+
const toCoordinates = positions => positions.map(toCoordinate);
|
|
13
|
+
const normalizeFeatures = geojson => {
|
|
14
|
+
switch (geojson.type) {
|
|
15
|
+
case 'FeatureCollection':
|
|
16
|
+
return geojson.features;
|
|
17
|
+
case 'Feature':
|
|
18
|
+
return [geojson];
|
|
19
|
+
default:
|
|
20
|
+
return [{
|
|
21
|
+
type: 'Feature',
|
|
22
|
+
geometry: geojson,
|
|
23
|
+
properties: null
|
|
24
|
+
}];
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const renderGeometry = (geometry, feature, props, keyPrefix) => {
|
|
28
|
+
const elements = [];
|
|
29
|
+
switch (geometry.type) {
|
|
30
|
+
case 'Point':
|
|
31
|
+
{
|
|
32
|
+
const markerProps = {
|
|
33
|
+
coordinate: toCoordinate(geometry.coordinates),
|
|
34
|
+
title: feature.properties?.title,
|
|
35
|
+
description: feature.properties?.description,
|
|
36
|
+
zIndex: props.zIndex
|
|
37
|
+
};
|
|
38
|
+
elements.push(props.renderMarker ? props.renderMarker(markerProps, feature) ?? /*#__PURE__*/_jsx(React.Fragment, {}, keyPrefix) : /*#__PURE__*/_jsx(Marker, {
|
|
39
|
+
...markerProps
|
|
40
|
+
}, keyPrefix));
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case 'MultiPoint':
|
|
44
|
+
{
|
|
45
|
+
for (let i = 0; i < geometry.coordinates.length; i++) {
|
|
46
|
+
const markerProps = {
|
|
47
|
+
coordinate: toCoordinate(geometry.coordinates[i]),
|
|
48
|
+
title: feature.properties?.title,
|
|
49
|
+
description: feature.properties?.description,
|
|
50
|
+
zIndex: props.zIndex
|
|
51
|
+
};
|
|
52
|
+
const key = `${keyPrefix}-${i}`;
|
|
53
|
+
elements.push(props.renderMarker ? props.renderMarker(markerProps, feature) ?? /*#__PURE__*/_jsx(React.Fragment, {}, key) : /*#__PURE__*/_jsx(Marker, {
|
|
54
|
+
...markerProps
|
|
55
|
+
}, key));
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case 'LineString':
|
|
60
|
+
{
|
|
61
|
+
const p = feature.properties;
|
|
62
|
+
const polylineProps = {
|
|
63
|
+
coordinates: toCoordinates(geometry.coordinates),
|
|
64
|
+
strokeColors: p?.stroke ? [p.stroke] : undefined,
|
|
65
|
+
strokeWidth: p?.['stroke-width'],
|
|
66
|
+
zIndex: props.zIndex
|
|
67
|
+
};
|
|
68
|
+
elements.push(props.renderPolyline ? props.renderPolyline(polylineProps, feature) ?? /*#__PURE__*/_jsx(React.Fragment, {}, keyPrefix) : /*#__PURE__*/_jsx(Polyline, {
|
|
69
|
+
...polylineProps
|
|
70
|
+
}, keyPrefix));
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case 'MultiLineString':
|
|
74
|
+
{
|
|
75
|
+
const p = feature.properties;
|
|
76
|
+
for (let i = 0; i < geometry.coordinates.length; i++) {
|
|
77
|
+
const polylineProps = {
|
|
78
|
+
coordinates: toCoordinates(geometry.coordinates[i]),
|
|
79
|
+
strokeColors: p?.stroke ? [p.stroke] : undefined,
|
|
80
|
+
strokeWidth: p?.['stroke-width'],
|
|
81
|
+
zIndex: props.zIndex
|
|
82
|
+
};
|
|
83
|
+
const key = `${keyPrefix}-${i}`;
|
|
84
|
+
elements.push(props.renderPolyline ? props.renderPolyline(polylineProps, feature) ?? /*#__PURE__*/_jsx(React.Fragment, {}, key) : /*#__PURE__*/_jsx(Polyline, {
|
|
85
|
+
...polylineProps
|
|
86
|
+
}, key));
|
|
87
|
+
}
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case 'Polygon':
|
|
91
|
+
{
|
|
92
|
+
const outer = toCoordinates(geometry.coordinates[0]);
|
|
93
|
+
const holes = geometry.coordinates.length > 1 ? geometry.coordinates.slice(1).map(toCoordinates) : undefined;
|
|
94
|
+
const p = feature.properties;
|
|
95
|
+
const polygonProps = {
|
|
96
|
+
coordinates: outer,
|
|
97
|
+
holes,
|
|
98
|
+
fillColor: p?.fill,
|
|
99
|
+
strokeColor: p?.stroke,
|
|
100
|
+
strokeWidth: p?.['stroke-width'],
|
|
101
|
+
zIndex: props.zIndex
|
|
102
|
+
};
|
|
103
|
+
elements.push(props.renderPolygon ? props.renderPolygon(polygonProps, feature) ?? /*#__PURE__*/_jsx(React.Fragment, {}, keyPrefix) : /*#__PURE__*/_jsx(Polygon, {
|
|
104
|
+
...polygonProps
|
|
105
|
+
}, keyPrefix));
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case 'MultiPolygon':
|
|
109
|
+
{
|
|
110
|
+
const p = feature.properties;
|
|
111
|
+
for (let i = 0; i < geometry.coordinates.length; i++) {
|
|
112
|
+
const rings = geometry.coordinates[i];
|
|
113
|
+
const outer = toCoordinates(rings[0]);
|
|
114
|
+
const holes = rings.length > 1 ? rings.slice(1).map(toCoordinates) : undefined;
|
|
115
|
+
const polygonProps = {
|
|
116
|
+
coordinates: outer,
|
|
117
|
+
holes,
|
|
118
|
+
fillColor: p?.fill,
|
|
119
|
+
strokeColor: p?.stroke,
|
|
120
|
+
strokeWidth: p?.['stroke-width'],
|
|
121
|
+
zIndex: props.zIndex
|
|
122
|
+
};
|
|
123
|
+
const key = `${keyPrefix}-${i}`;
|
|
124
|
+
elements.push(props.renderPolygon ? props.renderPolygon(polygonProps, feature) ?? /*#__PURE__*/_jsx(React.Fragment, {}, key) : /*#__PURE__*/_jsx(Polygon, {
|
|
125
|
+
...polygonProps
|
|
126
|
+
}, key));
|
|
127
|
+
}
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case 'GeometryCollection':
|
|
131
|
+
{
|
|
132
|
+
for (let i = 0; i < geometry.geometries.length; i++) {
|
|
133
|
+
elements.push(...renderGeometry(geometry.geometries[i], feature, props, `${keyPrefix}-${i}`));
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return elements;
|
|
139
|
+
};
|
|
140
|
+
export const GeoJson = props => {
|
|
141
|
+
const {
|
|
142
|
+
geojson
|
|
143
|
+
} = props;
|
|
144
|
+
const elements = useMemo(() => {
|
|
145
|
+
const features = normalizeFeatures(geojson);
|
|
146
|
+
const result = [];
|
|
147
|
+
for (let i = 0; i < features.length; i++) {
|
|
148
|
+
const feature = features[i];
|
|
149
|
+
if (!feature.geometry) continue;
|
|
150
|
+
const key = feature.id != null ? String(feature.id) : String(i);
|
|
151
|
+
result.push(...renderGeometry(feature.geometry, feature, props, key));
|
|
152
|
+
}
|
|
153
|
+
return result;
|
|
154
|
+
}, [geojson, props]);
|
|
155
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
156
|
+
children: elements
|
|
157
|
+
});
|
|
158
|
+
};
|
|
159
|
+
//# sourceMappingURL=GeoJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useMemo","Marker","Polygon","Polyline","jsx","_jsx","Fragment","_Fragment","toCoordinate","position","latitude","longitude","toCoordinates","positions","map","normalizeFeatures","geojson","type","features","geometry","properties","renderGeometry","feature","props","keyPrefix","elements","markerProps","coordinate","coordinates","title","description","zIndex","push","renderMarker","i","length","key","p","polylineProps","strokeColors","stroke","undefined","strokeWidth","renderPolyline","outer","holes","slice","polygonProps","fillColor","fill","strokeColor","renderPolygon","rings","geometries","GeoJson","result","id","String","children"],"sourceRoot":"../../../src","sources":["components/GeoJson.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,OAAO,QAA2B,OAAO;AAUzD,SAASC,MAAM,QAAQ,UAAU;AAEjC,SAASC,OAAO,QAAQ,WAAW;AAEnC,SAASC,QAAQ,QAAQ,YAAY;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA;AAKtC,MAAMC,YAAY,GAAIC,QAAkB,KAAkB;EACxDC,QAAQ,EAAED,QAAQ,CAAC,CAAC,CAAC;EACrBE,SAAS,EAAEF,QAAQ,CAAC,CAAC;AACvB,CAAC,CAAC;AAEF,MAAMG,aAAa,GAAIC,SAAqB,IAC1CA,SAAS,CAACC,GAAG,CAACN,YAAY,CAAC;AAE7B,MAAMO,iBAAiB,GAAIC,OAAgB,IAAgB;EACzD,QAAQA,OAAO,CAACC,IAAI;IAClB,KAAK,mBAAmB;MACtB,OAAQD,OAAO,CAAuBE,QAAQ;IAChD,KAAK,SAAS;MACZ,OAAO,CAACF,OAAO,CAAY;IAC7B;MACE,OAAO,CACL;QAAEC,IAAI,EAAE,SAAS;QAAEE,QAAQ,EAAEH,OAAmB;QAAEI,UAAU,EAAE;MAAK,CAAC,CACrE;EACL;AACF,CAAC;AAED,MAAMC,cAAc,GAAGA,CACrBF,QAAkB,EAClBG,OAAgB,EAChBC,KAAmB,EACnBC,SAAiB,KACE;EACnB,MAAMC,QAAwB,GAAG,EAAE;EAEnC,QAAQN,QAAQ,CAACF,IAAI;IACnB,KAAK,OAAO;MAAE;QACZ,MAAMS,WAAwB,GAAG;UAC/BC,UAAU,EAAEnB,YAAY,CAACW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,CAAC;IAC3C,MAAMuC,MAAsB,GAAG,EAAE;IAEjC,KAAK,IAAIrB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGhB,QAAQ,CAACiB,MAAM,EAAED,CAAC,EAAE,EAAE;MACxC,MAAMZ,OAAO,GAAGJ,QAAQ,CAACgB,CAAC,CAAE;MAC5B,IAAI,CAACZ,OAAO,CAACH,QAAQ,EAAE;MAEvB,MAAMiB,GAAG,GAAGd,OAAO,CAACkC,EAAE,IAAI,IAAI,GAAGC,MAAM,CAACnC,OAAO,CAACkC,EAAE,CAAC,GAAGC,MAAM,CAACvB,CAAC,CAAC;MAC/DqB,MAAM,CAACvB,IAAI,CAAC,GAAGX,cAAc,CAACC,OAAO,CAACH,QAAQ,EAAEG,OAAO,EAAEC,KAAK,EAAEa,GAAG,CAAC,CAAC;IACvE;IAEA,OAAOmB,MAAM;EACf,CAAC,EAAE,CAACvC,OAAO,EAAEO,KAAK,CAAC,CAAC;EAEpB,oBAAOlB,IAAA,CAAAE,SAAA;IAAAmD,QAAA,EAAGjC;EAAQ,CAAG,CAAC;AACxB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["components/GeoJson.types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
3
|
+
import React, { isValidElement } from 'react';
|
|
4
4
|
import { StyleSheet } from 'react-native';
|
|
5
5
|
import LuggMarkerViewNativeComponent from '../fabric/LuggMarkerViewNativeComponent';
|
|
6
|
-
import
|
|
7
|
-
|
|
6
|
+
import LuggCalloutViewNativeComponent from '../fabric/LuggCalloutViewNativeComponent';
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
export class Marker extends React.PureComponent {
|
|
9
|
+
getStyle(zIndex) {
|
|
10
|
+
if (zIndex == null) return styles.marker;
|
|
11
|
+
if (zIndex !== this._cachedZIndex) {
|
|
12
|
+
this._cachedZIndex = zIndex;
|
|
13
|
+
this._cachedStyle = [{
|
|
14
|
+
zIndex
|
|
15
|
+
}, styles.marker];
|
|
16
|
+
}
|
|
17
|
+
return this._cachedStyle;
|
|
18
|
+
}
|
|
8
19
|
render() {
|
|
9
20
|
const {
|
|
10
21
|
name,
|
|
@@ -13,18 +24,42 @@ export class Marker extends React.Component {
|
|
|
13
24
|
description,
|
|
14
25
|
anchor,
|
|
15
26
|
zIndex,
|
|
27
|
+
rotate = 0,
|
|
28
|
+
scale = 1,
|
|
29
|
+
rasterize = true,
|
|
30
|
+
draggable = false,
|
|
31
|
+
onPress,
|
|
32
|
+
onDragStart,
|
|
33
|
+
onDragChange,
|
|
34
|
+
onDragEnd,
|
|
35
|
+
callout,
|
|
36
|
+
calloutOptions,
|
|
16
37
|
children
|
|
17
38
|
} = this.props;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
39
|
+
const calloutContent = callout ? /*#__PURE__*/isValidElement(callout) ? callout : /*#__PURE__*/React.createElement(callout) : null;
|
|
40
|
+
const calloutBubbled = calloutOptions?.bubbled ?? true;
|
|
41
|
+
const calloutAnchor = calloutOptions?.anchor;
|
|
42
|
+
return /*#__PURE__*/_jsxs(LuggMarkerViewNativeComponent, {
|
|
43
|
+
style: this.getStyle(zIndex),
|
|
22
44
|
name: name,
|
|
23
45
|
coordinate: coordinate,
|
|
24
46
|
title: title,
|
|
25
47
|
description: description,
|
|
26
48
|
anchor: anchor,
|
|
27
|
-
|
|
49
|
+
rotate: rotate,
|
|
50
|
+
scale: scale,
|
|
51
|
+
rasterize: rasterize,
|
|
52
|
+
draggable: draggable,
|
|
53
|
+
onMarkerPress: onPress,
|
|
54
|
+
onMarkerDragStart: onDragStart,
|
|
55
|
+
onMarkerDragChange: onDragChange,
|
|
56
|
+
onMarkerDragEnd: onDragEnd,
|
|
57
|
+
children: [children, calloutContent && /*#__PURE__*/_jsx(LuggCalloutViewNativeComponent, {
|
|
58
|
+
style: calloutStyles.callout,
|
|
59
|
+
bubbled: calloutBubbled,
|
|
60
|
+
anchor: calloutAnchor,
|
|
61
|
+
children: calloutContent
|
|
62
|
+
})]
|
|
28
63
|
});
|
|
29
64
|
}
|
|
30
65
|
}
|
|
@@ -34,4 +69,10 @@ const styles = StyleSheet.create({
|
|
|
34
69
|
pointerEvents: 'box-none'
|
|
35
70
|
}
|
|
36
71
|
});
|
|
72
|
+
const calloutStyles = StyleSheet.create({
|
|
73
|
+
callout: {
|
|
74
|
+
position: 'absolute',
|
|
75
|
+
pointerEvents: 'box-none'
|
|
76
|
+
}
|
|
77
|
+
});
|
|
37
78
|
//# sourceMappingURL=Marker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","StyleSheet","LuggMarkerViewNativeComponent","jsx","_jsx","Marker","
|
|
1
|
+
{"version":3,"names":["React","isValidElement","StyleSheet","LuggMarkerViewNativeComponent","LuggCalloutViewNativeComponent","jsx","_jsx","jsxs","_jsxs","Marker","PureComponent","getStyle","zIndex","styles","marker","_cachedZIndex","_cachedStyle","render","name","coordinate","title","description","anchor","rotate","scale","rasterize","draggable","onPress","onDragStart","onDragChange","onDragEnd","callout","calloutOptions","children","props","calloutContent","createElement","calloutBubbled","bubbled","calloutAnchor","style","onMarkerPress","onMarkerDragStart","onMarkerDragChange","onMarkerDragEnd","calloutStyles","create","position","pointerEvents"],"sourceRoot":"../../../src","sources":["components/Marker.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,cAAc,QAAQ,OAAO;AAC7C,SAASC,UAAU,QAAQ,cAAc;AACzC,OAAOC,6BAA6B,MAAM,yCAAyC;AACnF,OAAOC,8BAA8B,MAAM,0CAA0C;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAUtF,OAAO,MAAMC,MAAM,SAAST,KAAK,CAACU,aAAa,CAAc;EACnDC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AAQ;MACvBe,iBAAiB,EAAEd,WAAY;MAC/Be,kBAAkB,EAAEd,YAAa;MACjCe,eAAe,EAAEd,SAAU;MAAAG,QAAA,GAE1BA,QAAQ,EACRE,cAAc,iBACb7B,IAAA,CAACF,8BAA8B;QAC7BoC,KAAK,EAAEK,aAAa,CAACd,OAAQ;QAC7BO,OAAO,EAAED,cAAe;QACxBf,MAAM,EAAEiB,aAAc;QAAAN,QAAA,EAErBE;MAAc,CACe,CACjC;IAAA,CAC4B,CAAC;EAEpC;AACF;AAEA,MAAMtB,MAAM,GAAGX,UAAU,CAAC4C,MAAM,CAAC;EAC/BhC,MAAM,EAAE;IACNiC,QAAQ,EAAE,UAAU;IACpBC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC;AAEF,MAAMH,aAAa,GAAG3C,UAAU,CAAC4C,MAAM,CAAC;EACtCf,OAAO,EAAE;IACPgB,QAAQ,EAAE,UAAU;IACpBC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["components/Marker.types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1,34 +1,169 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { AdvancedMarker } from '@vis.gl/react-google-maps';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import React, { isValidElement, useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { AdvancedMarker, InfoWindow, useAdvancedMarkerRef } from '@vis.gl/react-google-maps';
|
|
5
|
+
import { useMapContext } from "../MapProvider.web.js";
|
|
6
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
const CALLOUT_ARROW_HEIGHT = 12;
|
|
8
|
+
const UNBUBBLED_CLASS = 'rnm-callout-unbubbled';
|
|
9
|
+
const UNBUBBLED_STYLE_ID = 'rnm-callout-unbubbled-style';
|
|
10
|
+
function injectUnbubbledStyle() {
|
|
11
|
+
if (document.getElementById(UNBUBBLED_STYLE_ID)) return;
|
|
12
|
+
const style = document.createElement('style');
|
|
13
|
+
style.id = UNBUBBLED_STYLE_ID;
|
|
14
|
+
style.textContent = `
|
|
15
|
+
.gm-style-iw-c:has(.${UNBUBBLED_CLASS}) {
|
|
16
|
+
background: transparent !important;
|
|
17
|
+
box-shadow: none !important;
|
|
18
|
+
padding: 0 !important;
|
|
19
|
+
border-radius: 0 !important;
|
|
20
|
+
}
|
|
21
|
+
.gm-style-iw-d:has(.${UNBUBBLED_CLASS}) {
|
|
22
|
+
overflow: visible !important;
|
|
23
|
+
}
|
|
24
|
+
.gm-style-iw-t:has(.${UNBUBBLED_CLASS})::after,
|
|
25
|
+
.gm-style-iw-t:has(.${UNBUBBLED_CLASS}) .gm-style-iw-tc {
|
|
26
|
+
display: none !important;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
document.head.appendChild(style);
|
|
30
|
+
}
|
|
10
31
|
const toWebAnchor = value => `-${value * 100}%`;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
coordinate,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
32
|
+
const createEvent = (e, coordinate) => ({
|
|
33
|
+
nativeEvent: {
|
|
34
|
+
coordinate: {
|
|
35
|
+
latitude: e.latLng?.lat() ?? coordinate.latitude,
|
|
36
|
+
longitude: e.latLng?.lng() ?? coordinate.longitude
|
|
37
|
+
},
|
|
38
|
+
point: {
|
|
39
|
+
x: e.domEvent?.clientX ?? 0,
|
|
40
|
+
y: e.domEvent?.clientY ?? 0
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
export const Marker = ({
|
|
45
|
+
coordinate,
|
|
46
|
+
title,
|
|
47
|
+
description,
|
|
48
|
+
anchor,
|
|
49
|
+
zIndex,
|
|
50
|
+
rotate,
|
|
51
|
+
scale,
|
|
52
|
+
draggable,
|
|
53
|
+
onPress,
|
|
54
|
+
onDragStart,
|
|
55
|
+
onDragChange,
|
|
56
|
+
onDragEnd,
|
|
57
|
+
callout,
|
|
58
|
+
calloutOptions,
|
|
59
|
+
children
|
|
60
|
+
}) => {
|
|
61
|
+
const {
|
|
62
|
+
moveCamera,
|
|
63
|
+
onCalloutClose,
|
|
64
|
+
closeCallouts
|
|
65
|
+
} = useMapContext();
|
|
66
|
+
const dragPositionRef = useRef(null);
|
|
67
|
+
const [markerRef, markerElement] = useAdvancedMarkerRef();
|
|
68
|
+
const [infoWindowOpen, setInfoWindowOpen] = useState(false);
|
|
69
|
+
const calloutBubbled = calloutOptions?.bubbled ?? true;
|
|
70
|
+
const closeCallout = useCallback(() => setInfoWindowOpen(false), []);
|
|
71
|
+
useEffect(() => onCalloutClose(closeCallout), [onCalloutClose, closeCallout]);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (!calloutBubbled) injectUnbubbledStyle();
|
|
74
|
+
}, [calloutBubbled]);
|
|
75
|
+
const hasCallout = !!(callout || title);
|
|
76
|
+
const calloutContent = callout ? /*#__PURE__*/isValidElement(callout) ? callout : /*#__PURE__*/React.createElement(callout) : title ? /*#__PURE__*/React.createElement('div', {
|
|
77
|
+
style: {
|
|
78
|
+
fontSize: 14
|
|
79
|
+
}
|
|
80
|
+
}, /*#__PURE__*/React.createElement('div', {
|
|
81
|
+
style: {
|
|
82
|
+
fontWeight: 500
|
|
83
|
+
}
|
|
84
|
+
}, title), description ? /*#__PURE__*/React.createElement('div', null, description) : null) : null;
|
|
85
|
+
const transforms = [];
|
|
86
|
+
if (rotate) transforms.push(`rotate(${rotate}deg)`);
|
|
87
|
+
if (scale && scale !== 1) transforms.push(`scale(${scale})`);
|
|
88
|
+
const handleClick = useCallback(e => {
|
|
89
|
+
const pos = dragPositionRef.current;
|
|
90
|
+
const coord = pos ? {
|
|
91
|
+
latitude: pos.lat,
|
|
92
|
+
longitude: pos.lng
|
|
93
|
+
} : coordinate;
|
|
94
|
+
moveCamera(coord);
|
|
95
|
+
onPress?.(createEvent(e, coordinate));
|
|
96
|
+
if (hasCallout) {
|
|
97
|
+
closeCallouts(closeCallout);
|
|
98
|
+
setInfoWindowOpen(prev => !prev);
|
|
99
|
+
}
|
|
100
|
+
}, [moveCamera, onPress, coordinate, hasCallout, closeCallouts, closeCallout]);
|
|
101
|
+
const handleDragStart = useCallback(e => {
|
|
102
|
+
const latLng = e.latLng;
|
|
103
|
+
if (latLng) {
|
|
104
|
+
dragPositionRef.current = {
|
|
105
|
+
lat: latLng.lat(),
|
|
106
|
+
lng: latLng.lng()
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
onDragStart?.(createEvent(e, coordinate));
|
|
110
|
+
}, [onDragStart, coordinate]);
|
|
111
|
+
const handleDrag = useCallback(e => {
|
|
112
|
+
const latLng = e.latLng;
|
|
113
|
+
if (latLng) {
|
|
114
|
+
dragPositionRef.current = {
|
|
115
|
+
lat: latLng.lat(),
|
|
116
|
+
lng: latLng.lng()
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
onDragChange?.(createEvent(e, coordinate));
|
|
120
|
+
}, [onDragChange, coordinate]);
|
|
121
|
+
const handleDragEnd = useCallback(e => {
|
|
122
|
+
const latLng = e.latLng;
|
|
123
|
+
if (latLng) {
|
|
124
|
+
dragPositionRef.current = {
|
|
125
|
+
lat: latLng.lat(),
|
|
126
|
+
lng: latLng.lng()
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
onDragEnd?.(createEvent(e, coordinate));
|
|
130
|
+
}, [onDragEnd, coordinate]);
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
dragPositionRef.current = null;
|
|
133
|
+
}, [coordinate.latitude, coordinate.longitude]);
|
|
134
|
+
const latLngPosition = {
|
|
135
|
+
lat: coordinate.latitude,
|
|
136
|
+
lng: coordinate.longitude
|
|
137
|
+
};
|
|
138
|
+
const position = dragPositionRef.current ?? latLngPosition;
|
|
139
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
140
|
+
children: [/*#__PURE__*/_jsx(AdvancedMarker, {
|
|
141
|
+
ref: markerRef,
|
|
25
142
|
position: position,
|
|
26
143
|
title: title,
|
|
27
144
|
zIndex: zIndex,
|
|
28
145
|
anchorLeft: anchor ? toWebAnchor(anchor.x) : undefined,
|
|
29
146
|
anchorTop: anchor ? toWebAnchor(anchor.y) : undefined,
|
|
147
|
+
clickable: true,
|
|
148
|
+
draggable: draggable,
|
|
149
|
+
onClick: handleClick,
|
|
150
|
+
onDragStart: handleDragStart,
|
|
151
|
+
onDrag: handleDrag,
|
|
152
|
+
onDragEnd: handleDragEnd,
|
|
153
|
+
style: transforms.length > 0 ? {
|
|
154
|
+
transform: transforms.join(' ')
|
|
155
|
+
} : undefined,
|
|
30
156
|
children: children
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
|
|
157
|
+
}), calloutContent && infoWindowOpen && markerElement && /*#__PURE__*/_jsx(InfoWindow, {
|
|
158
|
+
anchor: markerElement,
|
|
159
|
+
pixelOffset: !calloutBubbled ? [0, CALLOUT_ARROW_HEIGHT] : undefined,
|
|
160
|
+
headerDisabled: true,
|
|
161
|
+
onClose: () => setInfoWindowOpen(false),
|
|
162
|
+
children: !calloutBubbled ? /*#__PURE__*/_jsx("div", {
|
|
163
|
+
className: UNBUBBLED_CLASS,
|
|
164
|
+
children: calloutContent
|
|
165
|
+
}) : calloutContent
|
|
166
|
+
})]
|
|
167
|
+
});
|
|
168
|
+
};
|
|
34
169
|
//# sourceMappingURL=Marker.web.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","AdvancedMarker","jsx","_jsx","toWebAnchor","value","
|
|
1
|
+
{"version":3,"names":["React","isValidElement","useCallback","useEffect","useRef","useState","AdvancedMarker","InfoWindow","useAdvancedMarkerRef","useMapContext","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","CALLOUT_ARROW_HEIGHT","UNBUBBLED_CLASS","UNBUBBLED_STYLE_ID","injectUnbubbledStyle","document","getElementById","style","createElement","id","textContent","head","appendChild","toWebAnchor","value","createEvent","e","coordinate","nativeEvent","latitude","latLng","lat","longitude","lng","point","x","domEvent","clientX","y","clientY","Marker","title","description","anchor","zIndex","rotate","scale","draggable","onPress","onDragStart","onDragChange","onDragEnd","callout","calloutOptions","children","moveCamera","onCalloutClose","closeCallouts","dragPositionRef","markerRef","markerElement","infoWindowOpen","setInfoWindowOpen","calloutBubbled","bubbled","closeCallout","hasCallout","calloutContent","fontSize","fontWeight","transforms","push","handleClick","pos","current","coord","prev","handleDragStart","handleDrag","handleDragEnd","latLngPosition","position","ref","anchorLeft","undefined","anchorTop","clickable","onClick","onDrag","length","transform","join","pixelOffset","headerDisabled","onClose","className"],"sourceRoot":"../../../src","sources":["components/Marker.web.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IACVC,cAAc,EACdC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SACEC,cAAc,EACdC,UAAU,EACVC,oBAAoB,QACf,2BAA2B;AAClC,SAASC,aAAa,QAAQ,uBAAoB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAGnD,MAAMC,oBAAoB,GAAG,EAAE;AAC/B,MAAMC,eAAe,GAAG,uBAAuB;AAC/C,MAAMC,kBAAkB,GAAG,6BAA6B;AAExD,SAASC,oBAAoBA,CAAA,EAAG;EAC9B,IAAIC,QAAQ,CAACC,cAAc,CAACH,kBAAkB,CAAC,EAAE;EACjD,MAAMI,KAAK,GAAGF,QAAQ,CAACG,aAAa,CAAC,OAAO,CAAC;EAC7CD,KAAK,CAACE,EAAE,GAAGN,kBAAkB;EAC7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AAO,EAAEf,WAAY;MACrBvB,WAAW,EAAE4B,eAAgB;MAC7BW,MAAM,EAAEV,UAAW;MACnB3B,SAAS,EAAE4B,aAAc;MACzB9D,KAAK,EACHqD,UAAU,CAACmB,MAAM,GAAG,CAAC,GACjB;QAAEC,SAAS,EAAEpB,UAAU,CAACqB,IAAI,CAAC,GAAG;MAAE,CAAC,GACnCP,SACL;MAAA9B,QAAA,EAEAA;IAAQ,CACK,CAAC,EAChBa,cAAc,IAAIN,cAAc,IAAID,aAAa,iBAChDtD,IAAA,CAACJ,UAAU;MACTyC,MAAM,EAAEiB,aAAc;MACtBgC,WAAW,EAAE,CAAC7B,cAAc,GAAG,CAAC,CAAC,EAAEpD,oBAAoB,CAAC,GAAGyE,SAAU;MACrES,cAAc;MACdC,OAAO,EAAEA,CAAA,KAAMhC,iBAAiB,CAAC,KAAK,CAAE;MAAAR,QAAA,EAEvC,CAACS,cAAc,gBACdzD,IAAA;QAAKyF,SAAS,EAAEnF,eAAgB;QAAA0C,QAAA,EAAEa;MAAc,CAAM,CAAC,GAEvDA;IACD,CACS,CACb;EAAA,CACD,CAAC;AAEP,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { StyleSheet } from 'react-native';
|
|
5
|
+
import LuggPolygonViewNativeComponent from '../fabric/LuggPolygonViewNativeComponent';
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
export class Polygon extends React.PureComponent {
|
|
8
|
+
getStyle(zIndex) {
|
|
9
|
+
if (zIndex == null) return styles.polygon;
|
|
10
|
+
if (zIndex !== this._cachedZIndex) {
|
|
11
|
+
this._cachedZIndex = zIndex;
|
|
12
|
+
this._cachedStyle = [{
|
|
13
|
+
zIndex
|
|
14
|
+
}, styles.polygon];
|
|
15
|
+
}
|
|
16
|
+
return this._cachedStyle;
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
const {
|
|
20
|
+
coordinates,
|
|
21
|
+
holes,
|
|
22
|
+
strokeColor,
|
|
23
|
+
strokeWidth,
|
|
24
|
+
fillColor,
|
|
25
|
+
zIndex,
|
|
26
|
+
onPress
|
|
27
|
+
} = this.props;
|
|
28
|
+
return /*#__PURE__*/_jsx(LuggPolygonViewNativeComponent, {
|
|
29
|
+
style: this.getStyle(zIndex),
|
|
30
|
+
coordinates: coordinates,
|
|
31
|
+
holes: holes,
|
|
32
|
+
strokeColor: strokeColor,
|
|
33
|
+
strokeWidth: strokeWidth,
|
|
34
|
+
fillColor: fillColor,
|
|
35
|
+
tappable: !!onPress,
|
|
36
|
+
onPolygonPress: onPress
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const styles = StyleSheet.create({
|
|
41
|
+
polygon: {
|
|
42
|
+
position: 'absolute',
|
|
43
|
+
pointerEvents: 'none'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=Polygon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","StyleSheet","LuggPolygonViewNativeComponent","jsx","_jsx","Polygon","PureComponent","getStyle","zIndex","styles","polygon","_cachedZIndex","_cachedStyle","render","coordinates","holes","strokeColor","strokeWidth","fillColor","onPress","props","style","tappable","onPolygonPress","create","position","pointerEvents"],"sourceRoot":"../../../src","sources":["components/Polygon.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,UAAU,QAAQ,cAAc;AACzC,OAAOC,8BAA8B,MAAM,0CAA0C;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAKtF,OAAO,MAAMC,OAAO,SAASL,KAAK,CAACM,aAAa,CAAe;EAIrDC,QAAQA,CAACC,MAA0B,EAAE;IAC3C,IAAIA,MAAM,IAAI,IAAI,EAAE,OAAOC,MAAM,CAACC,OAAO;IACzC,IAAIF,MAAM,KAAK,IAAI,CAACG,aAAa,EAAE;MACjC,IAAI,CAACA,aAAa,GAAGH,MAAM;MAC3B,IAAI,CAACI,YAAY,GAAG,CAAC;QAAEJ;MAAO,CAAC,EAAEC,MAAM,CAACC,OAAO,CAAC;IAClD;IACA,OAAO,IAAI,CAACE,YAAY;EAC1B;EAEAC,MAAMA,CAAA,EAAG;IACP,MAAM;MACJC,WAAW;MACXC,KAAK;MACLC,WAAW;MACXC,WAAW;MACXC,SAAS;MACTV,MAAM;MACNW;IACF,CAAC,GAAG,IAAI,CAACC,KAAK;IAEd,oBACEhB,IAAA,CAACF,8BAA8B;MAC7BmB,KAAK,EAAE,IAAI,CAACd,QAAQ,CAACC,MAAM,CAAE;MAC7BM,WAAW,EAAEA,WAAY;MACzBC,KAAK,EAAEA,KAAM;MACbC,WAAW,EAAEA,WAAY;MACzBC,WAAW,EAAEA,WAAY;MACzBC,SAAS,EAAEA,SAAU;MACrBI,QAAQ,EAAE,CAAC,CAACH,OAAQ;MACpBI,cAAc,EAAEJ;IAAQ,CACzB,CAAC;EAEN;AACF;AAEA,MAAMV,MAAM,GAAGR,UAAU,CAACuB,MAAM,CAAC;EAC/Bd,OAAO,EAAE;IACPe,QAAQ,EAAE,UAAU;IACpBC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["components/Polygon.types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
4
|
+
import { useMapContext } from "../MapProvider.web.js";
|
|
5
|
+
export const Polygon = ({
|
|
6
|
+
coordinates,
|
|
7
|
+
holes,
|
|
8
|
+
strokeColor = '#000000',
|
|
9
|
+
strokeWidth = 1,
|
|
10
|
+
fillColor = 'rgba(0, 0, 0, 0.3)',
|
|
11
|
+
zIndex = 0,
|
|
12
|
+
onPress
|
|
13
|
+
}) => {
|
|
14
|
+
const {
|
|
15
|
+
map
|
|
16
|
+
} = useMapContext();
|
|
17
|
+
const polygonRef = useRef(null);
|
|
18
|
+
const listenersRef = useRef([]);
|
|
19
|
+
const handleClick = useCallback(() => {
|
|
20
|
+
onPress?.();
|
|
21
|
+
}, [onPress]);
|
|
22
|
+
|
|
23
|
+
// Cleanup on unmount
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
return () => {
|
|
26
|
+
listenersRef.current.forEach(l => l.remove());
|
|
27
|
+
listenersRef.current = [];
|
|
28
|
+
polygonRef.current?.setMap(null);
|
|
29
|
+
polygonRef.current = null;
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
// Sync listeners
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const polygon = polygonRef.current;
|
|
36
|
+
if (!polygon) return;
|
|
37
|
+
listenersRef.current.forEach(l => l.remove());
|
|
38
|
+
listenersRef.current = [];
|
|
39
|
+
if (onPress) {
|
|
40
|
+
listenersRef.current.push(polygon.addListener('click', handleClick));
|
|
41
|
+
}
|
|
42
|
+
polygon.set('clickable', !!onPress);
|
|
43
|
+
}, [onPress, handleClick]);
|
|
44
|
+
|
|
45
|
+
// Sync polygon with props
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!map || coordinates.length === 0) {
|
|
48
|
+
polygonRef.current?.setMap(null);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const outerPath = coordinates.map(c => ({
|
|
52
|
+
lat: c.latitude,
|
|
53
|
+
lng: c.longitude
|
|
54
|
+
}));
|
|
55
|
+
const paths = [outerPath, ...(holes ?? []).map(hole => [...hole].reverse().map(c => ({
|
|
56
|
+
lat: c.latitude,
|
|
57
|
+
lng: c.longitude
|
|
58
|
+
})))];
|
|
59
|
+
if (polygonRef.current) {
|
|
60
|
+
polygonRef.current.setPaths(paths);
|
|
61
|
+
polygonRef.current.setOptions({
|
|
62
|
+
strokeColor: strokeColor,
|
|
63
|
+
strokeWeight: strokeWidth,
|
|
64
|
+
fillColor: fillColor,
|
|
65
|
+
zIndex
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
const polygon = new google.maps.Polygon({
|
|
69
|
+
paths,
|
|
70
|
+
strokeColor: strokeColor,
|
|
71
|
+
strokeWeight: strokeWidth,
|
|
72
|
+
strokeOpacity: 1,
|
|
73
|
+
fillColor: fillColor,
|
|
74
|
+
fillOpacity: 1,
|
|
75
|
+
zIndex,
|
|
76
|
+
clickable: !!onPress,
|
|
77
|
+
map
|
|
78
|
+
});
|
|
79
|
+
polygonRef.current = polygon;
|
|
80
|
+
if (onPress) {
|
|
81
|
+
listenersRef.current.push(polygon.addListener('click', handleClick));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, [map, coordinates, holes, strokeColor, strokeWidth, fillColor, zIndex, onPress, handleClick]);
|
|
85
|
+
return null;
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=Polygon.web.js.map
|