@lugg/maps 0.2.0-alpha.1 → 0.2.0-alpha.11
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 +17 -4
- package/android/src/main/java/com/luggmaps/LuggGoogleMapView.kt +30 -8
- package/android/src/main/java/com/luggmaps/LuggGoogleMapViewManager.kt +10 -2
- package/android/src/main/java/com/luggmaps/LuggMarkerView.kt +7 -1
- package/android/src/main/java/com/luggmaps/LuggMarkerViewManager.kt +6 -0
- package/android/src/main/java/com/luggmaps/LuggPolylineView.kt +7 -0
- package/android/src/main/java/com/luggmaps/LuggPolylineViewManager.kt +6 -0
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +89 -43
- package/ios/LuggAppleMapView.mm +45 -5
- package/ios/LuggGoogleMapView.mm +18 -6
- package/ios/LuggMarkerView.h +2 -0
- package/ios/LuggMarkerView.mm +13 -0
- package/ios/LuggPolylineView.h +1 -0
- package/ios/LuggPolylineView.mm +6 -1
- package/ios/core/GMSPolylineAnimator.m +85 -36
- package/ios/core/MKPolylineAnimator.m +63 -32
- package/lib/module/MapProvider.js +13 -0
- package/lib/module/MapProvider.js.map +1 -0
- package/lib/module/MapProvider.types.js +4 -0
- package/lib/module/MapProvider.types.js.map +1 -0
- package/lib/module/MapProvider.web.js +14 -0
- package/lib/module/MapProvider.web.js.map +1 -0
- package/lib/module/MapView.js +8 -2
- package/lib/module/MapView.js.map +1 -1
- package/lib/module/MapView.web.js +235 -0
- package/lib/module/MapView.web.js.map +1 -0
- package/lib/module/components/Marker.js +4 -1
- package/lib/module/components/Marker.js.map +1 -1
- package/lib/module/components/Marker.web.js +25 -0
- package/lib/module/components/Marker.web.js.map +1 -0
- package/lib/module/components/Polyline.js +5 -2
- package/lib/module/components/Polyline.js.map +1 -1
- package/lib/module/components/Polyline.web.js +169 -0
- package/lib/module/components/Polyline.web.js.map +1 -0
- package/lib/module/components/index.js +2 -2
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/index.web.js +5 -0
- package/lib/module/components/index.web.js.map +1 -0
- package/lib/module/fabric/LuggAppleMapViewNativeComponent.ts +4 -1
- package/lib/module/fabric/LuggGoogleMapViewNativeComponent.ts +4 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +6 -0
- package/lib/module/index.web.js.map +1 -0
- package/lib/typescript/src/MapProvider.d.ts +8 -0
- package/lib/typescript/src/MapProvider.d.ts.map +1 -0
- package/lib/typescript/src/MapProvider.types.d.ts +16 -0
- package/lib/typescript/src/MapProvider.types.d.ts.map +1 -0
- package/lib/typescript/src/MapProvider.web.d.ts +3 -0
- package/lib/typescript/src/MapProvider.web.d.ts.map +1 -0
- package/lib/typescript/src/MapView.d.ts.map +1 -1
- package/lib/typescript/src/MapView.types.d.ts +1 -2
- package/lib/typescript/src/MapView.types.d.ts.map +1 -1
- package/lib/typescript/src/MapView.web.d.ts +3 -0
- package/lib/typescript/src/MapView.web.d.ts.map +1 -0
- package/lib/typescript/src/components/Marker.d.ts +4 -0
- package/lib/typescript/src/components/Marker.d.ts.map +1 -1
- package/lib/typescript/src/components/Marker.web.d.ts +3 -0
- package/lib/typescript/src/components/Marker.web.d.ts.map +1 -0
- package/lib/typescript/src/components/Polyline.d.ts +4 -0
- package/lib/typescript/src/components/Polyline.d.ts.map +1 -1
- package/lib/typescript/src/components/Polyline.web.d.ts +3 -0
- package/lib/typescript/src/components/Polyline.web.d.ts.map +1 -0
- package/lib/typescript/src/components/index.web.d.ts +5 -0
- package/lib/typescript/src/components/index.web.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/fabric/LuggAppleMapViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts +1 -1
- package/lib/typescript/src/fabric/LuggGoogleMapViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.web.d.ts +7 -0
- package/lib/typescript/src/index.web.d.ts.map +1 -0
- package/package.json +15 -2
- package/src/MapProvider.tsx +10 -0
- package/src/MapProvider.types.ts +16 -0
- package/src/MapProvider.web.tsx +6 -0
- package/src/MapView.tsx +11 -2
- package/src/MapView.types.ts +1 -2
- package/src/MapView.web.tsx +283 -0
- package/src/components/Marker.tsx +6 -2
- package/src/components/Marker.web.tsx +24 -0
- package/src/components/Polyline.tsx +6 -1
- package/src/components/Polyline.web.tsx +209 -0
- package/src/components/index.web.ts +4 -0
- package/src/fabric/LuggAppleMapViewNativeComponent.ts +4 -1
- package/src/fabric/LuggGoogleMapViewNativeComponent.ts +4 -1
- package/src/index.ts +8 -1
- package/src/index.web.ts +17 -0
|
@@ -11,11 +11,10 @@ export interface MoveCameraOptions {
|
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Options for fitting coordinates in view
|
|
14
|
-
* @default padding 0
|
|
15
14
|
* @default duration -1
|
|
16
15
|
*/
|
|
17
16
|
export interface FitCoordinatesOptions {
|
|
18
|
-
padding?:
|
|
17
|
+
padding?: EdgeInsets;
|
|
19
18
|
duration?: number;
|
|
20
19
|
}
|
|
21
20
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapView.types.d.ts","sourceRoot":"","sources":["../../../src/MapView.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEnE;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED
|
|
1
|
+
{"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AO,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;IACzE;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC;IACzE;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MapView.web.d.ts","sourceRoot":"","sources":["../../../src/MapView.web.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EAIX,MAAM,iBAAiB,CAAC;AAyEzB,eAAO,MAAM,OAAO,qGAyLlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Marker.d.ts","sourceRoot":"","sources":["../../../../src/components/Marker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,qBAAa,MAAO,SAAQ,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC;IACtD,MAAM;CAiBP"}
|
|
1
|
+
{"version":3,"file":"Marker.d.ts","sourceRoot":"","sources":["../../../../src/components/Marker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAElD,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,qBAAa,MAAO,SAAQ,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC;IACtD,MAAM;CAiBP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Marker.web.d.ts","sourceRoot":"","sources":["../../../../src/components/Marker.web.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C,wBAAgB,MAAM,CAAC,EACrB,UAAU,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,QAAQ,GACT,EAAE,WAAW,2CAYb"}
|
|
@@ -18,6 +18,10 @@ export interface PolylineProps {
|
|
|
18
18
|
* Animate the polyline with a snake effect
|
|
19
19
|
*/
|
|
20
20
|
animated?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Z-index for layering polylines
|
|
23
|
+
*/
|
|
24
|
+
zIndex?: number;
|
|
21
25
|
}
|
|
22
26
|
export declare class Polyline extends React.Component<PolylineProps> {
|
|
23
27
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Polyline.d.ts","sourceRoot":"","sources":["../../../../src/components/Polyline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAC5B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Polyline.d.ts","sourceRoot":"","sources":["../../../../src/components/Polyline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B;;OAEG;IACH,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAC5B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,QAAS,SAAQ,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC;IAC1D,MAAM;CAmBP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Polyline.web.d.ts","sourceRoot":"","sources":["../../../../src/components/Polyline.web.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAkChD,wBAAgB,QAAQ,CAAC,EACvB,WAAW,EACX,YAAY,EACZ,WAAe,EACf,QAAQ,EACR,MAAM,GACP,EAAE,aAAa,QAsKf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/components/index.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -46,7 +46,7 @@ export interface NativeProps extends ViewProps {
|
|
|
46
46
|
type ComponentType = HostComponent<NativeProps>;
|
|
47
47
|
interface NativeCommands {
|
|
48
48
|
moveCamera: (viewRef: React.ElementRef<ComponentType>, latitude: Double, longitude: Double, zoom: Double, duration: Double) => void;
|
|
49
|
-
fitCoordinates: (viewRef: React.ElementRef<ComponentType>, coordinates: Coordinate[],
|
|
49
|
+
fitCoordinates: (viewRef: React.ElementRef<ComponentType>, coordinates: Coordinate[], paddingTop: Double, paddingLeft: Double, paddingBottom: Double, paddingRight: Double, duration: Double) => void;
|
|
50
50
|
}
|
|
51
51
|
export declare const Commands: NativeCommands;
|
|
52
52
|
declare const _default: ComponentType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LuggAppleMapViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/fabric/LuggA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CAAC,eAAe,CAAC,CAAC;IACnD,YAAY,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;CAC1C;AAED,KAAK,aAAa,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;AAEhD,UAAU,cAAc;IACtB,UAAU,EAAE,CACV,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,EACxC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,KACb,IAAI,CAAC;IACV,cAAc,EAAE,CACd,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,EACxC,WAAW,EAAE,UAAU,EAAE,EACzB,
|
|
1
|
+
{"version":3,"file":"LuggAppleMapViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/fabric/LuggAppleMapViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EACV,MAAM,EACN,kBAAkB,EACnB,MAAM,2CAA2C,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE;QACV,QAAQ,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C;CACX;AAED,eAAO,MAAM,QAAQ,gBAEnB,CAAC;wBAIE,aAAa;AAFlB,wBAEmB"}
|
|
@@ -47,7 +47,7 @@ export interface NativeProps extends ViewProps {
|
|
|
47
47
|
type ComponentType = HostComponent<NativeProps>;
|
|
48
48
|
interface NativeCommands {
|
|
49
49
|
moveCamera: (viewRef: React.ElementRef<ComponentType>, latitude: Double, longitude: Double, zoom: Double, duration: Double) => void;
|
|
50
|
-
fitCoordinates: (viewRef: React.ElementRef<ComponentType>, coordinates: Coordinate[],
|
|
50
|
+
fitCoordinates: (viewRef: React.ElementRef<ComponentType>, coordinates: Coordinate[], paddingTop: Double, paddingLeft: Double, paddingBottom: Double, paddingRight: Double, duration: Double) => void;
|
|
51
51
|
}
|
|
52
52
|
export declare const Commands: NativeCommands;
|
|
53
53
|
declare const _default: ComponentType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LuggGoogleMapViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/fabric/LuggGoogleMapViewNativeComponent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EACV,MAAM,EACN,kBAAkB,EACnB,MAAM,2CAA2C,CAAC;AAEnD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,e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AmB,CAAC,EAAE,OAAO,CAAC;IAC9B,YAAY,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACnD,YAAY,CAAC,EAAE,kBAAkB,CAAC,eAAe,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC;CAC1C;AAED,KAAK,aAAa,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;AAEhD,UAAU,cAAc;IACtB,UAAU,EAAE,CACV,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,EACxC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,KACb,IAAI,CAAC;IACV,cAAc,EAAE,CACd,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,EACxC,WAAW,EAAE,UAAU,EAAE,EACzB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,KACb,IAAI,CAAC;CACX;AAED,eAAO,MAAM,QAAQ,gBAEnB,CAAC;wBAIE,aAAa;AAFlB,wBAEmB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { MapView } from './MapView';
|
|
2
|
+
export { MapProvider } from './MapProvider';
|
|
3
|
+
export type { MapProviderProps } from './MapProvider.types';
|
|
2
4
|
export * from './components';
|
|
3
5
|
export type { MapViewProps, MapViewRef, MoveCameraOptions, FitCoordinatesOptions, CameraEventPayload, } from './MapView.types';
|
|
4
|
-
export type { MapProvider, Coordinate, Point, EdgeInsets } from './types';
|
|
6
|
+
export type { MapProvider as MapProviderType, Coordinate, Point, EdgeInsets, } from './types';
|
|
5
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,YAAY,EACV,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,cAAc,cAAc,CAAC;AAC7B,YAAY,EACV,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,WAAW,IAAI,eAAe,EAC9B,UAAU,EACV,KAAK,EACL,UAAU,GACX,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { MapView } from './MapView.web';
|
|
2
|
+
export { MapProvider } from './MapProvider.web';
|
|
3
|
+
export type { MapProviderProps } from './MapProvider.types';
|
|
4
|
+
export * from './components/index.web';
|
|
5
|
+
export type { MapViewProps, MapViewRef, MoveCameraOptions, FitCoordinatesOptions, CameraEventPayload, } from './MapView.types';
|
|
6
|
+
export type { MapProvider as MapProviderType, Coordinate, Point, EdgeInsets, } from './types';
|
|
7
|
+
//# sourceMappingURL=index.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../src/index.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,cAAc,wBAAwB,CAAC;AACvC,YAAY,EACV,YAAY,EACZ,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,WAAW,IAAI,eAAe,EAC9B,UAAU,EACV,KAAK,EACL,UAAU,GACX,MAAM,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lugg/maps",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.11",
|
|
4
4
|
"description": "Universal maps for React Native.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"source": "./src/index.ts",
|
|
10
|
+
"react-native": "./lib/module/index.js",
|
|
11
|
+
"web": {
|
|
12
|
+
"types": "./lib/typescript/src/index.web.d.ts",
|
|
13
|
+
"default": "./lib/module/index.web.js"
|
|
14
|
+
},
|
|
10
15
|
"types": "./lib/typescript/src/index.d.ts",
|
|
11
16
|
"default": "./lib/module/index.js"
|
|
12
17
|
},
|
|
13
|
-
"./package.json": "./package.json"
|
|
18
|
+
"./package.json": "./package.json",
|
|
19
|
+
"./app.plugin.js": "./app.plugin.js"
|
|
14
20
|
},
|
|
15
21
|
"files": [
|
|
16
22
|
"src",
|
|
@@ -74,6 +80,7 @@
|
|
|
74
80
|
"@release-it/conventional-changelog": "^10.0.1",
|
|
75
81
|
"@types/jest": "^29.5.14",
|
|
76
82
|
"@types/react": "^19.2.0",
|
|
83
|
+
"@vis.gl/react-google-maps": "^1.7.1",
|
|
77
84
|
"commitlint": "^19.8.1",
|
|
78
85
|
"del-cli": "^6.0.0",
|
|
79
86
|
"eslint": "^9.35.0",
|
|
@@ -90,9 +97,15 @@
|
|
|
90
97
|
"typescript": "^5.9.2"
|
|
91
98
|
},
|
|
92
99
|
"peerDependencies": {
|
|
100
|
+
"@vis.gl/react-google-maps": ">=1.0.0",
|
|
93
101
|
"react": "*",
|
|
94
102
|
"react-native": "*"
|
|
95
103
|
},
|
|
104
|
+
"peerDependenciesMeta": {
|
|
105
|
+
"@vis.gl/react-google-maps": {
|
|
106
|
+
"optional": true
|
|
107
|
+
}
|
|
108
|
+
},
|
|
96
109
|
"dependencies": {
|
|
97
110
|
"@expo/config-plugins": "^9.0.0"
|
|
98
111
|
},
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MapProviderProps } from './MapProvider.types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Provider component for map configuration.
|
|
5
|
+
* On web, wraps children with Google Maps APIProvider.
|
|
6
|
+
* On native, passes children through.
|
|
7
|
+
*/
|
|
8
|
+
export function MapProvider({ children }: MapProviderProps) {
|
|
9
|
+
return children;
|
|
10
|
+
}
|
package/src/MapView.tsx
CHANGED
|
@@ -55,7 +55,8 @@ export class MapView
|
|
|
55
55
|
const first = coordinates[0];
|
|
56
56
|
if (!ref || !first) return;
|
|
57
57
|
|
|
58
|
-
const { padding
|
|
58
|
+
const { padding, duration = -1 } = options ?? {};
|
|
59
|
+
const { top = 0, left = 0, bottom = 0, right = 0 } = padding ?? {};
|
|
59
60
|
|
|
60
61
|
if (coordinates.length === 1) {
|
|
61
62
|
const zoom = this.props.initialZoom ?? 10;
|
|
@@ -63,7 +64,15 @@ export class MapView
|
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
this.nativeCommands.fitCoordinates(
|
|
67
|
+
this.nativeCommands.fitCoordinates(
|
|
68
|
+
ref,
|
|
69
|
+
coordinates,
|
|
70
|
+
top,
|
|
71
|
+
left,
|
|
72
|
+
bottom,
|
|
73
|
+
right,
|
|
74
|
+
duration
|
|
75
|
+
);
|
|
67
76
|
}
|
|
68
77
|
|
|
69
78
|
render() {
|
package/src/MapView.types.ts
CHANGED
|
@@ -13,11 +13,10 @@ export interface MoveCameraOptions {
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Options for fitting coordinates in view
|
|
16
|
-
* @default padding 0
|
|
17
16
|
* @default duration -1
|
|
18
17
|
*/
|
|
19
18
|
export interface FitCoordinatesOptions {
|
|
20
|
-
padding?:
|
|
19
|
+
padding?: EdgeInsets;
|
|
21
20
|
duration?: number;
|
|
22
21
|
}
|
|
23
22
|
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
forwardRef,
|
|
4
|
+
isValidElement,
|
|
5
|
+
useEffect,
|
|
6
|
+
useImperativeHandle,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
type CSSProperties,
|
|
10
|
+
type ReactElement,
|
|
11
|
+
type ReactNode,
|
|
12
|
+
} from 'react';
|
|
13
|
+
import type { NativeSyntheticEvent, ViewStyle } from 'react-native';
|
|
14
|
+
import { View } from 'react-native';
|
|
15
|
+
import { Map, useMap } from '@vis.gl/react-google-maps';
|
|
16
|
+
import { Marker } from './components/Marker.web';
|
|
17
|
+
import { Polyline } from './components/Polyline.web';
|
|
18
|
+
|
|
19
|
+
import type {
|
|
20
|
+
MapViewProps,
|
|
21
|
+
MapViewRef,
|
|
22
|
+
MoveCameraOptions,
|
|
23
|
+
FitCoordinatesOptions,
|
|
24
|
+
CameraEventPayload,
|
|
25
|
+
} from './MapView.types';
|
|
26
|
+
import type { Coordinate } from './types';
|
|
27
|
+
|
|
28
|
+
const MAP_COMPONENT_TYPES = new Set([Marker, Polyline]);
|
|
29
|
+
|
|
30
|
+
const isMapComponent = (child: ReactElement): boolean =>
|
|
31
|
+
MAP_COMPONENT_TYPES.has(child.type as typeof Marker | typeof Polyline);
|
|
32
|
+
|
|
33
|
+
const createSyntheticEvent = <T,>(nativeEvent: T): NativeSyntheticEvent<T> =>
|
|
34
|
+
({
|
|
35
|
+
nativeEvent,
|
|
36
|
+
currentTarget: null,
|
|
37
|
+
target: null,
|
|
38
|
+
bubbles: false,
|
|
39
|
+
cancelable: false,
|
|
40
|
+
defaultPrevented: false,
|
|
41
|
+
eventPhase: 0,
|
|
42
|
+
isTrusted: true,
|
|
43
|
+
preventDefault: () => {},
|
|
44
|
+
stopPropagation: () => {},
|
|
45
|
+
isDefaultPrevented: () => false,
|
|
46
|
+
isPropagationStopped: () => false,
|
|
47
|
+
persist: () => {},
|
|
48
|
+
timeStamp: Date.now(),
|
|
49
|
+
type: '',
|
|
50
|
+
} as unknown as NativeSyntheticEvent<T>);
|
|
51
|
+
|
|
52
|
+
const userLocationDotStyle: CSSProperties = {
|
|
53
|
+
width: 16,
|
|
54
|
+
height: 16,
|
|
55
|
+
backgroundColor: '#4285F4',
|
|
56
|
+
border: '2px solid white',
|
|
57
|
+
borderRadius: '50%',
|
|
58
|
+
boxShadow: '0 1px 4px rgba(0,0,0,0.3)',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
function UserLocationMarker({ enabled }: { enabled?: boolean }) {
|
|
62
|
+
const [coordinate, setCoordinate] = useState<Coordinate | null>(null);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (!enabled) {
|
|
66
|
+
setCoordinate(null);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let watchId: number | null = null;
|
|
71
|
+
|
|
72
|
+
const updateLocation = (position: GeolocationPosition) => {
|
|
73
|
+
setCoordinate({
|
|
74
|
+
latitude: position.coords.latitude,
|
|
75
|
+
longitude: position.coords.longitude,
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
navigator.geolocation.getCurrentPosition(updateLocation, () => {});
|
|
80
|
+
watchId = navigator.geolocation.watchPosition(updateLocation, () => {});
|
|
81
|
+
|
|
82
|
+
return () => {
|
|
83
|
+
if (watchId !== null) {
|
|
84
|
+
navigator.geolocation.clearWatch(watchId);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}, [enabled]);
|
|
88
|
+
|
|
89
|
+
if (!coordinate) return null;
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<Marker coordinate={coordinate} anchor={{ x: 0.5, y: 0.5 }}>
|
|
93
|
+
<div style={userLocationDotStyle} />
|
|
94
|
+
</Marker>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const MapView = forwardRef<MapViewRef, MapViewProps>(function MapView(
|
|
99
|
+
props,
|
|
100
|
+
ref
|
|
101
|
+
) {
|
|
102
|
+
const {
|
|
103
|
+
mapId = 'DEMO_MAP_ID',
|
|
104
|
+
initialCoordinate,
|
|
105
|
+
initialZoom = 10,
|
|
106
|
+
minZoom,
|
|
107
|
+
maxZoom,
|
|
108
|
+
zoomEnabled = true,
|
|
109
|
+
scrollEnabled = true,
|
|
110
|
+
pitchEnabled = true,
|
|
111
|
+
padding,
|
|
112
|
+
userLocationEnabled,
|
|
113
|
+
onCameraMove,
|
|
114
|
+
onCameraIdle,
|
|
115
|
+
onReady,
|
|
116
|
+
children,
|
|
117
|
+
style,
|
|
118
|
+
} = props;
|
|
119
|
+
|
|
120
|
+
const map = useMap();
|
|
121
|
+
const readyFired = useRef(false);
|
|
122
|
+
|
|
123
|
+
useImperativeHandle(
|
|
124
|
+
ref,
|
|
125
|
+
() => ({
|
|
126
|
+
moveCamera(coordinate: Coordinate, options: MoveCameraOptions) {
|
|
127
|
+
if (!map) return;
|
|
128
|
+
|
|
129
|
+
const { zoom, duration = -1 } = options;
|
|
130
|
+
const center = { lat: coordinate.latitude, lng: coordinate.longitude };
|
|
131
|
+
|
|
132
|
+
if (duration === 0) {
|
|
133
|
+
map.moveCamera({ center, zoom });
|
|
134
|
+
} else {
|
|
135
|
+
const currentZoom = map.getZoom();
|
|
136
|
+
const zoomChanged = zoom !== undefined && zoom !== currentZoom;
|
|
137
|
+
|
|
138
|
+
if (zoomChanged) {
|
|
139
|
+
map.setZoom(zoom);
|
|
140
|
+
}
|
|
141
|
+
map.panTo(center);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
fitCoordinates(
|
|
146
|
+
coordinates: Coordinate[],
|
|
147
|
+
options?: FitCoordinatesOptions
|
|
148
|
+
) {
|
|
149
|
+
const first = coordinates[0];
|
|
150
|
+
if (!map || !first) return;
|
|
151
|
+
|
|
152
|
+
const { padding: fitPadding, duration = -1 } = options ?? {};
|
|
153
|
+
|
|
154
|
+
if (coordinates.length === 1) {
|
|
155
|
+
this.moveCamera(first, { zoom: initialZoom, duration });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const bounds = new google.maps.LatLngBounds();
|
|
160
|
+
coordinates.forEach((coord) => {
|
|
161
|
+
bounds.extend({ lat: coord.latitude, lng: coord.longitude });
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
map.fitBounds(bounds, {
|
|
165
|
+
top: fitPadding?.top ?? 0,
|
|
166
|
+
left: fitPadding?.left ?? 0,
|
|
167
|
+
bottom: fitPadding?.bottom ?? 0,
|
|
168
|
+
right: fitPadding?.right ?? 0,
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
}),
|
|
172
|
+
[map, initialZoom]
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
if (map && !readyFired.current) {
|
|
177
|
+
readyFired.current = true;
|
|
178
|
+
onReady?.();
|
|
179
|
+
}
|
|
180
|
+
}, [map, onReady]);
|
|
181
|
+
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if (!map) return;
|
|
184
|
+
|
|
185
|
+
const createPayload = (gesture: boolean): CameraEventPayload => {
|
|
186
|
+
const center = map.getCenter();
|
|
187
|
+
return {
|
|
188
|
+
coordinate: {
|
|
189
|
+
latitude: center?.lat() ?? 0,
|
|
190
|
+
longitude: center?.lng() ?? 0,
|
|
191
|
+
},
|
|
192
|
+
zoom: map.getZoom() ?? 0,
|
|
193
|
+
gesture,
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
let isDragging = false;
|
|
198
|
+
let wasGesture = false;
|
|
199
|
+
|
|
200
|
+
const dragStartListener = map.addListener('dragstart', () => {
|
|
201
|
+
isDragging = true;
|
|
202
|
+
wasGesture = true;
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const dragEndListener = map.addListener('dragend', () => {
|
|
206
|
+
isDragging = false;
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const centerListener = map.addListener('center_changed', () => {
|
|
210
|
+
onCameraMove?.(createSyntheticEvent(createPayload(isDragging)));
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const idleListener = map.addListener('idle', () => {
|
|
214
|
+
onCameraIdle?.(createSyntheticEvent(createPayload(wasGesture)));
|
|
215
|
+
wasGesture = false;
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
return () => {
|
|
219
|
+
google.maps.event.removeListener(dragStartListener);
|
|
220
|
+
google.maps.event.removeListener(dragEndListener);
|
|
221
|
+
google.maps.event.removeListener(centerListener);
|
|
222
|
+
google.maps.event.removeListener(idleListener);
|
|
223
|
+
};
|
|
224
|
+
}, [map, onCameraMove, onCameraIdle]);
|
|
225
|
+
|
|
226
|
+
const gestureHandling =
|
|
227
|
+
scrollEnabled === false && zoomEnabled === false
|
|
228
|
+
? 'none'
|
|
229
|
+
: scrollEnabled === false
|
|
230
|
+
? 'none'
|
|
231
|
+
: 'auto';
|
|
232
|
+
|
|
233
|
+
const defaultCenter = initialCoordinate
|
|
234
|
+
? { lat: initialCoordinate.latitude, lng: initialCoordinate.longitude }
|
|
235
|
+
: undefined;
|
|
236
|
+
|
|
237
|
+
const mapChildren: ReactNode[] = [];
|
|
238
|
+
const overlayChildren: ReactNode[] = [];
|
|
239
|
+
|
|
240
|
+
Children.forEach(children, (child) => {
|
|
241
|
+
if (!isValidElement(child)) return;
|
|
242
|
+
if (isMapComponent(child)) {
|
|
243
|
+
mapChildren.push(child);
|
|
244
|
+
} else {
|
|
245
|
+
overlayChildren.push(child);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
const mapContainerStyle: ViewStyle = {
|
|
250
|
+
position: 'absolute',
|
|
251
|
+
top: padding?.top ?? 0,
|
|
252
|
+
left: padding?.left ?? 0,
|
|
253
|
+
right: padding?.right ?? 0,
|
|
254
|
+
bottom: padding?.bottom ?? 0,
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const mapStyle: CSSProperties = {
|
|
258
|
+
width: '100%',
|
|
259
|
+
height: '100%',
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
return (
|
|
263
|
+
<View style={style}>
|
|
264
|
+
<View style={mapContainerStyle}>
|
|
265
|
+
<Map
|
|
266
|
+
mapId={mapId}
|
|
267
|
+
defaultCenter={defaultCenter}
|
|
268
|
+
defaultZoom={initialZoom}
|
|
269
|
+
minZoom={minZoom}
|
|
270
|
+
maxZoom={maxZoom}
|
|
271
|
+
gestureHandling={gestureHandling}
|
|
272
|
+
disableDefaultUI
|
|
273
|
+
tilt={pitchEnabled === false ? 0 : undefined}
|
|
274
|
+
style={mapStyle}
|
|
275
|
+
>
|
|
276
|
+
<UserLocationMarker enabled={userLocationEnabled} />
|
|
277
|
+
{mapChildren}
|
|
278
|
+
</Map>
|
|
279
|
+
</View>
|
|
280
|
+
{overlayChildren}
|
|
281
|
+
</View>
|
|
282
|
+
);
|
|
283
|
+
});
|
|
@@ -25,6 +25,10 @@ export interface MarkerProps {
|
|
|
25
25
|
* Anchor point for custom marker views
|
|
26
26
|
*/
|
|
27
27
|
anchor?: Point;
|
|
28
|
+
/**
|
|
29
|
+
* Z-index for marker ordering. Higher values render on top.
|
|
30
|
+
*/
|
|
31
|
+
zIndex?: number;
|
|
28
32
|
/**
|
|
29
33
|
* Custom marker view
|
|
30
34
|
*/
|
|
@@ -33,12 +37,12 @@ export interface MarkerProps {
|
|
|
33
37
|
|
|
34
38
|
export class Marker extends React.Component<MarkerProps> {
|
|
35
39
|
render() {
|
|
36
|
-
const { name, coordinate, title, description, anchor, children } =
|
|
40
|
+
const { name, coordinate, title, description, anchor, zIndex, children } =
|
|
37
41
|
this.props;
|
|
38
42
|
|
|
39
43
|
return (
|
|
40
44
|
<LuggMarkerViewNativeComponent
|
|
41
|
-
style={styles.marker}
|
|
45
|
+
style={[{ zIndex }, styles.marker]}
|
|
42
46
|
name={name}
|
|
43
47
|
coordinate={coordinate}
|
|
44
48
|
title={title}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AdvancedMarker } from '@vis.gl/react-google-maps';
|
|
2
|
+
import type { MarkerProps } from './Marker';
|
|
3
|
+
|
|
4
|
+
const toWebAnchor = (value: number) => `-${value * 100}%`;
|
|
5
|
+
|
|
6
|
+
export function Marker({
|
|
7
|
+
coordinate,
|
|
8
|
+
title,
|
|
9
|
+
anchor,
|
|
10
|
+
zIndex,
|
|
11
|
+
children,
|
|
12
|
+
}: MarkerProps) {
|
|
13
|
+
return (
|
|
14
|
+
<AdvancedMarker
|
|
15
|
+
position={{ lat: coordinate.latitude, lng: coordinate.longitude }}
|
|
16
|
+
title={title}
|
|
17
|
+
zIndex={zIndex}
|
|
18
|
+
anchorLeft={anchor ? toWebAnchor(anchor.x) : undefined}
|
|
19
|
+
anchorTop={anchor ? toWebAnchor(anchor.y) : undefined}
|
|
20
|
+
>
|
|
21
|
+
{children}
|
|
22
|
+
</AdvancedMarker>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -21,6 +21,10 @@ export interface PolylineProps {
|
|
|
21
21
|
* Animate the polyline with a snake effect
|
|
22
22
|
*/
|
|
23
23
|
animated?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Z-index for layering polylines
|
|
26
|
+
*/
|
|
27
|
+
zIndex?: number;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
export class Polyline extends React.Component<PolylineProps> {
|
|
@@ -30,11 +34,12 @@ export class Polyline extends React.Component<PolylineProps> {
|
|
|
30
34
|
strokeColors,
|
|
31
35
|
strokeWidth,
|
|
32
36
|
animated = false,
|
|
37
|
+
zIndex,
|
|
33
38
|
} = this.props;
|
|
34
39
|
|
|
35
40
|
return (
|
|
36
41
|
<LuggPolylineViewNativeComponent
|
|
37
|
-
style={styles.polyline}
|
|
42
|
+
style={[{ zIndex }, styles.polyline]}
|
|
38
43
|
coordinates={coordinates}
|
|
39
44
|
strokeColors={strokeColors}
|
|
40
45
|
strokeWidth={strokeWidth}
|