@lugg/maps 0.2.0-alpha.0
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/LuggMaps.podspec +23 -0
- package/README.md +119 -0
- package/android/build.gradle +78 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/luggmaps/LuggMapsGoogleMapView.kt +438 -0
- package/android/src/main/java/com/luggmaps/LuggMapsGoogleMapViewManager.kt +144 -0
- package/android/src/main/java/com/luggmaps/LuggMapsMarkerView.kt +134 -0
- package/android/src/main/java/com/luggmaps/LuggMapsMarkerViewManager.kt +69 -0
- package/android/src/main/java/com/luggmaps/LuggMapsPackage.kt +13 -0
- package/android/src/main/java/com/luggmaps/LuggMapsPolylineView.kt +79 -0
- package/android/src/main/java/com/luggmaps/LuggMapsPolylineViewManager.kt +71 -0
- package/android/src/main/java/com/luggmaps/LuggMapsWrapperView.kt +39 -0
- package/android/src/main/java/com/luggmaps/LuggMapsWrapperViewManager.kt +25 -0
- package/android/src/main/java/com/luggmaps/core/PolylineAnimator.kt +180 -0
- package/android/src/main/java/com/luggmaps/events/CameraIdleEvent.kt +21 -0
- package/android/src/main/java/com/luggmaps/events/CameraMoveEvent.kt +28 -0
- package/app.plugin.js +1 -0
- package/ios/LuggMapsAppleMapView.h +16 -0
- package/ios/LuggMapsAppleMapView.mm +544 -0
- package/ios/LuggMapsGoogleMapView.h +13 -0
- package/ios/LuggMapsGoogleMapView.mm +439 -0
- package/ios/LuggMapsMarkerView.h +29 -0
- package/ios/LuggMapsMarkerView.mm +154 -0
- package/ios/LuggMapsPolylineView.h +27 -0
- package/ios/LuggMapsPolylineView.mm +116 -0
- package/ios/LuggMapsWrapperView.h +9 -0
- package/ios/LuggMapsWrapperView.mm +36 -0
- package/ios/core/GMSPolylineAnimator.h +11 -0
- package/ios/core/GMSPolylineAnimator.m +151 -0
- package/ios/core/MKPolylineAnimator.h +12 -0
- package/ios/core/MKPolylineAnimator.m +252 -0
- package/ios/core/PolylineAnimatorBase.h +22 -0
- package/ios/core/PolylineAnimatorBase.m +35 -0
- package/ios/events/CameraIdleEvent.h +24 -0
- package/ios/events/CameraMoveEvent.h +26 -0
- package/ios/extensions/MKMapView+Zoom.h +19 -0
- package/ios/extensions/MKMapView+Zoom.m +45 -0
- package/lib/module/MapView.js +87 -0
- package/lib/module/MapView.js.map +1 -0
- package/lib/module/MapView.types.js +4 -0
- package/lib/module/MapView.types.js.map +1 -0
- package/lib/module/Marker.js +34 -0
- package/lib/module/Marker.js.map +1 -0
- package/lib/module/Marker.types.js +4 -0
- package/lib/module/Marker.types.js.map +1 -0
- package/lib/module/Polyline.js +30 -0
- package/lib/module/Polyline.js.map +1 -0
- package/lib/module/Polyline.types.js +4 -0
- package/lib/module/Polyline.types.js.map +1 -0
- package/lib/module/fabric/LuggMapsAppleMapViewNativeComponent.ts +73 -0
- package/lib/module/fabric/LuggMapsGoogleMapViewNativeComponent.ts +74 -0
- package/lib/module/fabric/LuggMapsMarkerViewNativeComponent.ts +25 -0
- package/lib/module/fabric/LuggMapsPolylineViewNativeComponent.ts +19 -0
- package/lib/module/fabric/LuggMapsWrapperViewNativeComponent.ts +8 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/plugin/src/index.d.ts +16 -0
- package/lib/typescript/plugin/src/index.d.ts.map +1 -0
- package/lib/typescript/plugin/src/withMapsAndroid.d.ts +6 -0
- package/lib/typescript/plugin/src/withMapsAndroid.d.ts.map +1 -0
- package/lib/typescript/plugin/src/withMapsIOS.d.ts +6 -0
- package/lib/typescript/plugin/src/withMapsIOS.d.ts.map +1 -0
- package/lib/typescript/src/MapView.d.ts +12 -0
- package/lib/typescript/src/MapView.d.ts.map +1 -0
- package/lib/typescript/src/MapView.types.d.ts +102 -0
- package/lib/typescript/src/MapView.types.d.ts.map +1 -0
- package/lib/typescript/src/Marker.d.ts +6 -0
- package/lib/typescript/src/Marker.d.ts.map +1 -0
- package/lib/typescript/src/Marker.types.d.ts +32 -0
- package/lib/typescript/src/Marker.types.d.ts.map +1 -0
- package/lib/typescript/src/Polyline.d.ts +6 -0
- package/lib/typescript/src/Polyline.d.ts.map +1 -0
- package/lib/typescript/src/Polyline.types.d.ts +24 -0
- package/lib/typescript/src/Polyline.types.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggMapsAppleMapViewNativeComponent.d.ts +47 -0
- package/lib/typescript/src/fabric/LuggMapsAppleMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggMapsGoogleMapViewNativeComponent.d.ts +48 -0
- package/lib/typescript/src/fabric/LuggMapsGoogleMapViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggMapsMarkerViewNativeComponent.d.ts +20 -0
- package/lib/typescript/src/fabric/LuggMapsMarkerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggMapsPolylineViewNativeComponent.d.ts +15 -0
- package/lib/typescript/src/fabric/LuggMapsPolylineViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/fabric/LuggMapsWrapperViewNativeComponent.d.ts +6 -0
- package/lib/typescript/src/fabric/LuggMapsWrapperViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +8 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +28 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +200 -0
- package/plugin/build/index.d.ts +15 -0
- package/plugin/build/index.js +13 -0
- package/plugin/build/withMapsAndroid.d.ts +5 -0
- package/plugin/build/withMapsAndroid.js +15 -0
- package/plugin/build/withMapsIOS.d.ts +5 -0
- package/plugin/build/withMapsIOS.js +27 -0
- package/src/MapView.tsx +111 -0
- package/src/MapView.types.ts +110 -0
- package/src/Marker.tsx +31 -0
- package/src/Marker.types.ts +32 -0
- package/src/Polyline.tsx +32 -0
- package/src/Polyline.types.ts +24 -0
- package/src/fabric/LuggMapsAppleMapViewNativeComponent.ts +73 -0
- package/src/fabric/LuggMapsGoogleMapViewNativeComponent.ts +74 -0
- package/src/fabric/LuggMapsMarkerViewNativeComponent.ts +25 -0
- package/src/fabric/LuggMapsPolylineViewNativeComponent.ts +19 -0
- package/src/fabric/LuggMapsWrapperViewNativeComponent.ts +8 -0
- package/src/index.ts +13 -0
- package/src/types.ts +30 -0
package/src/MapView.tsx
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Platform, StyleSheet } from 'react-native';
|
|
3
|
+
import LuggMapsGoogleMapViewNativeComponent, {
|
|
4
|
+
Commands as GoogleMapCommands,
|
|
5
|
+
} from './fabric/LuggMapsGoogleMapViewNativeComponent';
|
|
6
|
+
import LuggMapsAppleMapViewNativeComponent, {
|
|
7
|
+
Commands as AppleMapCommands,
|
|
8
|
+
} from './fabric/LuggMapsAppleMapViewNativeComponent';
|
|
9
|
+
import LuggMapsWrapperViewNativeComponent from './fabric/LuggMapsWrapperViewNativeComponent';
|
|
10
|
+
import type {
|
|
11
|
+
MapViewProps,
|
|
12
|
+
MapViewRef,
|
|
13
|
+
MoveCameraOptions,
|
|
14
|
+
FitCoordinatesOptions,
|
|
15
|
+
} from './MapView.types';
|
|
16
|
+
import type { Coordinate } from './types';
|
|
17
|
+
|
|
18
|
+
export class MapView
|
|
19
|
+
extends React.Component<MapViewProps>
|
|
20
|
+
implements MapViewRef
|
|
21
|
+
{
|
|
22
|
+
static defaultProps: Partial<MapViewProps> = {
|
|
23
|
+
provider: Platform.OS === 'ios' ? 'apple' : 'google',
|
|
24
|
+
initialZoom: 10,
|
|
25
|
+
zoomEnabled: true,
|
|
26
|
+
scrollEnabled: true,
|
|
27
|
+
rotateEnabled: true,
|
|
28
|
+
pitchEnabled: true,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
private nativeRef = React.createRef<any>();
|
|
32
|
+
|
|
33
|
+
private get nativeCommands() {
|
|
34
|
+
const provider = this.props.provider ?? MapView.defaultProps.provider;
|
|
35
|
+
const isApple = Platform.OS === 'ios' && provider === 'apple';
|
|
36
|
+
return isApple ? AppleMapCommands : GoogleMapCommands;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
moveCamera(coordinate: Coordinate, options: MoveCameraOptions) {
|
|
40
|
+
const ref = this.nativeRef.current;
|
|
41
|
+
if (!ref) return;
|
|
42
|
+
|
|
43
|
+
const { zoom, duration = -1 } = options;
|
|
44
|
+
this.nativeCommands.moveCamera(
|
|
45
|
+
ref,
|
|
46
|
+
coordinate.latitude,
|
|
47
|
+
coordinate.longitude,
|
|
48
|
+
zoom,
|
|
49
|
+
duration
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fitCoordinates(coordinates: Coordinate[], options?: FitCoordinatesOptions) {
|
|
54
|
+
const ref = this.nativeRef.current;
|
|
55
|
+
const first = coordinates[0];
|
|
56
|
+
if (!ref || !first) return;
|
|
57
|
+
|
|
58
|
+
const { padding = 0, duration = -1 } = options ?? {};
|
|
59
|
+
|
|
60
|
+
if (coordinates.length === 1) {
|
|
61
|
+
const zoom = this.props.initialZoom ?? 10;
|
|
62
|
+
this.moveCamera(first, { zoom, duration });
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
this.nativeCommands.fitCoordinates(ref, coordinates, padding, duration);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
render() {
|
|
70
|
+
const {
|
|
71
|
+
provider,
|
|
72
|
+
mapId,
|
|
73
|
+
initialCoordinate,
|
|
74
|
+
initialZoom,
|
|
75
|
+
zoomEnabled,
|
|
76
|
+
scrollEnabled,
|
|
77
|
+
rotateEnabled,
|
|
78
|
+
pitchEnabled,
|
|
79
|
+
padding,
|
|
80
|
+
onCameraMove,
|
|
81
|
+
onCameraIdle,
|
|
82
|
+
children,
|
|
83
|
+
...rest
|
|
84
|
+
} = this.props;
|
|
85
|
+
|
|
86
|
+
const NativeMapView =
|
|
87
|
+
Platform.OS === 'ios' && provider === 'apple'
|
|
88
|
+
? LuggMapsAppleMapViewNativeComponent
|
|
89
|
+
: LuggMapsGoogleMapViewNativeComponent;
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<NativeMapView
|
|
93
|
+
ref={this.nativeRef}
|
|
94
|
+
{...rest}
|
|
95
|
+
mapId={mapId}
|
|
96
|
+
initialCoordinate={initialCoordinate}
|
|
97
|
+
initialZoom={initialZoom}
|
|
98
|
+
zoomEnabled={zoomEnabled}
|
|
99
|
+
scrollEnabled={scrollEnabled}
|
|
100
|
+
rotateEnabled={rotateEnabled}
|
|
101
|
+
pitchEnabled={pitchEnabled}
|
|
102
|
+
padding={padding}
|
|
103
|
+
onCameraMove={onCameraMove}
|
|
104
|
+
onCameraIdle={onCameraIdle}
|
|
105
|
+
>
|
|
106
|
+
<LuggMapsWrapperViewNativeComponent style={StyleSheet.absoluteFill} />
|
|
107
|
+
{children}
|
|
108
|
+
</NativeMapView>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { NativeSyntheticEvent, ViewProps } from 'react-native';
|
|
3
|
+
import type { MapProvider, Coordinate, EdgeInsets } from './types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Options for moving the camera
|
|
7
|
+
* @default duration -1
|
|
8
|
+
*/
|
|
9
|
+
export interface MoveCameraOptions {
|
|
10
|
+
zoom: number;
|
|
11
|
+
duration?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Options for fitting coordinates in view
|
|
16
|
+
* @default padding 0
|
|
17
|
+
* @default duration -1
|
|
18
|
+
*/
|
|
19
|
+
export interface FitCoordinatesOptions {
|
|
20
|
+
padding?: number;
|
|
21
|
+
duration?: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* MapView ref methods
|
|
26
|
+
*/
|
|
27
|
+
export interface MapViewRef {
|
|
28
|
+
moveCamera(coordinate: Coordinate, options: MoveCameraOptions): void;
|
|
29
|
+
fitCoordinates(
|
|
30
|
+
coordinates: Coordinate[],
|
|
31
|
+
options?: FitCoordinatesOptions
|
|
32
|
+
): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Camera move event data
|
|
37
|
+
*/
|
|
38
|
+
export interface CameraMoveEvent {
|
|
39
|
+
coordinate: Coordinate;
|
|
40
|
+
zoom: number;
|
|
41
|
+
dragging: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Camera idle event data
|
|
46
|
+
*/
|
|
47
|
+
export interface CameraIdleEvent {
|
|
48
|
+
coordinate: Coordinate;
|
|
49
|
+
zoom: number;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* MapView component props
|
|
54
|
+
*/
|
|
55
|
+
export interface MapViewProps extends ViewProps {
|
|
56
|
+
/**
|
|
57
|
+
* Map provider to use
|
|
58
|
+
* @default 'apple' on iOS, 'google' on Android
|
|
59
|
+
*/
|
|
60
|
+
provider?: MapProvider;
|
|
61
|
+
/**
|
|
62
|
+
* Map style ID (Google Maps) or configuration name (Apple Maps)
|
|
63
|
+
*/
|
|
64
|
+
mapId?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Initial camera coordinate
|
|
67
|
+
*/
|
|
68
|
+
initialCoordinate?: Coordinate;
|
|
69
|
+
/**
|
|
70
|
+
* Initial zoom level
|
|
71
|
+
* @default 10
|
|
72
|
+
*/
|
|
73
|
+
initialZoom?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Enable zoom gestures
|
|
76
|
+
* @default true
|
|
77
|
+
*/
|
|
78
|
+
zoomEnabled?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Enable scroll/pan gestures
|
|
81
|
+
* @default true
|
|
82
|
+
*/
|
|
83
|
+
scrollEnabled?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Enable rotation gestures
|
|
86
|
+
* @default true
|
|
87
|
+
*/
|
|
88
|
+
rotateEnabled?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Enable pitch/tilt gestures
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
93
|
+
pitchEnabled?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Map content padding
|
|
96
|
+
*/
|
|
97
|
+
padding?: EdgeInsets;
|
|
98
|
+
/**
|
|
99
|
+
* Called when camera moves
|
|
100
|
+
*/
|
|
101
|
+
onCameraMove?: (event: NativeSyntheticEvent<CameraMoveEvent>) => void;
|
|
102
|
+
/**
|
|
103
|
+
* Called when camera stops moving
|
|
104
|
+
*/
|
|
105
|
+
onCameraIdle?: (event: NativeSyntheticEvent<CameraIdleEvent>) => void;
|
|
106
|
+
/**
|
|
107
|
+
* Map children (markers, polylines, etc.)
|
|
108
|
+
*/
|
|
109
|
+
children?: ReactNode;
|
|
110
|
+
}
|
package/src/Marker.tsx
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import LuggMapsMarkerViewNativeComponent from './fabric/LuggMapsMarkerViewNativeComponent';
|
|
3
|
+
import type { MarkerProps } from './Marker.types';
|
|
4
|
+
import { StyleSheet } from 'react-native';
|
|
5
|
+
|
|
6
|
+
export class Marker extends React.Component<MarkerProps> {
|
|
7
|
+
render() {
|
|
8
|
+
const { name, coordinate, title, description, anchor, children } =
|
|
9
|
+
this.props;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<LuggMapsMarkerViewNativeComponent
|
|
13
|
+
style={styles.marker}
|
|
14
|
+
name={name}
|
|
15
|
+
coordinate={coordinate}
|
|
16
|
+
title={title}
|
|
17
|
+
description={description}
|
|
18
|
+
anchor={anchor}
|
|
19
|
+
>
|
|
20
|
+
{children}
|
|
21
|
+
</LuggMapsMarkerViewNativeComponent>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const styles = StyleSheet.create({
|
|
27
|
+
marker: {
|
|
28
|
+
position: 'absolute',
|
|
29
|
+
pointerEvents: 'box-none',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Coordinate, Point } from './types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Marker component props
|
|
6
|
+
*/
|
|
7
|
+
export interface MarkerProps {
|
|
8
|
+
/**
|
|
9
|
+
* Name used for debugging purposes
|
|
10
|
+
*/
|
|
11
|
+
name?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Marker position
|
|
14
|
+
*/
|
|
15
|
+
coordinate: Coordinate;
|
|
16
|
+
/**
|
|
17
|
+
* Callout title
|
|
18
|
+
*/
|
|
19
|
+
title?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Callout description
|
|
22
|
+
*/
|
|
23
|
+
description?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Anchor point for custom marker views
|
|
26
|
+
*/
|
|
27
|
+
anchor?: Point;
|
|
28
|
+
/**
|
|
29
|
+
* Custom marker view
|
|
30
|
+
*/
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
}
|
package/src/Polyline.tsx
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import LuggMapsPolylineViewNativeComponent from './fabric/LuggMapsPolylineViewNativeComponent';
|
|
3
|
+
import type { PolylineProps } from './Polyline.types';
|
|
4
|
+
import { StyleSheet } from 'react-native';
|
|
5
|
+
|
|
6
|
+
export class Polyline extends React.Component<PolylineProps> {
|
|
7
|
+
render() {
|
|
8
|
+
const {
|
|
9
|
+
coordinates,
|
|
10
|
+
strokeColors,
|
|
11
|
+
strokeWidth,
|
|
12
|
+
animated = false,
|
|
13
|
+
} = this.props;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<LuggMapsPolylineViewNativeComponent
|
|
17
|
+
style={styles.polyline}
|
|
18
|
+
coordinates={coordinates}
|
|
19
|
+
strokeColors={strokeColors}
|
|
20
|
+
strokeWidth={strokeWidth}
|
|
21
|
+
animated={animated}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const styles = StyleSheet.create({
|
|
28
|
+
polyline: {
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
pointerEvents: 'none',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ColorValue } from 'react-native';
|
|
2
|
+
import type { Coordinate } from './types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Polyline component props
|
|
6
|
+
*/
|
|
7
|
+
export interface PolylineProps {
|
|
8
|
+
/**
|
|
9
|
+
* Array of coordinates forming the polyline
|
|
10
|
+
*/
|
|
11
|
+
coordinates: Coordinate[];
|
|
12
|
+
/**
|
|
13
|
+
* Gradient colors along the polyline
|
|
14
|
+
*/
|
|
15
|
+
strokeColors?: ColorValue[];
|
|
16
|
+
/**
|
|
17
|
+
* Line width in points
|
|
18
|
+
*/
|
|
19
|
+
strokeWidth?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Animate the polyline with a snake effect
|
|
22
|
+
*/
|
|
23
|
+
animated?: boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { codegenNativeComponent, codegenNativeCommands } from 'react-native';
|
|
2
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
|
3
|
+
import type {
|
|
4
|
+
Double,
|
|
5
|
+
DirectEventHandler,
|
|
6
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
7
|
+
|
|
8
|
+
export interface Coordinate {
|
|
9
|
+
latitude: Double;
|
|
10
|
+
longitude: Double;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface EdgeInsets {
|
|
14
|
+
top: Double;
|
|
15
|
+
left: Double;
|
|
16
|
+
bottom: Double;
|
|
17
|
+
right: Double;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CameraMoveEvent {
|
|
21
|
+
coordinate: {
|
|
22
|
+
latitude: Double;
|
|
23
|
+
longitude: Double;
|
|
24
|
+
};
|
|
25
|
+
zoom: Double;
|
|
26
|
+
dragging: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface CameraIdleEvent {
|
|
30
|
+
coordinate: {
|
|
31
|
+
latitude: Double;
|
|
32
|
+
longitude: Double;
|
|
33
|
+
};
|
|
34
|
+
zoom: Double;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface NativeProps extends ViewProps {
|
|
38
|
+
initialCoordinate?: Coordinate;
|
|
39
|
+
initialZoom?: Double;
|
|
40
|
+
zoomEnabled?: boolean;
|
|
41
|
+
scrollEnabled?: boolean;
|
|
42
|
+
rotateEnabled?: boolean;
|
|
43
|
+
pitchEnabled?: boolean;
|
|
44
|
+
padding?: EdgeInsets;
|
|
45
|
+
onCameraMove?: DirectEventHandler<CameraMoveEvent>;
|
|
46
|
+
onCameraIdle?: DirectEventHandler<CameraIdleEvent>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
50
|
+
|
|
51
|
+
interface NativeCommands {
|
|
52
|
+
moveCamera: (
|
|
53
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
54
|
+
latitude: Double,
|
|
55
|
+
longitude: Double,
|
|
56
|
+
zoom: Double,
|
|
57
|
+
duration: Double
|
|
58
|
+
) => void;
|
|
59
|
+
fitCoordinates: (
|
|
60
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
61
|
+
coordinates: Coordinate[],
|
|
62
|
+
padding: Double,
|
|
63
|
+
duration: Double
|
|
64
|
+
) => void;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const Commands = codegenNativeCommands<NativeCommands>({
|
|
68
|
+
supportedCommands: ['moveCamera', 'fitCoordinates'],
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export default codegenNativeComponent<NativeProps>(
|
|
72
|
+
'LuggMapsAppleMapView'
|
|
73
|
+
) as ComponentType;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { codegenNativeComponent, codegenNativeCommands } from 'react-native';
|
|
2
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
|
3
|
+
import type {
|
|
4
|
+
Double,
|
|
5
|
+
DirectEventHandler,
|
|
6
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
7
|
+
|
|
8
|
+
export interface Coordinate {
|
|
9
|
+
latitude: Double;
|
|
10
|
+
longitude: Double;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface EdgeInsets {
|
|
14
|
+
top: Double;
|
|
15
|
+
left: Double;
|
|
16
|
+
bottom: Double;
|
|
17
|
+
right: Double;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CameraMoveEvent {
|
|
21
|
+
coordinate: {
|
|
22
|
+
latitude: Double;
|
|
23
|
+
longitude: Double;
|
|
24
|
+
};
|
|
25
|
+
zoom: Double;
|
|
26
|
+
dragging: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface CameraIdleEvent {
|
|
30
|
+
coordinate: {
|
|
31
|
+
latitude: Double;
|
|
32
|
+
longitude: Double;
|
|
33
|
+
};
|
|
34
|
+
zoom: Double;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface NativeProps extends ViewProps {
|
|
38
|
+
mapId?: string;
|
|
39
|
+
initialCoordinate?: Coordinate;
|
|
40
|
+
initialZoom?: Double;
|
|
41
|
+
zoomEnabled?: boolean;
|
|
42
|
+
scrollEnabled?: boolean;
|
|
43
|
+
rotateEnabled?: boolean;
|
|
44
|
+
pitchEnabled?: boolean;
|
|
45
|
+
padding?: EdgeInsets;
|
|
46
|
+
onCameraMove?: DirectEventHandler<CameraMoveEvent>;
|
|
47
|
+
onCameraIdle?: DirectEventHandler<CameraIdleEvent>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
51
|
+
|
|
52
|
+
interface NativeCommands {
|
|
53
|
+
moveCamera: (
|
|
54
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
55
|
+
latitude: Double,
|
|
56
|
+
longitude: Double,
|
|
57
|
+
zoom: Double,
|
|
58
|
+
duration: Double
|
|
59
|
+
) => void;
|
|
60
|
+
fitCoordinates: (
|
|
61
|
+
viewRef: React.ElementRef<ComponentType>,
|
|
62
|
+
coordinates: Coordinate[],
|
|
63
|
+
padding: Double,
|
|
64
|
+
duration: Double
|
|
65
|
+
) => void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const Commands = codegenNativeCommands<NativeCommands>({
|
|
69
|
+
supportedCommands: ['moveCamera', 'fitCoordinates'],
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export default codegenNativeComponent<NativeProps>(
|
|
73
|
+
'LuggMapsGoogleMapView'
|
|
74
|
+
) as ComponentType;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { codegenNativeComponent } from 'react-native';
|
|
2
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
|
3
|
+
import type { Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
|
|
5
|
+
export interface Coordinate {
|
|
6
|
+
latitude: Double;
|
|
7
|
+
longitude: Double;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Point {
|
|
11
|
+
x: Double;
|
|
12
|
+
y: Double;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface NativeProps extends ViewProps {
|
|
16
|
+
name?: string;
|
|
17
|
+
coordinate: Coordinate;
|
|
18
|
+
title?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
anchor?: Point;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default codegenNativeComponent<NativeProps>(
|
|
24
|
+
'LuggMapsMarkerView'
|
|
25
|
+
) as HostComponent<NativeProps>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { codegenNativeComponent } from 'react-native';
|
|
2
|
+
import type { ViewProps, HostComponent, ColorValue } from 'react-native';
|
|
3
|
+
import type { Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
|
|
5
|
+
export interface Coordinate {
|
|
6
|
+
latitude: Double;
|
|
7
|
+
longitude: Double;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface NativeProps extends ViewProps {
|
|
11
|
+
coordinates: ReadonlyArray<Coordinate>;
|
|
12
|
+
strokeColors?: ReadonlyArray<ColorValue>;
|
|
13
|
+
strokeWidth?: Double;
|
|
14
|
+
animated?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default codegenNativeComponent<NativeProps>(
|
|
18
|
+
'LuggMapsPolylineView'
|
|
19
|
+
) as HostComponent<NativeProps>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { codegenNativeComponent } from 'react-native';
|
|
2
|
+
import type { ViewProps, HostComponent } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export interface NativeProps extends ViewProps {}
|
|
5
|
+
|
|
6
|
+
export default codegenNativeComponent<NativeProps>(
|
|
7
|
+
'LuggMapsWrapperView'
|
|
8
|
+
) as HostComponent<NativeProps>;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { MapView } from './MapView';
|
|
2
|
+
export { Marker } from './Marker';
|
|
3
|
+
export { Polyline } from './Polyline';
|
|
4
|
+
export type {
|
|
5
|
+
MapViewProps,
|
|
6
|
+
MapViewRef,
|
|
7
|
+
MoveCameraOptions,
|
|
8
|
+
CameraMoveEvent,
|
|
9
|
+
CameraIdleEvent,
|
|
10
|
+
} from './MapView.types';
|
|
11
|
+
export type { MarkerProps } from './Marker.types';
|
|
12
|
+
export type { PolylineProps } from './Polyline.types';
|
|
13
|
+
export type { MapProvider, Coordinate, Point, EdgeInsets } from './types';
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map provider type
|
|
3
|
+
*/
|
|
4
|
+
export type MapProvider = 'google' | 'apple';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Geographic coordinate with latitude and longitude
|
|
8
|
+
*/
|
|
9
|
+
export interface Coordinate {
|
|
10
|
+
latitude: number;
|
|
11
|
+
longitude: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 2D point representing x and y positions
|
|
16
|
+
*/
|
|
17
|
+
export interface Point {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Edge insets for padding
|
|
24
|
+
*/
|
|
25
|
+
export interface EdgeInsets {
|
|
26
|
+
top: number;
|
|
27
|
+
left: number;
|
|
28
|
+
bottom: number;
|
|
29
|
+
right: number;
|
|
30
|
+
}
|