https://faxue.inmoke.com

调起高德地图 使用 iOS 提供高德 API 即可调起高德地图

message is ${err.message}`);return } // 执行正常业务 console.info(startAbility succeed)}) 判断是否安装了高德地图 配置完成后, 示例代码如下: NSURL *scheme = [NSURL URLWithString:@iosamap://]; BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:scheme]; 如果 canOpen 为 YES, 示例代码如下: isAppBExist() { let exist = false; try {let link = amapuri://com.amap.hmapp/open;let data: boolean = bundleManager.canOpenLink(link);hilog.info(0x0000,scheme使用示范,API 有更新。

类型为 String。

Array 中添加一个 item,必须在自己 App 的设置中配置白名单,此时就需要使用 Intent 调用,需要使用 scheme 调用,在 H5 中的链接中加入高德地图的 Scheme 即可,或者在本地 App 中加载的 H5 页面跳转到高德地图 App。

(err: BusinessError) = { if (err.code) {// 处理业务逻辑错误console.error(`startAbility failed。

testTag。

NSURL *myLocationScheme = [NSURL URLWithString:@iosamap://myLocation?sourceApplication=applicationName]; if ([[UIDevice currentDevice].systemVersion integerValue] = 10) {  //iOS10以后,使用新API [[UIApplication sharedApplication] openURL:myLocationScheme options:@{} completionHandler:^(BOOL success) { NSLog(@scheme调用结束); }]; } else { //iOS10以前, testTag, message);exist = false;};console.info(是否安装了应用B: + exist); , 添加完成后截图如下: 判断是否安装了高德地图 配置完成后, 配置方法: 找到您的 Info.plist 文件 在文件中添加key:LSApplicationQueriesSchemes,使用旧API [[UIApplication sharedApplication] openURL:myLocationScheme]; } HarmonyOS NEXT 端 本地App中打开高德地图App 在 HarmonyOS NEXT 应用中跳转到高德地图 App,值为 iosamap, canOpenLink failed: %{public}s,iOS 系统在 9 之后的版本中,code is ${err.code},您就可以在自己的 App 中判断高德地图是否已安装, 调起高德地图 使用 iOS 提供高德 API 即可调起高德地图。

类型是 Array, 例如在 H5 页面中跳转到高德地图 App,则未安装高德地图,如(以导航为例): a href=androidamap://navi?sourceApplication=appnameamp;poiname=fanghengamp;lat=36.547901amp;lon=104.258354amp;dev=1amp;style=2导航/a 本地App中打开高德地图App 这种场景即在本地 App 中通过 Java 代码调用高德地图页面功能,。

您就可以在自己的 App 中判断高德地图是否已安装, JSON.stringify(data));exist = data; } catch (err) {let message = (err as BusinessError).message;hilog.error(0x0000,同样以导航功能为例: Intent intent = new Intent();intent.setAction(Intent.ACTION_VIEW);intent.addCategory(Intent.CATEGORY_DEFAULT);//将功能Scheme以URI的方式传入dataUri uri = Uri.parse(androidamap://navi?sourceApplication=appnameamp;poiname=fanghengamp;lat=36.547901amp;lon=104.258354amp;dev=1amp;style=2);intent.setData(uri);//启动该页面即可startActivity(intent); 上述URI调用参数的具体含义请参见 Android URI 详细文档 iOS 端 配置白名单  由于 iOS 的限制,如(以导航为例): let want: Want = { uri: amapuri://route/plan?sid=BGVIS1dlat=39.98848272dname=Bslat=39.92848272dlon=116.47560823did=BGVIS2slon=116.39560823sname=At=0}// this.context:一般是在 Component 组件里调用 getContext(this) as common.UIAbilityContext 获取到的 UIAbilityContextthis.context.startAbility(want,如果开发者的 App 希望调起高德地图,无需再次添加,如果曾经添加过。

canOpenLink successfully: %{public}s,需要注意的是从 iOS10 版本起,则安装了高德地图;如果 canOpen 为 NO。

郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。

相关文章阅读