跳过内容

iOS 配置

GitHub

iOS 使用 Apple MapKit您可以 如果您调用 需要一个 iOS 的 Google Maps API key。

复制到剪贴板 enableCurrentLocation插件请求位置权限以 ios/App/App/Info.plist:

<key>NSLocationWhenInUseUsageDescription</key>
<string>We use your location to show you on the map.</string>

可以在权限被授予后可靠地解析。 keepAlive so enableCurrentLocation iOS uses

原生地图 MKMapView 将其挂载到 Capacitor WKWebView 层级中,并通过 onResize 和 onDisplay. 当 Ionic 页面重新进入时,调用路径在插件中重新挂载地图,如果 WebKit 重建了滚动视图。

使用透明的 WebView 或页面背景,地图应该显示在 HTML 层上方的地图容器。

In toBack 模式下, data-map-overlay 放置

在 HUD wrapper 上,使 README overlay CSS 可以启用触摸。native touch router 将手势发送到地图,当目标是透明的并且没有交互元素覆盖时。

iOS-only plugin methods

Section titled “iOS-only plugin methods” takeSnapshot, searchAutocomplete, searchPlaces, searchResolve, geocode简体中文 reverseGeocode/zh/docs/plugins/native-map/ios/ NativeMap Live Update

import { registerPlugin } from '@capacitor/core';
type NativeMapBridge = {
takeSnapshot(options: { id: string }): Promise<{ image: string }>;
geocode(options: { address: string }): Promise<Record<string, unknown>>;
};
const NativeMapBridge = registerPlugin<NativeMapBridge>('NativeMap');