expo-maps 0.7.1 → 0.7.2

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/maps/CustomLocationSource.kt +21 -0
  4. package/android/src/main/java/expo/modules/maps/GoogleMapsModule.kt +19 -0
  5. package/android/src/main/java/expo/modules/maps/GoogleMapsView.kt +88 -16
  6. package/android/src/main/java/expo/modules/maps/MapsModule.kt +10 -3
  7. package/android/src/main/java/expo/modules/maps/Records.kt +24 -0
  8. package/build/ExpoMaps.d.ts +4 -0
  9. package/build/ExpoMaps.d.ts.map +1 -0
  10. package/build/ExpoMaps.js +3 -0
  11. package/build/ExpoMaps.js.map +1 -0
  12. package/build/apple/AppleMapsView.d.ts +1 -1
  13. package/build/apple/AppleMapsView.d.ts.map +1 -1
  14. package/build/apple/AppleMapsView.js +3 -2
  15. package/build/apple/AppleMapsView.js.map +1 -1
  16. package/build/google/GoogleMaps.types.d.ts +30 -0
  17. package/build/google/GoogleMaps.types.d.ts.map +1 -1
  18. package/build/google/GoogleMaps.types.js.map +1 -1
  19. package/build/google/GoogleMapsView.d.ts +2 -2
  20. package/build/google/GoogleMapsView.d.ts.map +1 -1
  21. package/build/google/GoogleMapsView.js +9 -3
  22. package/build/google/GoogleMapsView.js.map +1 -1
  23. package/build/index.d.ts +15 -3
  24. package/build/index.d.ts.map +1 -1
  25. package/build/index.js +19 -2
  26. package/build/index.js.map +1 -1
  27. package/build/shared.types.d.ts +13 -0
  28. package/build/shared.types.d.ts.map +1 -1
  29. package/build/shared.types.js.map +1 -1
  30. package/expo-module.config.json +6 -2
  31. package/ios/AppleMapsModule.swift +18 -0
  32. package/ios/AppleMapsView.swift +15 -0
  33. package/ios/MapPermissionRequester.swift +81 -0
  34. package/ios/MapsModule.swift +26 -6
  35. package/package.json +2 -2
  36. package/plugin/build/withMapsLocation.d.ts +6 -0
  37. package/plugin/build/withMapsLocation.js +21 -0
  38. package/plugin/src/withMapsLocation.ts +28 -0
  39. package/plugin/tsconfig.json +9 -0
  40. package/src/ExpoMaps.ts +5 -0
  41. package/src/apple/AppleMapsView.tsx +3 -1
  42. package/src/google/GoogleMaps.types.ts +35 -0
  43. package/src/google/GoogleMapsView.tsx +54 -41
  44. package/src/index.ts +24 -2
  45. package/src/shared.types.ts +15 -0
package/CHANGELOG.md CHANGED
@@ -10,6 +10,10 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.7.2 — 2025-02-10
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
13
17
  ## 0.7.1 — 2025-02-06
14
18
 
15
19
  _This version does not introduce any user-facing changes._
@@ -37,13 +37,13 @@ if (KOTLIN_MAJOR_VERSION >= 2) {
37
37
  }
38
38
 
39
39
  group = 'host.exp.exponent'
40
- version = '0.7.1'
40
+ version = '0.7.2'
41
41
 
42
42
  android {
43
43
  namespace "expo.modules.maps"
44
44
  defaultConfig {
45
45
  versionCode 1
46
- versionName "0.7.1"
46
+ versionName "0.7.2"
47
47
  }
48
48
  buildFeatures {
49
49
  compose true
@@ -0,0 +1,21 @@
1
+ package expo.modules.maps
2
+
3
+ import android.location.Location
4
+ import com.google.android.gms.maps.LocationSource
5
+ import com.google.android.gms.maps.LocationSource.OnLocationChangedListener
6
+
7
+ class CustomLocationSource : LocationSource {
8
+ private var listener: OnLocationChangedListener? = null
9
+
10
+ override fun activate(listener: OnLocationChangedListener) {
11
+ this.listener = listener
12
+ }
13
+
14
+ override fun deactivate() {
15
+ listener = null
16
+ }
17
+
18
+ fun onLocationChanged(location: Location) {
19
+ listener?.onLocationChanged(location)
20
+ }
21
+ }
@@ -0,0 +1,19 @@
1
+ package expo.modules.maps
2
+
3
+ import expo.modules.kotlin.functions.Coroutine
4
+ import expo.modules.kotlin.modules.Module
5
+ import expo.modules.kotlin.modules.ModuleDefinition
6
+
7
+ class GoogleMapsModule : Module() {
8
+ override fun definition() = ModuleDefinition {
9
+ Name("ExpoGoogleMaps")
10
+
11
+ View(GoogleMapsView::class) {
12
+ Events("onMapLoaded", "onMapClick", "onMapLongClick", "onPOIClick", "onMarkerClick", "onCameraMove")
13
+
14
+ AsyncFunction("setCameraPosition") Coroutine { view: GoogleMapsView, config: SetCameraPositionConfig? ->
15
+ view.setCameraPosition(config)
16
+ }
17
+ }
18
+ }
19
+ }
@@ -2,6 +2,7 @@
2
2
 
3
3
  package expo.modules.maps
4
4
 
5
+ import android.annotation.SuppressLint
5
6
  import android.content.Context
6
7
  import android.graphics.Bitmap
7
8
  import android.graphics.drawable.BitmapDrawable
@@ -10,14 +11,17 @@ import androidx.compose.foundation.layout.fillMaxSize
10
11
  import androidx.compose.runtime.Composable
11
12
  import androidx.compose.runtime.LaunchedEffect
12
13
  import androidx.compose.runtime.MutableState
13
- import androidx.compose.runtime.State
14
14
  import androidx.compose.runtime.derivedStateOf
15
15
  import androidx.compose.runtime.mutableStateOf
16
16
  import androidx.compose.runtime.remember
17
17
  import androidx.compose.ui.Modifier
18
+ import com.google.android.gms.maps.CameraUpdateFactory
19
+ import com.google.android.gms.maps.LocationSource
18
20
  import com.google.android.gms.maps.model.BitmapDescriptor
19
21
  import com.google.android.gms.maps.model.BitmapDescriptorFactory
20
22
  import com.google.android.gms.maps.model.CameraPosition
23
+ import com.google.android.gms.maps.model.LatLng
24
+ import com.google.maps.android.compose.CameraMoveStartedReason
21
25
  import com.google.maps.android.compose.CameraPositionState
22
26
  import com.google.maps.android.compose.GoogleMap
23
27
  import com.google.maps.android.compose.Marker
@@ -29,8 +33,10 @@ import expo.modules.kotlin.types.toKClass
29
33
  import expo.modules.kotlin.viewevent.EventDispatcher
30
34
  import expo.modules.kotlin.views.ComposeProps
31
35
  import expo.modules.kotlin.views.ExpoComposeView
36
+ import kotlinx.coroutines.launch
32
37
 
33
38
  data class GoogleMapsViewProps(
39
+ val userLocation: MutableState<UserLocationRecord> = mutableStateOf(UserLocationRecord()),
34
40
  val cameraPosition: MutableState<CameraPositionRecord> = mutableStateOf(CameraPositionRecord()),
35
41
  val markers: MutableState<List<MarkerRecord>> = mutableStateOf(listOf()),
36
42
  val uiSettings: MutableState<MapUiSettingsRecord> = mutableStateOf(MapUiSettingsRecord()),
@@ -38,6 +44,7 @@ data class GoogleMapsViewProps(
38
44
  val colorScheme: MutableState<MapColorSchemeEnum> = mutableStateOf(MapColorSchemeEnum.FOLLOW_SYSTEM)
39
45
  ) : ComposeProps
40
46
 
47
+ @SuppressLint("ViewConstructor")
41
48
  class GoogleMapsView(context: Context, appContext: AppContext) : ExpoComposeView<GoogleMapsViewProps>(context, appContext) {
42
49
  override val props = GoogleMapsViewProps()
43
50
 
@@ -50,16 +57,20 @@ class GoogleMapsView(context: Context, appContext: AppContext) : ExpoComposeView
50
57
 
51
58
  private val onCameraMove by EventDispatcher<CameraMoveEvent>()
52
59
 
53
- private var wasLoaded = mutableStateOf<Boolean>(false)
60
+ private var wasLoaded = mutableStateOf(false)
61
+
62
+ private lateinit var cameraState: CameraPositionState
63
+ private var manualCameraControl = false
54
64
 
55
65
  init {
56
66
  setContent {
57
- val cameraState = cameraStateFromProps()
67
+ cameraState = updateCameraState()
58
68
  val markerState = markerStateFromProps()
69
+ val locationSource = locationSourceFromProps()
59
70
 
60
71
  GoogleMap(
61
72
  modifier = Modifier.fillMaxSize(),
62
- cameraPositionState = cameraState.value,
73
+ cameraPositionState = cameraState,
63
74
  uiSettings = props.uiSettings.value.toMapUiSettings(),
64
75
  properties = props.properties.value.toMapProperties(),
65
76
  onMapLoaded = {
@@ -84,7 +95,18 @@ class GoogleMapsView(context: Context, appContext: AppContext) : ExpoComposeView
84
95
  )
85
96
  )
86
97
  },
87
- mapColorScheme = props.colorScheme.value.toComposeMapColorScheme()
98
+ onMyLocationButtonClick = props.userLocation.value.coordinates?.let { coordinates ->
99
+ {
100
+ // Override onMyLocationButtonClick with default behavior to update manualCameraControl
101
+ appContext.mainQueue.launch {
102
+ cameraState.animate(CameraUpdateFactory.newLatLng(coordinates.toLatLng()))
103
+ manualCameraControl = false
104
+ }
105
+ true
106
+ }
107
+ },
108
+ mapColorScheme = props.colorScheme.value.toComposeMapColorScheme(),
109
+ locationSource = locationSource
88
110
  ) {
89
111
  for ((marker, state) in markerState.value) {
90
112
  val icon = getIconDescriptor(marker)
@@ -114,25 +136,31 @@ class GoogleMapsView(context: Context, appContext: AppContext) : ExpoComposeView
114
136
  }
115
137
 
116
138
  @Composable
117
- private fun cameraStateFromProps(): State<CameraPositionState> {
118
- val cameraState = remember {
119
- derivedStateOf {
120
- CameraPositionState(
121
- position = CameraPosition.fromLatLngZoom(
122
- props.cameraPosition.value.coordinates.toLatLng(),
123
- props.cameraPosition.value.zoom
124
- )
139
+ private fun updateCameraState(): CameraPositionState {
140
+ val cameraPosition = props.cameraPosition.value
141
+ cameraState = remember {
142
+ CameraPositionState(
143
+ position = CameraPosition.fromLatLngZoom(
144
+ cameraPosition.coordinates.toLatLng(),
145
+ cameraPosition.zoom
125
146
  )
147
+ )
148
+ }
149
+
150
+ LaunchedEffect(cameraState.cameraMoveStartedReason) {
151
+ // We should stop following the user's location when camera is moved manually.
152
+ if (cameraState.cameraMoveStartedReason == CameraMoveStartedReason.GESTURE || cameraState.cameraMoveStartedReason == CameraMoveStartedReason.API_ANIMATION) {
153
+ manualCameraControl = true
126
154
  }
127
155
  }
128
156
 
129
- LaunchedEffect(cameraState.value.position) {
157
+ LaunchedEffect(cameraState.position) {
130
158
  // We don't want to send the event when the map is not loaded yet
131
159
  if (!wasLoaded.value) {
132
160
  return@LaunchedEffect
133
161
  }
134
162
 
135
- val position = cameraState.value.position
163
+ val position = cameraState.position
136
164
  onCameraMove(
137
165
  CameraMoveEvent(
138
166
  Coordinates(position.target.latitude, position.target.longitude),
@@ -142,10 +170,34 @@ class GoogleMapsView(context: Context, appContext: AppContext) : ExpoComposeView
142
170
  )
143
171
  )
144
172
  }
145
-
146
173
  return cameraState
147
174
  }
148
175
 
176
+ @Composable
177
+ private fun locationSourceFromProps(): LocationSource? {
178
+ val coordinates = props.userLocation.value.coordinates
179
+ val followUserLocation = props.userLocation.value.followUserLocation
180
+
181
+ val locationSource = remember(coordinates) {
182
+ CustomLocationSource()
183
+ }
184
+ LaunchedEffect(coordinates) {
185
+ if (coordinates == null) {
186
+ return@LaunchedEffect
187
+ }
188
+ locationSource.onLocationChanged(coordinates.toLocation())
189
+ if (followUserLocation && !manualCameraControl) {
190
+ // Update camera position when location changes and manualCameraControl is disabled.
191
+ cameraState.animate(CameraUpdateFactory.newLatLng(coordinates.toLatLng()))
192
+ }
193
+ }
194
+ return coordinates?.let {
195
+ locationSource.apply {
196
+ onLocationChanged(coordinates.toLocation())
197
+ }
198
+ }
199
+ }
200
+
149
201
  @Composable
150
202
  private fun markerStateFromProps() =
151
203
  remember {
@@ -156,6 +208,26 @@ class GoogleMapsView(context: Context, appContext: AppContext) : ExpoComposeView
156
208
  }
157
209
  }
158
210
 
211
+ suspend fun setCameraPosition(config: SetCameraPositionConfig?) {
212
+ // Stop updating the camera position based on user location.
213
+ manualCameraControl = true
214
+ // If no coordinates are provided, the camera will be centered on the user's location.
215
+ val coordinates: LatLng = config?.coordinates?.toLatLng()
216
+ ?: props.userLocation.value.coordinates?.toLatLng()
217
+ ?: return
218
+
219
+ val cameraUpdate = config?.zoom?.let { CameraUpdateFactory.newLatLngZoom(coordinates, it) }
220
+ ?: CameraUpdateFactory.newLatLng(coordinates)
221
+
222
+ // When Int.MAX_VALUE is provided as durationMs, the default animation duration will be used.
223
+ cameraState.animate(cameraUpdate, config?.duration ?: Int.MAX_VALUE)
224
+
225
+ // If centering on the user's location, stop manual camera control.
226
+ if (config?.coordinates == null) {
227
+ manualCameraControl = false
228
+ }
229
+ }
230
+
159
231
  private fun getIconDescriptor(marker: MarkerRecord): BitmapDescriptor? {
160
232
  return marker.icon?.let { icon ->
161
233
  val bitmap = if (icon.`is`(toKClass<SharedRef<Drawable>>())) {
@@ -1,14 +1,21 @@
1
1
  package expo.modules.maps
2
2
 
3
+ import android.Manifest
4
+ import expo.modules.interfaces.permissions.Permissions
5
+ import expo.modules.kotlin.Promise
3
6
  import expo.modules.kotlin.modules.Module
4
7
  import expo.modules.kotlin.modules.ModuleDefinition
5
8
 
6
9
  class MapsModule : Module() {
7
10
  override fun definition() = ModuleDefinition {
8
- Name("ExpoGoogleMaps")
11
+ Name("ExpoMaps")
9
12
 
10
- View(GoogleMapsView::class) {
11
- Events("onMapLoaded", "onMapClick", "onMapLongClick", "onPOIClick", "onMarkerClick", "onCameraMove")
13
+ AsyncFunction("requestPermissionsAsync") { promise: Promise ->
14
+ Permissions.askForPermissionsWithPermissionsManager(appContext.permissions, promise, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION)
15
+ }
16
+
17
+ AsyncFunction("getPermissionsAsync") { promise: Promise ->
18
+ Permissions.getPermissionsWithPermissionsManager(appContext.permissions, promise, Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION)
12
19
  }
13
20
  }
14
21
  }
@@ -4,6 +4,7 @@ package expo.modules.maps
4
4
 
5
5
  import android.graphics.Bitmap
6
6
  import android.graphics.drawable.Drawable
7
+ import android.location.Location
7
8
  import com.google.android.gms.maps.model.LatLng
8
9
  import com.google.maps.android.compose.ComposeMapColorScheme
9
10
  import com.google.maps.android.compose.MapProperties
@@ -16,6 +17,17 @@ import expo.modules.kotlin.sharedobjects.SharedRef
16
17
  import expo.modules.kotlin.types.Either
17
18
  import expo.modules.kotlin.types.Enumerable
18
19
 
20
+ data class SetCameraPositionConfig(
21
+ @Field
22
+ val coordinates: Coordinates?,
23
+
24
+ @Field
25
+ val zoom: Float?,
26
+
27
+ @Field
28
+ val duration: Int?
29
+ ) : Record
30
+
19
31
  data class Coordinates(
20
32
  @Field
21
33
  val latitude: Double = 0.0,
@@ -26,6 +38,10 @@ data class Coordinates(
26
38
  fun toLatLng(): LatLng {
27
39
  return LatLng(latitude, longitude)
28
40
  }
41
+ fun toLocation() = Location("CustomLocation").apply {
42
+ latitude = this@Coordinates.latitude
43
+ longitude = this@Coordinates.longitude
44
+ }
29
45
  }
30
46
 
31
47
  data class MarkerRecord(
@@ -56,6 +72,14 @@ data class CameraPositionRecord(
56
72
  val zoom: Float = 10f
57
73
  ) : Record
58
74
 
75
+ data class UserLocationRecord(
76
+ @Field
77
+ val coordinates: Coordinates? = null,
78
+
79
+ @Field
80
+ val followUserLocation: Boolean = false
81
+ ) : Record
82
+
59
83
  data class MapUiSettingsRecord(
60
84
  @Field
61
85
  val compassEnabled: Boolean = true,
@@ -0,0 +1,4 @@
1
+ import { MapsModule } from './shared.types';
2
+ declare const _default: MapsModule;
3
+ export default _default;
4
+ //# sourceMappingURL=ExpoMaps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoMaps.d.ts","sourceRoot":"","sources":["../src/ExpoMaps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;;AAE5C,wBAA2D"}
@@ -0,0 +1,3 @@
1
+ import { requireNativeModule } from 'expo';
2
+ export default requireNativeModule('ExpoMaps');
3
+ //# sourceMappingURL=ExpoMaps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoMaps.js","sourceRoot":"","sources":["../src/ExpoMaps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAI3C,eAAe,mBAAmB,CAAa,UAAU,CAAC,CAAC","sourcesContent":["import { requireNativeModule } from 'expo';\n\nimport { MapsModule } from './shared.types';\n\nexport default requireNativeModule<MapsModule>('ExpoMaps');\n"]}
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
2
  import type { MapProps } from './AppleMaps.types';
3
- export declare function MapView({ onMapClick, onMarkerClick, onCameraMove, annotations, ...props }: MapProps): React.JSX.Element | null;
3
+ export declare function AppleMapsView({ onMapClick, onMarkerClick, onCameraMove, annotations, ...props }: MapProps): React.JSX.Element | null;
4
4
  //# sourceMappingURL=AppleMapsView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppleMapsView.d.ts","sourceRoot":"","sources":["../../src/apple/AppleMapsView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAiBlD,wBAAgB,OAAO,CAAC,EACtB,UAAU,EACV,aAAa,EACb,YAAY,EACZ,WAAW,EACX,GAAG,KAAK,EACT,EAAE,QAAQ,4BAsBV"}
1
+ {"version":3,"file":"AppleMapsView.d.ts","sourceRoot":"","sources":["../../src/apple/AppleMapsView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAiBlD,wBAAgB,aAAa,CAAC,EAC5B,UAAU,EACV,aAAa,EACb,YAAY,EACZ,WAAW,EACX,GAAG,KAAK,EACT,EAAE,QAAQ,4BAwBV"}
@@ -10,8 +10,9 @@ function useNativeEvent(userHandler) {
10
10
  userHandler?.(event.nativeEvent);
11
11
  }, [userHandler]);
12
12
  }
13
- export function MapView({ onMapClick, onMarkerClick, onCameraMove, annotations, ...props }) {
13
+ export function AppleMapsView({ onMapClick, onMarkerClick, onCameraMove, annotations, ...props }) {
14
14
  const onNativeMapClick = useNativeEvent(onMapClick);
15
+ const onNativeMarkerClick = useNativeEvent(onMarkerClick);
15
16
  const onNativeCameraMove = useNativeEvent(onCameraMove);
16
17
  const parsedAnnotations = annotations?.map((annotation) => ({
17
18
  ...annotation,
@@ -21,6 +22,6 @@ export function MapView({ onMapClick, onMarkerClick, onCameraMove, annotations,
21
22
  if (!NativeView) {
22
23
  return null;
23
24
  }
24
- return (<NativeView {...props} annotations={parsedAnnotations} onMapClick={onNativeMapClick} onCameraMove={onNativeCameraMove}/>);
25
+ return (<NativeView {...props} annotations={parsedAnnotations} onMapClick={onNativeMapClick} onMarkerClick={onNativeMarkerClick} onCameraMove={onNativeCameraMove}/>);
25
26
  }
26
27
  //# sourceMappingURL=AppleMapsView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppleMapsView.js","sourceRoot":"","sources":["../../src/apple/AppleMapsView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIxC,IAAI,UAAgD,CAAC;AAErD,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;IACzB,UAAU,GAAG,iBAAiB,CAAC,eAAe,CAAC,CAAC;CACjD;AAED,SAAS,cAAc,CAAI,WAA+B;IACxD,OAAO,KAAK,CAAC,WAAW,CACtB,CAAC,KAAK,EAAE,EAAE;QACR,WAAW,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC,EACD,CAAC,WAAW,CAAC,CACd,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,EACtB,UAAU,EACV,aAAa,EACb,YAAY,EACZ,WAAW,EACX,GAAG,KAAK,EACC;IACT,MAAM,gBAAgB,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IACpD,MAAM,kBAAkB,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;IAExD,MAAM,iBAAiB,GAAG,WAAW,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAC1D,GAAG,UAAU;QACb,mBAAmB;QACnB,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,yBAAyB;KACjD,CAAC,CAAC,CAAC;IAEJ,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,CAAC,UAAU,CACT,IAAI,KAAK,CAAC,CACV,WAAW,CAAC,CAAC,iBAAiB,CAAC,CAC/B,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAC7B,YAAY,CAAC,CAAC,kBAAkB,CAAC,EACjC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { Platform } from 'react-native';\n\nimport type { MapProps } from './AppleMaps.types';\n\nlet NativeView: React.ComponentType<MapProps> | null;\n\nif (Platform.OS === 'ios') {\n NativeView = requireNativeView('ExpoAppleMaps');\n}\n\nfunction useNativeEvent<T>(userHandler?: (data: T) => void) {\n return React.useCallback(\n (event) => {\n userHandler?.(event.nativeEvent);\n },\n [userHandler]\n );\n}\n\nexport function MapView({\n onMapClick,\n onMarkerClick,\n onCameraMove,\n annotations,\n ...props\n}: MapProps) {\n const onNativeMapClick = useNativeEvent(onMapClick);\n const onNativeCameraMove = useNativeEvent(onCameraMove);\n\n const parsedAnnotations = annotations?.map((annotation) => ({\n ...annotation,\n // @ts-expect-error\n icon: annotation.icon?.__expo_shared_object_id__,\n }));\n\n if (!NativeView) {\n return null;\n }\n\n return (\n <NativeView\n {...props}\n annotations={parsedAnnotations}\n onMapClick={onNativeMapClick}\n onCameraMove={onNativeCameraMove}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"AppleMapsView.js","sourceRoot":"","sources":["../../src/apple/AppleMapsView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIxC,IAAI,UAAgD,CAAC;AAErD,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;IACzB,UAAU,GAAG,iBAAiB,CAAC,eAAe,CAAC,CAAC;CACjD;AAED,SAAS,cAAc,CAAI,WAA+B;IACxD,OAAO,KAAK,CAAC,WAAW,CACtB,CAAC,KAAK,EAAE,EAAE;QACR,WAAW,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC,EACD,CAAC,WAAW,CAAC,CACd,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,EAC5B,UAAU,EACV,aAAa,EACb,YAAY,EACZ,WAAW,EACX,GAAG,KAAK,EACC;IACT,MAAM,gBAAgB,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IACpD,MAAM,mBAAmB,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;IAC1D,MAAM,kBAAkB,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;IAExD,MAAM,iBAAiB,GAAG,WAAW,EAAE,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAC1D,GAAG,UAAU;QACb,mBAAmB;QACnB,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,yBAAyB;KACjD,CAAC,CAAC,CAAC;IAEJ,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CACL,CAAC,UAAU,CACT,IAAI,KAAK,CAAC,CACV,WAAW,CAAC,CAAC,iBAAiB,CAAC,CAC/B,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAC7B,aAAa,CAAC,CAAC,mBAAmB,CAAC,CACnC,YAAY,CAAC,CAAC,kBAAkB,CAAC,EACjC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { Platform } from 'react-native';\n\nimport type { MapProps } from './AppleMaps.types';\n\nlet NativeView: React.ComponentType<MapProps> | null;\n\nif (Platform.OS === 'ios') {\n NativeView = requireNativeView('ExpoAppleMaps');\n}\n\nfunction useNativeEvent<T>(userHandler?: (data: T) => void) {\n return React.useCallback(\n (event) => {\n userHandler?.(event.nativeEvent);\n },\n [userHandler]\n );\n}\n\nexport function AppleMapsView({\n onMapClick,\n onMarkerClick,\n onCameraMove,\n annotations,\n ...props\n}: MapProps) {\n const onNativeMapClick = useNativeEvent(onMapClick);\n const onNativeMarkerClick = useNativeEvent(onMarkerClick);\n const onNativeCameraMove = useNativeEvent(onCameraMove);\n\n const parsedAnnotations = annotations?.map((annotation) => ({\n ...annotation,\n // @ts-expect-error\n icon: annotation.icon?.__expo_shared_object_id__,\n }));\n\n if (!NativeView) {\n return null;\n }\n\n return (\n <NativeView\n {...props}\n annotations={parsedAnnotations}\n onMapClick={onNativeMapClick}\n onMarkerClick={onNativeMarkerClick}\n onCameraMove={onNativeCameraMove}\n />\n );\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { SharedRef as SharedRefType } from 'expo/types';
2
+ import type { Ref } from 'react';
2
3
  import type { StyleProp, ViewStyle } from 'react-native';
3
4
  import { Coordinates } from '../shared.types';
4
5
  export type Marker = {
@@ -27,6 +28,16 @@ export type Marker = {
27
28
  */
28
29
  icon?: SharedRefType<'image'>;
29
30
  };
31
+ export type UserLocation = {
32
+ /**
33
+ * User location coordinates.
34
+ */
35
+ coordinates: Coordinates;
36
+ /**
37
+ * Should the camera follow the users location.
38
+ */
39
+ followUserLocation: boolean;
40
+ };
30
41
  export type CameraPosition = {
31
42
  /**
32
43
  * The middle point of the camera.
@@ -155,6 +166,7 @@ export declare enum MapColorScheme {
155
166
  FOLLOW_SYSTEM = "FOLLOW_SYSTEM"
156
167
  }
157
168
  export type MapProps = {
169
+ ref?: Ref<MapViewType>;
158
170
  style?: StyleProp<ViewStyle>;
159
171
  /**
160
172
  * The initial camera position of the map.
@@ -176,6 +188,10 @@ export type MapProps = {
176
188
  * Defines the color scheme for the map.
177
189
  */
178
190
  colorScheme?: MapColorScheme;
191
+ /**
192
+ * User location, overrides default behavior.
193
+ */
194
+ userLocation?: UserLocation;
179
195
  /**
180
196
  * Lambda invoked when the map is loaded.
181
197
  */
@@ -214,6 +230,20 @@ export type MapProps = {
214
230
  bearing: number;
215
231
  }) => void;
216
232
  };
233
+ export type SetCameraPositionConfig = CameraPosition & {
234
+ /**
235
+ * The duration of the animation in milliseconds.
236
+ */
237
+ duration?: number;
238
+ };
239
+ export type MapViewType = {
240
+ /**
241
+ * Update camera position.
242
+ *
243
+ * @param config New camera postion config.
244
+ */
245
+ setCameraPosition: (config?: SetCameraPositionConfig) => void;
246
+ };
217
247
  export type StreetViewProps = {
218
248
  style?: StyleProp<ViewStyle>;
219
249
  position?: Coordinates;
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMaps.types.d.ts","sourceRoot":"","sources":["../../src/google/GoogleMaps.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,MAAM,MAAM,GAAG;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,IAAI,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAE1B;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAEnC;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;I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AC5B,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAE7B,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMaps.types.js","sourceRoot":"","sources":["../../src/google/GoogleMaps.types.ts"],"names":[],"mappings":"AAmHA;;GAEG;AACH,MAAM,CAAN,IAAY,OAiBX;AAjBD,WAAY,OAAO;IACjB;;OAEG;IACH,4BAAiB,CAAA;IACjB;;OAEG;IACH,4BAAiB,CAAA;IACjB;;OAEG;IACH,kCAAuB,CAAA;IACvB;;OAEG;IACH,8BAAmB,CAAA;AACrB,CAAC,EAjBW,OAAO,KAAP,OAAO,QAiBlB;AA+CD,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,+BAAa,CAAA;IACb,iDAA+B,CAAA;AACjC,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB","sourcesContent":["import type { SharedRef as SharedRefType } from 'expo/types';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { Coordinates } from '../shared.types';\n\nexport type Marker = {\n /**\n * The coordinates of the marker.\n */\n coordinates?: Coordinates;\n\n /**\n * The title of the marker, displayed in the callout when the marker is clicked.\n */\n title?: string;\n\n /**\n * The snippet of the marker, Displayed in the callout when the marker is clicked.\n */\n snippet?: string;\n\n /**\n * Whether the marker is draggable.\n */\n draggable?: boolean;\n\n /**\n * Whether the callout should be shown when the marker is clicked.\n */\n showCallout?: boolean;\n\n /**\n * The custom icon to display for the marker.\n */\n icon?: SharedRefType<'image'>;\n};\n\nexport type CameraPosition = {\n /**\n * The middle point of the camera.\n */\n coordinates?: Coordinates;\n\n /**\n * The zoom level of the camera.\n * For some view sizez, lower zoom levels might not be available.\n */\n zoom?: number;\n};\n\nexport type MapUiSettings = {\n /**\n * Whether the compass is enabled on the map.\n * If enabled, the compass is only visible when the map is rotated.\n */\n compassEnabled?: boolean;\n\n /**\n * Whether the indoor level picker is enabled .\n */\n indoorLevelPickerEnabled?: boolean;\n\n /**\n * Whether the map toolbar is visible.\n */\n mapToolbarEnabled?: boolean;\n\n /**\n * Whether the my location button is visible.\n */\n myLocationButtonEnabled?: boolean;\n\n /**\n * Whether rotate gestures are enabled.\n */\n rotationGesturesEnabled?: boolean;\n\n /**\n * Whether the scroll gestures are enabled.\n */\n scrollGesturesEnabled?: boolean;\n\n /**\n * Whether the scroll gestures are enabled during rotation or zoom.\n */\n scrollGesturesEnabledDuringRotateOrZoom?: boolean;\n\n /**\n * Whether the tilt gestures are enabled.\n */\n tiltGesturesEnabled?: boolean;\n\n /**\n * Whether the zoom controls are visible.\n */\n zoomControlsEnabled?: boolean;\n\n /**\n * Whether the zoom gestures are enabled.\n */\n zoomGesturesEnabled?: boolean;\n\n /**\n * Whether the scale bar is displayed when zooming.\n * @platform ios\n */\n scaleBarEnabled?: boolean;\n\n /**\n * Whether the user is allowed to change the pitch type.\n * @platform ios\n */\n togglePitchEnabled?: boolean;\n};\n\n/**\n * The type of map to display.\n */\nexport enum MapType {\n /**\n * Satellite imagery with roads and points of interest overlayed.\n */\n HYBRID = 'HYBRID',\n /**\n * Standard road map.\n */\n NORMAL = 'NORMAL',\n /**\n * Satellite imagery.\n */\n SATELLITE = 'SATELLITE',\n /**\n * Topographic data.\n */\n TERRAIN = 'TERRAIN',\n}\n\nexport type MapProperties = {\n /**\n * Whether the building layer is enabled on the map.\n */\n isBuildingEnabled?: boolean;\n\n /**\n * Whether the indoor layer is enabled on the map.\n */\n isIndoorEnabled?: boolean;\n\n /**\n * Whether finding the user's location is enabled on the map.\n */\n isMyLocationEnabled?: boolean;\n\n /**\n * Whether the traffic layer is enabled on the map.\n */\n isTrafficEnabled?: boolean;\n\n /**\n * Defines which map type should be used.\n */\n mapType?: MapType;\n\n /**\n * If true, the user can select a location on the map to get more information.\n * @platform ios\n */\n selectionEnabled?: boolean;\n\n /**\n * The maximum zoom level for the map.\n * @platform android\n */\n maxZoomPreference?: number;\n\n /**\n * The minimum zoom level for the map.\n * @platform android\n */\n minZoomPreference?: number;\n};\n\nexport enum MapColorScheme {\n LIGHT = 'LIGHT',\n DARK = 'DARK',\n FOLLOW_SYSTEM = 'FOLLOW_SYSTEM',\n}\n\nexport type MapProps = {\n style?: StyleProp<ViewStyle>;\n\n /**\n * The initial camera position of the map.\n */\n cameraPosition?: CameraPosition;\n\n /**\n * The array of markers to display on the map.\n */\n markers?: Marker[];\n\n /**\n * The `MapUiSettings` to be used for UI-specific settings on the map.\n */\n uiSettings?: MapUiSettings;\n\n /**\n * The properties for the map.\n */\n properties?: MapProperties;\n\n /**\n * Defines the color scheme for the map.\n */\n colorScheme?: MapColorScheme;\n\n /**\n * Lambda invoked when the map is loaded.\n */\n onMapLoaded?: () => void;\n\n /**\n * Lambda invoked when the user clicks on the map.\n * It won't be invoked if the user clicks on POI or a marker.\n */\n onMapClick?: (event: { coordinates: Coordinates }) => void;\n\n /**\n * Lambda invoked when the user long presses on the map.\n */\n onMapLongClick?: (event: { coordinates: Coordinates }) => void;\n\n /**\n * Lambda invoked when a POI is clicked.\n */\n onPOIClick?: (event: { name: string; coordinates: Coordinates }) => void;\n\n /**\n * Lambda invoked when the marker is clicked\n */\n onMarkerClick?: (event: Marker) => void;\n\n /**\n * Lambda invoked when the map was moved by the user.\n */\n onCameraMove?: (event: {\n coordinates: Coordinates;\n zoom: number;\n tilt: number;\n bearing: number;\n }) => void;\n};\n\nexport type StreetViewProps = {\n style?: StyleProp<ViewStyle>;\n\n position?: Coordinates;\n isPanningGesturesEnabled?: boolean;\n isStreetNamesEnabled?: boolean;\n isUserNavigationEnabled?: boolean;\n isZoomGesturesEnabled?: boolean;\n};\n"]}
1
+ {"version":3,"file":"GoogleMaps.types.js","sourceRoot":"","sources":["../../src/google/GoogleMaps.types.ts"],"names":[],"mappings":"AAgIA;;GAEG;AACH,MAAM,CAAN,IAAY,OAiBX;AAjBD,WAAY,OAAO;IACjB;;OAEG;IACH,4BAAiB,CAAA;IACjB;;OAEG;IACH,4BAAiB,CAAA;IACjB;;OAEG;IACH,kCAAuB,CAAA;IACvB;;OAEG;IACH,8BAAmB,CAAA;AACrB,CAAC,EAjBW,OAAO,KAAP,OAAO,QAiBlB;AA+CD,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,+BAAa,CAAA;IACb,iDAA+B,CAAA;AACjC,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB","sourcesContent":["import type { SharedRef as SharedRefType } from 'expo/types';\nimport type { Ref } from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { Coordinates } from '../shared.types';\n\nexport type Marker = {\n /**\n * The coordinates of the marker.\n */\n coordinates?: Coordinates;\n\n /**\n * The title of the marker, displayed in the callout when the marker is clicked.\n */\n title?: string;\n\n /**\n * The snippet of the marker, Displayed in the callout when the marker is clicked.\n */\n snippet?: string;\n\n /**\n * Whether the marker is draggable.\n */\n draggable?: boolean;\n\n /**\n * Whether the callout should be shown when the marker is clicked.\n */\n showCallout?: boolean;\n\n /**\n * The custom icon to display for the marker.\n */\n icon?: SharedRefType<'image'>;\n};\n\nexport type UserLocation = {\n /**\n * User location coordinates.\n */\n coordinates: Coordinates;\n\n /**\n * Should the camera follow the users location.\n */\n followUserLocation: boolean;\n};\n\nexport type CameraPosition = {\n /**\n * The middle point of the camera.\n */\n coordinates?: Coordinates;\n\n /**\n * The zoom level of the camera.\n * For some view sizez, lower zoom levels might not be available.\n */\n zoom?: number;\n};\n\nexport type MapUiSettings = {\n /**\n * Whether the compass is enabled on the map.\n * If enabled, the compass is only visible when the map is rotated.\n */\n compassEnabled?: boolean;\n\n /**\n * Whether the indoor level picker is enabled .\n */\n indoorLevelPickerEnabled?: boolean;\n\n /**\n * Whether the map toolbar is visible.\n */\n mapToolbarEnabled?: boolean;\n\n /**\n * Whether the my location button is visible.\n */\n myLocationButtonEnabled?: boolean;\n\n /**\n * Whether rotate gestures are enabled.\n */\n rotationGesturesEnabled?: boolean;\n\n /**\n * Whether the scroll gestures are enabled.\n */\n scrollGesturesEnabled?: boolean;\n\n /**\n * Whether the scroll gestures are enabled during rotation or zoom.\n */\n scrollGesturesEnabledDuringRotateOrZoom?: boolean;\n\n /**\n * Whether the tilt gestures are enabled.\n */\n tiltGesturesEnabled?: boolean;\n\n /**\n * Whether the zoom controls are visible.\n */\n zoomControlsEnabled?: boolean;\n\n /**\n * Whether the zoom gestures are enabled.\n */\n zoomGesturesEnabled?: boolean;\n\n /**\n * Whether the scale bar is displayed when zooming.\n * @platform ios\n */\n scaleBarEnabled?: boolean;\n\n /**\n * Whether the user is allowed to change the pitch type.\n * @platform ios\n */\n togglePitchEnabled?: boolean;\n};\n\n/**\n * The type of map to display.\n */\nexport enum MapType {\n /**\n * Satellite imagery with roads and points of interest overlayed.\n */\n HYBRID = 'HYBRID',\n /**\n * Standard road map.\n */\n NORMAL = 'NORMAL',\n /**\n * Satellite imagery.\n */\n SATELLITE = 'SATELLITE',\n /**\n * Topographic data.\n */\n TERRAIN = 'TERRAIN',\n}\n\nexport type MapProperties = {\n /**\n * Whether the building layer is enabled on the map.\n */\n isBuildingEnabled?: boolean;\n\n /**\n * Whether the indoor layer is enabled on the map.\n */\n isIndoorEnabled?: boolean;\n\n /**\n * Whether finding the user's location is enabled on the map.\n */\n isMyLocationEnabled?: boolean;\n\n /**\n * Whether the traffic layer is enabled on the map.\n */\n isTrafficEnabled?: boolean;\n\n /**\n * Defines which map type should be used.\n */\n mapType?: MapType;\n\n /**\n * If true, the user can select a location on the map to get more information.\n * @platform ios\n */\n selectionEnabled?: boolean;\n\n /**\n * The maximum zoom level for the map.\n * @platform android\n */\n maxZoomPreference?: number;\n\n /**\n * The minimum zoom level for the map.\n * @platform android\n */\n minZoomPreference?: number;\n};\n\nexport enum MapColorScheme {\n LIGHT = 'LIGHT',\n DARK = 'DARK',\n FOLLOW_SYSTEM = 'FOLLOW_SYSTEM',\n}\n\nexport type MapProps = {\n ref?: Ref<MapViewType>;\n style?: StyleProp<ViewStyle>;\n\n /**\n * The initial camera position of the map.\n */\n cameraPosition?: CameraPosition;\n\n /**\n * The array of markers to display on the map.\n */\n markers?: Marker[];\n\n /**\n * The `MapUiSettings` to be used for UI-specific settings on the map.\n */\n uiSettings?: MapUiSettings;\n\n /**\n * The properties for the map.\n */\n properties?: MapProperties;\n\n /**\n * Defines the color scheme for the map.\n */\n colorScheme?: MapColorScheme;\n\n /**\n * User location, overrides default behavior.\n */\n userLocation?: UserLocation;\n\n /**\n * Lambda invoked when the map is loaded.\n */\n onMapLoaded?: () => void;\n\n /**\n * Lambda invoked when the user clicks on the map.\n * It won't be invoked if the user clicks on POI or a marker.\n */\n onMapClick?: (event: { coordinates: Coordinates }) => void;\n\n /**\n * Lambda invoked when the user long presses on the map.\n */\n onMapLongClick?: (event: { coordinates: Coordinates }) => void;\n\n /**\n * Lambda invoked when a POI is clicked.\n */\n onPOIClick?: (event: { name: string; coordinates: Coordinates }) => void;\n\n /**\n * Lambda invoked when the marker is clicked\n */\n onMarkerClick?: (event: Marker) => void;\n\n /**\n * Lambda invoked when the map was moved by the user.\n */\n onCameraMove?: (event: {\n coordinates: Coordinates;\n zoom: number;\n tilt: number;\n bearing: number;\n }) => void;\n};\n\nexport type SetCameraPositionConfig = CameraPosition & {\n /**\n * The duration of the animation in milliseconds.\n */\n duration?: number;\n};\n\nexport type MapViewType = {\n /**\n * Update camera position.\n *\n * @param config New camera postion config.\n */\n setCameraPosition: (config?: SetCameraPositionConfig) => void;\n};\n\nexport type StreetViewProps = {\n style?: StyleProp<ViewStyle>;\n\n position?: Coordinates;\n isPanningGesturesEnabled?: boolean;\n isStreetNamesEnabled?: boolean;\n isUserNavigationEnabled?: boolean;\n isZoomGesturesEnabled?: boolean;\n};\n"]}
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
- import type { MapProps } from './GoogleMaps.types';
3
- export declare function MapView({ onMapLoaded, onMapClick, onMapLongClick, onPOIClick, onMarkerClick, onCameraMove, markers, ...props }: MapProps): React.JSX.Element | null;
2
+ import type { MapProps, MapViewType } from './GoogleMaps.types';
3
+ export declare const GoogleMapsView: React.ForwardRefExoticComponent<Omit<MapProps, "ref"> & React.RefAttributes<MapViewType>>;
4
4
  //# sourceMappingURL=GoogleMapsView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMapsView.d.ts","sourceRoot":"","sources":["../../src/google/GoogleMapsView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAiBnD,wBAAgB,OAAO,CAAC,EACtB,WAAW,EACX,UAAU,EACV,cAAc,EACd,UAAU,EACV,aAAa,EACb,YAAY,EACZ,OAAO,EACP,GAAG,KAAK,EACT,EAAE,QAAQ,4BA+BV"}
1
+ {"version":3,"file":"GoogleMapsView.d.ts","sourceRoot":"","sources":["../../src/google/GoogleMapsView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAA2B,MAAM,oBAAoB,CAAC;AAiBzF,eAAO,MAAM,cAAc,2FAqD1B,CAAC"}
@@ -10,7 +10,13 @@ function useNativeEvent(userHandler) {
10
10
  userHandler?.(event.nativeEvent);
11
11
  }, [userHandler]);
12
12
  }
13
- export function MapView({ onMapLoaded, onMapClick, onMapLongClick, onPOIClick, onMarkerClick, onCameraMove, markers, ...props }) {
13
+ export const GoogleMapsView = React.forwardRef(({ onMapLoaded, onMapClick, onMapLongClick, onPOIClick, onMarkerClick, onCameraMove, markers, ...props }, ref) => {
14
+ const nativeRef = React.useRef(null);
15
+ React.useImperativeHandle(ref, () => ({
16
+ setCameraPosition(config) {
17
+ nativeRef.current?.setCameraPosition(config);
18
+ },
19
+ }));
14
20
  const onNativeMapLoaded = React.useCallback(() => {
15
21
  onMapLoaded?.();
16
22
  }, [onMapLoaded]);
@@ -27,6 +33,6 @@ export function MapView({ onMapLoaded, onMapClick, onMapLongClick, onPOIClick, o
27
33
  if (!NativeView) {
28
34
  return null;
29
35
  }
30
- return (<NativeView {...props} markers={parsedMarkers} onMapLoaded={onNativeMapLoaded} onMapClick={onNativeMapClick} onMapLongClick={onNativeMapLongClick} onPOIClick={onNativePOIClick} onMarkerClick={onNativeMarkerClick} onCameraMove={onNativeCameraMove}/>);
31
- }
36
+ return (<NativeView {...props} ref={nativeRef} markers={parsedMarkers} onMapLoaded={onNativeMapLoaded} onMapClick={onNativeMapClick} onMapLongClick={onNativeMapLongClick} onPOIClick={onNativePOIClick} onMarkerClick={onNativeMarkerClick} onCameraMove={onNativeCameraMove}/>);
37
+ });
32
38
  //# sourceMappingURL=GoogleMapsView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GoogleMapsView.js","sourceRoot":"","sources":["../../src/google/GoogleMapsView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIxC,IAAI,UAAU,GAAyC,IAAI,CAAC;AAE5D,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;IAC7B,UAAU,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;CAClD;AAED,SAAS,cAAc,CAAI,WAA+B;IACxD,OAAO,KAAK,CAAC,WAAW,CACtB,CAAC,KAAK,EAAE,EAAE;QACR,WAAW,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC,EACD,CAAC,WAAW,CAAC,CACd,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,EACtB,WAAW,EACX,UAAU,EACV,cAAc,EACd,UAAU,EACV,aAAa,EACb,YAAY,EACZ,OAAO,EACP,GAAG,KAAK,EACC;IACT,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QAC/C,WAAW,EAAE,EAAE,CAAC;IAClB,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAClB,MAAM,gBAAgB,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IACpD,MAAM,oBAAoB,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;IAC5D,MAAM,gBAAgB,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IACpD,MAAM,mBAAmB,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;IAC1D,MAAM,kBAAkB,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;IAExD,MAAM,aAAa,GAAG,OAAO,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC9C,GAAG,MAAM;QACT,mBAAmB;QACnB,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,yBAAyB;KAC7C,CAAC,CAAC,CAAC;IAEJ,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,IAAI,CAAC;KACb;IACD,OAAO,CACL,CAAC,UAAU,CACT,IAAI,KAAK,CAAC,CACV,OAAO,CAAC,CAAC,aAAa,CAAC,CACvB,WAAW,CAAC,CAAC,iBAAiB,CAAC,CAC/B,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAC7B,cAAc,CAAC,CAAC,oBAAoB,CAAC,CACrC,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAC7B,aAAa,CAAC,CAAC,mBAAmB,CAAC,CACnC,YAAY,CAAC,CAAC,kBAAkB,CAAC,EACjC,CACH,CAAC;AACJ,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { Platform } from 'react-native';\n\nimport type { MapProps } from './GoogleMaps.types';\n\nlet NativeView: React.ComponentType<MapProps> | null = null;\n\nif (Platform.OS === 'android') {\n NativeView = requireNativeView('ExpoGoogleMaps');\n}\n\nfunction useNativeEvent<T>(userHandler?: (data: T) => void) {\n return React.useCallback(\n (event) => {\n userHandler?.(event.nativeEvent);\n },\n [userHandler]\n );\n}\n\nexport function MapView({\n onMapLoaded,\n onMapClick,\n onMapLongClick,\n onPOIClick,\n onMarkerClick,\n onCameraMove,\n markers,\n ...props\n}: MapProps) {\n const onNativeMapLoaded = React.useCallback(() => {\n onMapLoaded?.();\n }, [onMapLoaded]);\n const onNativeMapClick = useNativeEvent(onMapClick);\n const onNativeMapLongClick = useNativeEvent(onMapLongClick);\n const onNativePOIClick = useNativeEvent(onPOIClick);\n const onNativeMarkerClick = useNativeEvent(onMarkerClick);\n const onNativeCameraMove = useNativeEvent(onCameraMove);\n\n const parsedMarkers = markers?.map((marker) => ({\n ...marker,\n // @ts-expect-error\n icon: marker.icon?.__expo_shared_object_id__,\n }));\n\n if (!NativeView) {\n return null;\n }\n return (\n <NativeView\n {...props}\n markers={parsedMarkers}\n onMapLoaded={onNativeMapLoaded}\n onMapClick={onNativeMapClick}\n onMapLongClick={onNativeMapLongClick}\n onPOIClick={onNativePOIClick}\n onMarkerClick={onNativeMarkerClick}\n onCameraMove={onNativeCameraMove}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"GoogleMapsView.js","sourceRoot":"","sources":["../../src/google/GoogleMapsView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAIxC,IAAI,UAAU,GAAyC,IAAI,CAAC;AAE5D,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;IAC7B,UAAU,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;CACl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AE,yBAAyB;KAC7C,CAAC,CAAC,CAAC;IAEJ,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,IAAI,CAAC;KACb;IACD,OAAO,CACL,CAAC,UAAU,CACT,IAAI,KAAK,CAAC,CACV,GAAG,CAAC,CAAC,SAAS,CAAC,CACf,OAAO,CAAC,CAAC,aAAa,CAAC,CACvB,WAAW,CAAC,CAAC,iBAAiB,CAAC,CAC/B,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAC7B,cAAc,CAAC,CAAC,oBAAoB,CAAC,CACrC,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAC7B,aAAa,CAAC,CAAC,mBAAmB,CAAC,CACnC,YAAY,CAAC,CAAC,kBAAkB,CAAC,EACjC,CACH,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { Platform } from 'react-native';\n\nimport type { MapProps, MapViewType, SetCameraPositionConfig } from './GoogleMaps.types';\n\nlet NativeView: React.ComponentType<MapProps> | null = null;\n\nif (Platform.OS === 'android') {\n NativeView = requireNativeView('ExpoGoogleMaps');\n}\n\nfunction useNativeEvent<T>(userHandler?: (data: T) => void) {\n return React.useCallback(\n (event) => {\n userHandler?.(event.nativeEvent);\n },\n [userHandler]\n );\n}\n\nexport const GoogleMapsView = React.forwardRef<MapViewType, MapProps>(\n (\n {\n onMapLoaded,\n onMapClick,\n onMapLongClick,\n onPOIClick,\n onMarkerClick,\n onCameraMove,\n markers,\n ...props\n },\n ref\n ) => {\n const nativeRef = React.useRef<MapViewType>(null);\n React.useImperativeHandle(ref, () => ({\n setCameraPosition(config?: SetCameraPositionConfig) {\n nativeRef.current?.setCameraPosition(config);\n },\n }));\n\n const onNativeMapLoaded = React.useCallback(() => {\n onMapLoaded?.();\n }, [onMapLoaded]);\n const onNativeMapClick = useNativeEvent(onMapClick);\n const onNativeMapLongClick = useNativeEvent(onMapLongClick);\n const onNativePOIClick = useNativeEvent(onPOIClick);\n const onNativeMarkerClick = useNativeEvent(onMarkerClick);\n const onNativeCameraMove = useNativeEvent(onCameraMove);\n\n const parsedMarkers = markers?.map((marker) => ({\n ...marker,\n // @ts-expect-error\n icon: marker.icon?.__expo_shared_object_id__,\n }));\n\n if (!NativeView) {\n return null;\n }\n return (\n <NativeView\n {...props}\n ref={nativeRef}\n markers={parsedMarkers}\n onMapLoaded={onNativeMapLoaded}\n onMapClick={onNativeMapClick}\n onMapLongClick={onNativeMapLongClick}\n onPOIClick={onNativePOIClick}\n onMarkerClick={onNativeMarkerClick}\n onCameraMove={onNativeCameraMove}\n />\n );\n }\n);\n"]}
package/build/index.d.ts CHANGED
@@ -1,10 +1,9 @@
1
1
  import * as AppleTypes from './apple/AppleMaps.types';
2
- import { MapView as AppleMapsView } from './apple/AppleMapsView';
2
+ import { AppleMapsView } from './apple/AppleMapsView';
3
3
  import * as GoogleTypes from './google/GoogleMaps.types';
4
- import { MapView as GoogleMapsView } from './google/GoogleMapsView';
5
4
  import { StreetView as GoogleStreetView } from './google/GoogleStreetView';
6
5
  export declare namespace GoogleMaps {
7
- const View: typeof GoogleMapsView;
6
+ const View: import("react").ForwardRefExoticComponent<Omit<GoogleTypes.MapProps, "ref"> & import("react").RefAttributes<GoogleTypes.MapViewType>>;
8
7
  const StreetView: typeof GoogleStreetView;
9
8
  const MapType: typeof GoogleTypes.MapType;
10
9
  type MapType = GoogleTypes.MapType;
@@ -15,6 +14,7 @@ export declare namespace GoogleMaps {
15
14
  type MapUiSettings = GoogleTypes.MapUiSettings;
16
15
  type MapProperties = GoogleTypes.MapProperties;
17
16
  type MapProps = GoogleTypes.MapProps;
17
+ type MapView = GoogleTypes.MapViewType;
18
18
  }
19
19
  export declare namespace AppleMaps {
20
20
  const View: typeof AppleMapsView;
@@ -25,5 +25,17 @@ export declare namespace AppleMaps {
25
25
  type MapUiSettings = AppleTypes.MapUiSettings;
26
26
  type Marker = AppleTypes.Marker;
27
27
  }
28
+ export declare const requestPermissionsAsync: () => Promise<import("expo-modules-core").PermissionResponse>;
29
+ export declare const getPermissionsAsync: () => Promise<import("expo-modules-core").PermissionResponse>;
30
+ /**
31
+ * Check or request permissions to access the location.
32
+ * This uses both `requestPermissionsAsync` and `getPermissionsAsync` to interact with the permissions.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const [status, requestPermission] = useLocationPermissions();
37
+ * ```
38
+ */
39
+ export declare const useLocationPermissions: (options?: import("expo-modules-core").PermissionHookOptions<object> | undefined) => [import("expo-modules-core").PermissionResponse | null, () => Promise<import("expo-modules-core").PermissionResponse>, () => Promise<import("expo-modules-core").PermissionResponse>];
28
40
  export * from './shared.types';
29
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE3E,yBAAiB,UAAU,CAAC;IACnB,MAAM,IAAI,uBAAiB,CAAC;IAC5B,MAAM,UAAU,yBAAmB,CAAC;IAEpC,MAAM,OAAO,4BAAsB,CAAC;IAC3C,KAAY,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;IAEnC,MAAM,cAAc,mCAA6B,CAAC;IACzD,KAAY,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC;IAExD,KAAY,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IACxC,KAAY,cAAc,GAAG,WAAW,CAAC,cAAc,CAAC;IACxD,KAAY,aAAa,GAAG,WAAW,CAAC,aAAa,CAAC;IACtD,KAAY,aAAa,GAAG,WAAW,CAAC,aAAa,CAA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