-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathNativeNavViewModule.ts
More file actions
174 lines (163 loc) · 6.2 KB
/
NativeNavViewModule.ts
File metadata and controls
174 lines (163 loc) · 6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/**
* Copyright 2026 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';
import type { Location } from '../shared';
import type {
Circle,
Marker,
Polyline,
Polygon,
GroundOverlay,
CameraPosition,
UISettings,
} from '../maps';
import type {
Float,
Double,
Int32,
WithDefault,
} from 'react-native/Libraries/Types/CodegenTypesNamespace';
// Note: Using Double instead of Int32 as codegen for TurboModules currently
// fails to unbox values to Integer on iOS. Transporting the value to integer is
// done in the native code.
type CameraPositionSpec = Readonly<{
target?: Readonly<{ lat: Float; lng: Float }> | null;
bearing?: WithDefault<Float, null>;
tilt?: WithDefault<Float, null>;
zoom?: WithDefault<Float, null>;
}>;
type MarkerOptionsSpec = Readonly<{
alpha?: WithDefault<Float, 0>;
draggable?: WithDefault<boolean, false>;
flat?: WithDefault<boolean, false>;
id?: WithDefault<string, null>;
imageBase64?: WithDefault<string, null>;
imgPath?: WithDefault<string, null>;
anchor?: Readonly<{ u: Float; v: Float }>;
position: Readonly<{ lat: Float; lng: Float }>;
rotation?: WithDefault<Float, 0>;
snippet?: WithDefault<string, null>;
title?: WithDefault<string, null>;
visible?: WithDefault<boolean, true>;
zIndex?: WithDefault<Double, null>;
}>;
type CircleOptionsSpec = Readonly<{
center: Readonly<{ lat: Float; lng: Float }>;
clickable?: WithDefault<boolean, true>;
fillColor?: WithDefault<Double, null>;
id?: WithDefault<string, null>;
radius: Float;
strokeColor?: WithDefault<Double, null>;
strokeWidth?: WithDefault<Float, 0>;
visible?: WithDefault<boolean, true>;
zIndex?: WithDefault<Double, null>;
}>;
type PolygonOptionsSpec = Readonly<{
clickable?: WithDefault<boolean, true>;
fillColor?: WithDefault<Double, null>;
geodesic?: WithDefault<boolean, false>;
holes: ReadonlyArray<ReadonlyArray<Readonly<{ lat: Float; lng: Float }>>>;
id?: WithDefault<string, null>;
points: ReadonlyArray<Readonly<{ lat: Float; lng: Float }>>;
strokeColor?: WithDefault<Double, null>;
strokeWidth?: WithDefault<Float, 0>;
visible?: WithDefault<boolean, true>;
zIndex?: WithDefault<Double, null>;
/** Mitered join (default): 0, Bevel: 1, Round: 2. */
//strokeJointType?: WithDefault<Double, 0>;
}>;
type PolylineOptionsSpec = Readonly<{
clickable?: WithDefault<boolean, true>;
color?: WithDefault<Double, null>;
id?: WithDefault<string, null>;
points: ReadonlyArray<Readonly<{ lat: Float; lng: Float }>>;
visible?: WithDefault<boolean, true>;
width?: WithDefault<Float, 1>;
zIndex?: WithDefault<Double, null>;
/** Mitered join (default): 0, Bevel: 1, Round: 2. */
//jointType?: WithDefault<Double, 0>;
}>;
type GroundOverlayOptionsSpec = Readonly<{
id?: WithDefault<string, null>;
imgPath: string;
// Position-based positioning (use location + width/height)
location?: Readonly<{ lat: Float; lng: Float }>;
width?: WithDefault<Float, null>;
height?: WithDefault<Float, null>;
zoomLevel?: WithDefault<Float, null>;
// Bounds-based positioning (alternative to location)
bounds?: Readonly<{
northEast: Readonly<{ lat: Float; lng: Float }>;
southWest: Readonly<{ lat: Float; lng: Float }>;
}>;
bearing?: WithDefault<Float, 0>;
/** Transparency of the ground overlay (0 = opaque, 1 = fully transparent). Default is 0. */
transparency?: WithDefault<Float, 0>;
anchor?: Readonly<{ u: Float; v: Float }>;
clickable?: WithDefault<boolean, false>;
visible?: WithDefault<boolean, true>;
zIndex?: WithDefault<Float, 0>;
}>;
/**
* TurboModule for map view operations.
*
* All methods take a `nativeID` string parameter to identify which view instance
* to operate on. The native implementation maintains a registry mapping nativeIDs
* to view instances.
*/
export interface Spec extends TurboModule {
addCircle(nativeID: string, options: CircleOptionsSpec): Promise<Circle>;
addMarker(nativeID: string, options: MarkerOptionsSpec): Promise<Marker>;
addPolyline(
nativeID: string,
options: PolylineOptionsSpec
): Promise<Polyline>;
addPolygon(nativeID: string, options: PolygonOptionsSpec): Promise<Polygon>;
addGroundOverlay(
nativeID: string,
options: GroundOverlayOptionsSpec
): Promise<GroundOverlay>;
setFollowingPerspective(
nativeID: string,
perspective: Int32,
zoomLevel?: WithDefault<Float, null>
): Promise<void>;
moveCamera(
nativeID: string,
cameraPosition: CameraPositionSpec
): Promise<void>;
getCameraPosition(nativeID: string): Promise<CameraPosition>;
getMyLocation(nativeID: string): Promise<Location>;
getUiSettings(nativeID: string): Promise<UISettings>;
isMyLocationEnabled(nativeID: string): Promise<boolean>;
setNavigationUIEnabled(nativeID: string, enabled: boolean): Promise<void>;
showRouteOverview(nativeID: string): Promise<boolean>;
clearMapView(nativeID: string): Promise<boolean>;
removeMarker(nativeID: string, id: string): Promise<boolean>;
removePolyline(nativeID: string, id: string): Promise<boolean>;
removePolygon(nativeID: string, id: string): Promise<boolean>;
removeCircle(nativeID: string, id: string): Promise<boolean>;
removeGroundOverlay(nativeID: string, id: string): Promise<boolean>;
setZoomLevel(nativeID: string, level: Double): Promise<boolean>;
getMarkers(nativeID: string): Promise<Marker[]>;
getCircles(nativeID: string): Promise<Circle[]>;
getPolylines(nativeID: string): Promise<Polyline[]>;
getPolygons(nativeID: string): Promise<Polygon[]>;
getGroundOverlays(nativeID: string): Promise<GroundOverlay[]>;
}
export default TurboModuleRegistry.getEnforcing<Spec>('NavViewModule');
export type { Spec as NavViewModuleSpec };