expo-maps 0.7.2 → 0.7.3
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/CHANGELOG.md +6 -0
- package/android/build.gradle +2 -2
- package/build/apple/AppleMaps.types.d.ts +14 -0
- package/build/apple/AppleMaps.types.d.ts.map +1 -1
- package/build/apple/AppleMaps.types.js.map +1 -1
- package/build/apple/AppleMapsView.d.ts +5 -2
- package/build/apple/AppleMapsView.d.ts.map +1 -1
- package/build/apple/AppleMapsView.js +12 -3
- package/build/apple/AppleMapsView.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/ios/AppleMapsModule.swift +5 -1
- package/ios/AppleMapsView.swift +33 -10
- package/ios/AppleMapsViewState.swift +11 -0
- package/package.json +3 -3
- package/src/apple/AppleMaps.types.ts +15 -0
- package/src/apple/AppleMapsView.tsx +38 -31
- package/src/index.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 0.7.3 — 2025-02-14
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- [iOS] Implement setCameraPosition ([#34886](https://github.com/expo/expo/pull/34886) by [@jakex7](https://github.com/jakex7))
|
|
18
|
+
|
|
13
19
|
## 0.7.2 — 2025-02-10
|
|
14
20
|
|
|
15
21
|
_This version does not introduce any user-facing changes._
|
package/android/build.gradle
CHANGED
|
@@ -37,13 +37,13 @@ if (KOTLIN_MAJOR_VERSION >= 2) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
group = 'host.exp.exponent'
|
|
40
|
-
version = '0.7.
|
|
40
|
+
version = '0.7.3'
|
|
41
41
|
|
|
42
42
|
android {
|
|
43
43
|
namespace "expo.modules.maps"
|
|
44
44
|
defaultConfig {
|
|
45
45
|
versionCode 1
|
|
46
|
-
versionName "0.7.
|
|
46
|
+
versionName "0.7.3"
|
|
47
47
|
}
|
|
48
48
|
buildFeatures {
|
|
49
49
|
compose true
|
|
@@ -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 = {
|
|
@@ -99,6 +100,7 @@ export type Annotation = {
|
|
|
99
100
|
icon?: SharedRefType<'image'>;
|
|
100
101
|
} & Marker;
|
|
101
102
|
export type MapProps = {
|
|
103
|
+
ref?: Ref<AppleMapsViewType>;
|
|
102
104
|
style?: StyleProp<ViewStyle>;
|
|
103
105
|
/**
|
|
104
106
|
* The initial camera position of the map.
|
|
@@ -141,4 +143,16 @@ export type MapProps = {
|
|
|
141
143
|
bearing: number;
|
|
142
144
|
}) => void;
|
|
143
145
|
};
|
|
146
|
+
/**
|
|
147
|
+
* @platform ios
|
|
148
|
+
*/
|
|
149
|
+
export type AppleMapsViewType = {
|
|
150
|
+
/**
|
|
151
|
+
* Update camera position.
|
|
152
|
+
* Animation duration is not supported on iOS.
|
|
153
|
+
*
|
|
154
|
+
* @param config New camera postion.
|
|
155
|
+
*/
|
|
156
|
+
setCameraPosition: (config?: CameraPosition) => void;
|
|
157
|
+
};
|
|
144
158
|
//# sourceMappingURL=AppleMaps.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppleMaps.types.d.ts","sourceRoot":"","sources":["../../src/apple/AppleMaps.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,MAA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AC,EAAE,MAAM,EAAE,CAAC;IAEnB;;OAEG;IACH,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAE3B;;OAEG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;IAE3B;;OAEG;IACH,UAAU,CAAC,EAAE,aAAa,CAAC;IAE3B;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,WAAW,CAAA;KAAE,KAAK,IAAI,CAAC;IAE3D;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAExC;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE;QACrB,WAAW,EAAE,WAAW,CAAC;QACzB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,KAAK,IAAI,CAAC;CACZ,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;;OAKG;IACH,iBAAiB,EAAE,CAAC,MAAM,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;CACtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppleMaps.types.js","sourceRoot":"","sources":["../../src/apple/AppleMaps.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AppleMaps.types.js","sourceRoot":"","sources":["../../src/apple/AppleMaps.types.ts"],"names":[],"mappings":"AAgEA;;GAEG;AACH,MAAM,CAAN,IAAY,OAaX;AAbD,WAAY,OAAO;IACjB;;OAEG;IACH,4BAAiB,CAAA;IACjB;;OAEG;IACH,gCAAqB,CAAA;IACrB;;OAEG;IACH,8BAAmB,CAAA;AACrB,CAAC,EAbW,OAAO,KAAP,OAAO,QAalB","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 SF symbol to display for the marker.\n */\n systemImage?: string;\n\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 tint color of the marker.\n */\n tintColor?: string;\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 my location button is visible.\n */\n myLocationButtonEnabled?: boolean;\n\n /**\n * Whether the scale bar is displayed when zooming.\n */\n scaleBarEnabled?: boolean;\n\n /**\n * Whether the user is allowed to change the pitch type.\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 STANDARD = 'STANDARD',\n /**\n * Satellite imagery.\n */\n IMAGERY = 'IMAGERY',\n}\n\nexport type MapProperties = {\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 */\n selectionEnabled?: boolean;\n};\n\nexport type Annotation = {\n /**\n * The background color of the annotation.\n */\n backgroundColor?: string;\n /**\n * The text to display in the annotation.\n */\n text?: string;\n /**\n * The text color of the annotation.\n */\n textColor?: string;\n /**\n * The custom icon to display in the annotation.\n */\n icon?: SharedRefType<'image'>;\n} & Marker;\n\nexport type MapProps = {\n ref?: Ref<AppleMapsViewType>;\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 array of annotations to display on the map.\n */\n annotations?: Annotation[];\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 * 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 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\n/**\n * @platform ios\n */\nexport type AppleMapsViewType = {\n /**\n * Update camera position.\n * Animation duration is not supported on iOS.\n *\n * @param config New camera postion.\n */\n setCameraPosition: (config?: CameraPosition) => void;\n};\n"]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { MapProps } from './AppleMaps.types';
|
|
3
|
-
|
|
2
|
+
import type { AppleMapsViewType, MapProps } from './AppleMaps.types';
|
|
3
|
+
/**
|
|
4
|
+
* @platform ios
|
|
5
|
+
*/
|
|
6
|
+
export declare const AppleMapsView: React.ForwardRefExoticComponent<Omit<MapProps, "ref"> & React.RefAttributes<AppleMapsViewType>>;
|
|
4
7
|
//# 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;
|
|
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,iBAAiB,EAAkB,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAiBrF;;GAEG;AACH,eAAO,MAAM,aAAa,iGAkCzB,CAAC"}
|
|
@@ -10,7 +10,16 @@ function useNativeEvent(userHandler) {
|
|
|
10
10
|
userHandler?.(event.nativeEvent);
|
|
11
11
|
}, [userHandler]);
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* @platform ios
|
|
15
|
+
*/
|
|
16
|
+
export const AppleMapsView = React.forwardRef(({ onMapClick, onMarkerClick, onCameraMove, annotations, ...props }, ref) => {
|
|
17
|
+
const nativeRef = React.useRef(null);
|
|
18
|
+
React.useImperativeHandle(ref, () => ({
|
|
19
|
+
setCameraPosition(config) {
|
|
20
|
+
nativeRef.current?.setCameraPosition(config);
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
14
23
|
const onNativeMapClick = useNativeEvent(onMapClick);
|
|
15
24
|
const onNativeMarkerClick = useNativeEvent(onMarkerClick);
|
|
16
25
|
const onNativeCameraMove = useNativeEvent(onCameraMove);
|
|
@@ -22,6 +31,6 @@ export function AppleMapsView({ onMapClick, onMarkerClick, onCameraMove, annotat
|
|
|
22
31
|
if (!NativeView) {
|
|
23
32
|
return null;
|
|
24
33
|
}
|
|
25
|
-
return (<NativeView {...props} annotations={parsedAnnotations} onMapClick={onNativeMapClick} onMarkerClick={onNativeMarkerClick} onCameraMove={onNativeCameraMove}/>);
|
|
26
|
-
}
|
|
34
|
+
return (<NativeView {...props} ref={nativeRef} annotations={parsedAnnotations} onMapClick={onNativeMapClick} onMarkerClick={onNativeMarkerClick} onCameraMove={onNativeCameraMove}/>);
|
|
35
|
+
});
|
|
27
36
|
//# sourceMappingURL=AppleMapsView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppleMapsView.js","sourceRoot":"","sources":["../../src/apple/AppleMapsView.tsx"],"names":[],"mappings":"AAA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MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAoB,IAAI,CAAC,CAAC;IACxD,KAAK,CAAC,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;QACpC,iBAAiB,CAAC,MAAuB;YACvC,SAAS,CAAC,OAAO,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;QAC/C,CAAC;KACF,CAAC,CAAC,CAAC;IAEJ,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,GAAG,CAAC,CAAC,SAAS,CAAC,CACf,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,CACF,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\nimport { Platform } from 'react-native';\n\nimport type { AppleMapsViewType, CameraPosition, 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\n/**\n * @platform ios\n */\nexport const AppleMapsView = React.forwardRef<AppleMapsViewType, MapProps>(\n ({ onMapClick, onMarkerClick, onCameraMove, annotations, ...props }, ref) => {\n const nativeRef = React.useRef<AppleMapsViewType>(null);\n React.useImperativeHandle(ref, () => ({\n setCameraPosition(config?: CameraPosition) {\n nativeRef.current?.setCameraPosition(config);\n },\n }));\n\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 ref={nativeRef}\n annotations={parsedAnnotations}\n onMapClick={onNativeMapClick}\n onMarkerClick={onNativeMarkerClick}\n onCameraMove={onNativeCameraMove}\n />\n );\n }\n);\n"]}
|
package/build/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as AppleTypes from './apple/AppleMaps.types';
|
|
2
|
-
import { AppleMapsView } from './apple/AppleMapsView';
|
|
3
2
|
import * as GoogleTypes from './google/GoogleMaps.types';
|
|
4
3
|
import { StreetView as GoogleStreetView } from './google/GoogleStreetView';
|
|
5
4
|
export declare namespace GoogleMaps {
|
|
@@ -17,13 +16,14 @@ export declare namespace GoogleMaps {
|
|
|
17
16
|
type MapView = GoogleTypes.MapViewType;
|
|
18
17
|
}
|
|
19
18
|
export declare namespace AppleMaps {
|
|
20
|
-
const View:
|
|
19
|
+
const View: import("react").ForwardRefExoticComponent<Omit<AppleTypes.MapProps, "ref"> & import("react").RefAttributes<AppleTypes.AppleMapsViewType>>;
|
|
21
20
|
const MapType: typeof AppleTypes.MapType;
|
|
22
21
|
type MapType = AppleTypes.MapType;
|
|
23
22
|
type CameraPosition = AppleTypes.CameraPosition;
|
|
24
23
|
type MapProperties = AppleTypes.MapProperties;
|
|
25
24
|
type MapUiSettings = AppleTypes.MapUiSettings;
|
|
26
25
|
type Marker = AppleTypes.Marker;
|
|
26
|
+
type MapView = AppleTypes.AppleMapsViewType;
|
|
27
27
|
}
|
|
28
28
|
export declare const requestPermissionsAsync: () => Promise<import("expo-modules-core").PermissionResponse>;
|
|
29
29
|
export declare const getPermissionsAsync: () => Promise<import("expo-modules-core").PermissionResponse>;
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE3E,yBAAiB,UAAU,CAAC;IACnB,MAAM,IAAI,uIAAiB,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,CAAC;IACtD,KAAY,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;IAE5C,KAAY,OAAO,GAAG,WAAW,CAAC,WAAW,CAAC;CAC/C;AAED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C,EAjBgB,UAAU,KAAV,UAAU,QAiB1B;AAED,MAAM,KAAW,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,KAAK,UAAU,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE3E,MAAM,KAAW,UAAU,CAiB1B;AAjBD,WAAiB,UAAU;IACZ,eAAI,GAAG,cAAc,CAAC;IACtB,qBAAU,GAAG,gBAAgB,CAAC;IAE9B,kBAAO,GAAG,WAAW,CAAC,OAAO,CAAC;IAG9B,yBAAc,GAAG,WAAW,CAAC,cAAc,CAAC;AAU3D,CAAC,EAjBgB,UAAU,KAAV,UAAU,QAiB1B;AAED,MAAM,KAAW,SAAS,CAWzB;AAXD,WAAiB,SAAS;IACX,cAAI,GAAG,aAAa,CAAC;IAErB,iBAAO,GAAG,UAAU,CAAC,OAAO,CAAC;AAQ5C,CAAC,EAXgB,SAAS,KAAT,SAAS,QAWzB;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,QAAQ,CAAC,uBAAuB,CAAC;AACxE,MAAM,CAAC,MAAM,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,CAAC;AAEhE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;IACzD,SAAS,EAAE,mBAAmB;IAC9B,aAAa,EAAE,uBAAuB;CACvC,CAAC,CAAC;AAEH,cAAc,gBAAgB,CAAC","sourcesContent":["import { createPermissionHook } from 'expo-modules-core';\n\nimport ExpoMaps from './ExpoMaps';\nimport * as AppleTypes from './apple/AppleMaps.types';\nimport { AppleMapsView } from './apple/AppleMapsView';\nimport * as GoogleTypes from './google/GoogleMaps.types';\nimport { GoogleMapsView } from './google/GoogleMapsView';\nimport { StreetView as GoogleStreetView } from './google/GoogleStreetView';\n\nexport namespace GoogleMaps {\n export const View = GoogleMapsView;\n export const StreetView = GoogleStreetView;\n\n export const MapType = GoogleTypes.MapType;\n export type MapType = GoogleTypes.MapType;\n\n export const MapColorScheme = GoogleTypes.MapColorScheme;\n export type MapColorScheme = GoogleTypes.MapColorScheme;\n\n export type Marker = GoogleTypes.Marker;\n export type CameraPosition = GoogleTypes.CameraPosition;\n export type MapUiSettings = GoogleTypes.MapUiSettings;\n export type MapProperties = GoogleTypes.MapProperties;\n export type MapProps = GoogleTypes.MapProps;\n\n export type MapView = GoogleTypes.MapViewType;\n}\n\nexport namespace AppleMaps {\n export const View = AppleMapsView;\n\n export const MapType = AppleTypes.MapType;\n export type MapType = AppleTypes.MapType;\n export type CameraPosition = AppleTypes.CameraPosition;\n export type MapProperties = AppleTypes.MapProperties;\n export type MapUiSettings = AppleTypes.MapUiSettings;\n export type Marker = AppleTypes.Marker;\n\n export type MapView = AppleTypes.AppleMapsViewType;\n}\n\nexport const requestPermissionsAsync = ExpoMaps.requestPermissionsAsync;\nexport const getPermissionsAsync = ExpoMaps.getPermissionsAsync;\n\n/**\n * Check or request permissions to access the location.\n * This uses both `requestPermissionsAsync` and `getPermissionsAsync` to interact with the permissions.\n *\n * @example\n * ```ts\n * const [status, requestPermission] = useLocationPermissions();\n * ```\n */\nexport const useLocationPermissions = createPermissionHook({\n getMethod: getPermissionsAsync,\n requestMethod: requestPermissionsAsync,\n});\n\nexport * from './shared.types';\n"]}
|
|
@@ -13,6 +13,10 @@ public class AppleMapsModule: Module {
|
|
|
13
13
|
return false
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
View(AppleMapsViewWrapper.self)
|
|
16
|
+
View(AppleMapsViewWrapper.self) {
|
|
17
|
+
AsyncFunction("setCameraPosition") { (view: AppleMapsViewWrapper, config: CameraPosition?) in
|
|
18
|
+
view.setCameraPosition(config: config)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
17
21
|
}
|
|
18
22
|
}
|
package/ios/AppleMapsView.swift
CHANGED
|
@@ -15,13 +15,31 @@ class AppleMapsViewProps: ExpoSwiftUI.ViewProps {
|
|
|
15
15
|
let onCameraMove = EventDispatcher()
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
protocol AppleMapsViewProtocol: View {
|
|
19
|
+
func setCameraPosition(config: CameraPosition?)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
struct AppleMapsViewWrapper: ExpoSwiftUI.View, AppleMapsViewProtocol {
|
|
19
23
|
@EnvironmentObject var props: AppleMapsViewProps
|
|
24
|
+
var appleMapsView: (any AppleMapsViewProtocol)?
|
|
25
|
+
|
|
26
|
+
init() {
|
|
27
|
+
if #available(iOS 18.0, *) {
|
|
28
|
+
appleMapsView = AppleMapsView()
|
|
29
|
+
} else {
|
|
30
|
+
appleMapsView = nil
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
func setCameraPosition(config: CameraPosition?) {
|
|
35
|
+
appleMapsView?.setCameraPosition(config: config)
|
|
36
|
+
}
|
|
20
37
|
|
|
21
38
|
var body: some View {
|
|
22
39
|
if #available(iOS 18.0, *) {
|
|
23
|
-
AppleMapsView
|
|
24
|
-
.environmentObject(props)
|
|
40
|
+
if let appleMapsView = appleMapsView as? AppleMapsView {
|
|
41
|
+
appleMapsView.environmentObject(props)
|
|
42
|
+
}
|
|
25
43
|
} else {
|
|
26
44
|
EmptyView()
|
|
27
45
|
}
|
|
@@ -29,10 +47,15 @@ struct AppleMapsViewWrapper: ExpoSwiftUI.View {
|
|
|
29
47
|
}
|
|
30
48
|
|
|
31
49
|
@available(iOS 18.0, *)
|
|
32
|
-
struct AppleMapsView: View {
|
|
50
|
+
struct AppleMapsView: View, AppleMapsViewProtocol {
|
|
33
51
|
@EnvironmentObject var props: AppleMapsViewProps
|
|
34
|
-
@
|
|
35
|
-
|
|
52
|
+
@ObservedObject var state = AppleMapsViewState()
|
|
53
|
+
|
|
54
|
+
func setCameraPosition(config: CameraPosition?) {
|
|
55
|
+
withAnimation {
|
|
56
|
+
state.mapCameraPosition = config.map(convertToMapCamera) ?? .userLocation(fallback: state.mapCameraPosition)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
36
59
|
|
|
37
60
|
var body: some View {
|
|
38
61
|
let properties = props.properties
|
|
@@ -40,7 +63,7 @@ struct AppleMapsView: View {
|
|
|
40
63
|
|
|
41
64
|
// swiftlint:disable:next closure_body_length
|
|
42
65
|
MapReader { reader in
|
|
43
|
-
Map(position: $mapCameraPosition, selection: $selection) {
|
|
66
|
+
Map(position: $state.mapCameraPosition, selection: $state.selection) {
|
|
44
67
|
ForEach(props.markers) { marker in
|
|
45
68
|
Marker(
|
|
46
69
|
marker.title,
|
|
@@ -96,9 +119,9 @@ struct AppleMapsView: View {
|
|
|
96
119
|
}
|
|
97
120
|
}
|
|
98
121
|
.onChange(of: props.cameraPosition) { _, newValue in
|
|
99
|
-
mapCameraPosition = convertToMapCamera(position: newValue)
|
|
122
|
+
state.mapCameraPosition = convertToMapCamera(position: newValue)
|
|
100
123
|
}
|
|
101
|
-
.onChange(of: selection) { _, newValue in
|
|
124
|
+
.onChange(of: state.selection) { _, newValue in
|
|
102
125
|
if let marker = props.markers.first(where: { $0.mapItem == newValue?.value }) {
|
|
103
126
|
props.onMarkerClick([
|
|
104
127
|
"title": marker.title,
|
|
@@ -131,7 +154,7 @@ struct AppleMapsView: View {
|
|
|
131
154
|
showsTraffic: properties.isTrafficEnabled
|
|
132
155
|
))
|
|
133
156
|
.onAppear {
|
|
134
|
-
mapCameraPosition = convertToMapCamera(position: props.cameraPosition)
|
|
157
|
+
state.mapCameraPosition = convertToMapCamera(position: props.cameraPosition)
|
|
135
158
|
}
|
|
136
159
|
}
|
|
137
160
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright 2025-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import ExpoModulesCore
|
|
4
|
+
import MapKit
|
|
5
|
+
import SwiftUI
|
|
6
|
+
|
|
7
|
+
@available(iOS 18.0, *)
|
|
8
|
+
public class AppleMapsViewState: ObservableObject {
|
|
9
|
+
@Published var mapCameraPosition: MapCameraPosition = .automatic
|
|
10
|
+
@Published var selection: MapSelection<MKMapItem>?
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-maps",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Provides a Map component that uses Google Maps on Android and Apple Maps on iOS.",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"dependencies": {},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/react": "~18.3.12",
|
|
32
|
-
"expo-module-scripts": "^4.0.
|
|
32
|
+
"expo-module-scripts": "^4.0.4"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"expo": "*",
|
|
36
36
|
"react": "*",
|
|
37
37
|
"react-native": "*"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "7080126694798ca950d5dc3ef33483a17fa401bb"
|
|
40
40
|
}
|
|
@@ -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
|
|
|
4
5
|
import { Coordinates } from '../shared.types';
|
|
@@ -116,6 +117,7 @@ export type Annotation = {
|
|
|
116
117
|
} & Marker;
|
|
117
118
|
|
|
118
119
|
export type MapProps = {
|
|
120
|
+
ref?: Ref<AppleMapsViewType>;
|
|
119
121
|
style?: StyleProp<ViewStyle>;
|
|
120
122
|
|
|
121
123
|
/**
|
|
@@ -164,3 +166,16 @@ export type MapProps = {
|
|
|
164
166
|
bearing: number;
|
|
165
167
|
}) => void;
|
|
166
168
|
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @platform ios
|
|
172
|
+
*/
|
|
173
|
+
export type AppleMapsViewType = {
|
|
174
|
+
/**
|
|
175
|
+
* Update camera position.
|
|
176
|
+
* Animation duration is not supported on iOS.
|
|
177
|
+
*
|
|
178
|
+
* @param config New camera postion.
|
|
179
|
+
*/
|
|
180
|
+
setCameraPosition: (config?: CameraPosition) => void;
|
|
181
|
+
};
|
|
@@ -2,7 +2,7 @@ import { requireNativeView } from 'expo';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { Platform } from 'react-native';
|
|
4
4
|
|
|
5
|
-
import type { MapProps } from './AppleMaps.types';
|
|
5
|
+
import type { AppleMapsViewType, CameraPosition, MapProps } from './AppleMaps.types';
|
|
6
6
|
|
|
7
7
|
let NativeView: React.ComponentType<MapProps> | null;
|
|
8
8
|
|
|
@@ -19,34 +19,41 @@ function useNativeEvent<T>(userHandler?: (data: T) => void) {
|
|
|
19
19
|
);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
annotations,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @platform ios
|
|
24
|
+
*/
|
|
25
|
+
export const AppleMapsView = React.forwardRef<AppleMapsViewType, MapProps>(
|
|
26
|
+
({ onMapClick, onMarkerClick, onCameraMove, annotations, ...props }, ref) => {
|
|
27
|
+
const nativeRef = React.useRef<AppleMapsViewType>(null);
|
|
28
|
+
React.useImperativeHandle(ref, () => ({
|
|
29
|
+
setCameraPosition(config?: CameraPosition) {
|
|
30
|
+
nativeRef.current?.setCameraPosition(config);
|
|
31
|
+
},
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
const onNativeMapClick = useNativeEvent(onMapClick);
|
|
35
|
+
const onNativeMarkerClick = useNativeEvent(onMarkerClick);
|
|
36
|
+
const onNativeCameraMove = useNativeEvent(onCameraMove);
|
|
37
|
+
|
|
38
|
+
const parsedAnnotations = annotations?.map((annotation) => ({
|
|
39
|
+
...annotation,
|
|
40
|
+
// @ts-expect-error
|
|
41
|
+
icon: annotation.icon?.__expo_shared_object_id__,
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
if (!NativeView) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<NativeView
|
|
50
|
+
{...props}
|
|
51
|
+
ref={nativeRef}
|
|
52
|
+
annotations={parsedAnnotations}
|
|
53
|
+
onMapClick={onNativeMapClick}
|
|
54
|
+
onMarkerClick={onNativeMarkerClick}
|
|
55
|
+
onCameraMove={onNativeCameraMove}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
41
58
|
}
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<NativeView
|
|
45
|
-
{...props}
|
|
46
|
-
annotations={parsedAnnotations}
|
|
47
|
-
onMapClick={onNativeMapClick}
|
|
48
|
-
onMarkerClick={onNativeMarkerClick}
|
|
49
|
-
onCameraMove={onNativeCameraMove}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
59
|
+
);
|
package/src/index.ts
CHANGED
|
@@ -35,6 +35,8 @@ export namespace AppleMaps {
|
|
|
35
35
|
export type MapProperties = AppleTypes.MapProperties;
|
|
36
36
|
export type MapUiSettings = AppleTypes.MapUiSettings;
|
|
37
37
|
export type Marker = AppleTypes.Marker;
|
|
38
|
+
|
|
39
|
+
export type MapView = AppleTypes.AppleMapsViewType;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
export const requestPermissionsAsync = ExpoMaps.requestPermissionsAsync;
|