从javascript打开原生地图应用程序,而不依赖于经度和纬度坐标 [英] Opening native map app from javascript without relying on longitude and latitude coordinates

查看:97
本文介绍了从javascript打开原生地图应用程序,而不依赖于经度和纬度坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在寻找一种方法,通过一个手机包装的javascript应用程序打开该应用程序的原生地图应用程序。

Hi I am looking for a way to open the native map app of the application from a phonegap wrapped javascript app.

到目前为止,我的研究显示,对于Android我必须使用以下格式的链接:

So far my reaserch revealed that for Android I will have to use a link in this format:

<a href="geo:38.897096,-77.036545">Geolocation Test</a>

这是有问题的,因为我将不得不使用外部服务将地址转换为经度和格子坐标,如果可能的话,我想避免这样做。

This is problematic because I will have to use an external service to convert the address into longitude and lattitude coordinates , wich is something I would like to avoid if possible.

在iOS的情况下,这很简单。我只需要给它一个这种格式的链接: / p>

In the case of iOS this is alot simpler.I only have to give it a link in this format:

<a href="maps:q=Bacau">Test 2</a>

原生地图应用得到了支持。

And the native map app get's oppened.

有没有办法,类似于iOS中的那个,Android为它提供一个特定格式的地址的简单链接,设备将知道打开它的原生地图应用程序?

Is there any way , similar to the one in iOS , for Android to give it a plain link with an address in a specific format and the device will know to open it's native map app?

推荐答案

Cordova 3.6.0 引入了第二个白名单,用于限制允许启动外部应用程序的URL。在以前版本的Cordova中,所有非http URL(例如mailto:,geo:,sms:和intent)都被隐式允许作为标记的目标。由于应用程序可能泄露信息,如果XSS漏洞允许攻击者构建任意链接,则这些URL也必须列入白名单,从Cordova 3.6.0开始。

Cordova 3.6.0 introduces a second whitelist, for restricting which URLs are allowed to launch external applications. In previous versions of Cordova, all non-http URLs, such as mailto:, geo:, sms: and intent, were implicitly allowed to be the target of an a tag. Because of the potential for an application to leak information, if an XSS vulnerability allows an attacker to construct arbitrary links, these URLs must be whitelisted as well, starting in Cordova 3.6.0.

Cordova 3.6.0白名单指南

所以你需要在config.xml中明确添加:

So you need to add explicitly in the config.xml:

  <access origin="tel:*" launch-external="yes" />
  <access origin="mailto:*" launch-external="yes" />

这篇关于从javascript打开原生地图应用程序,而不依赖于经度和纬度坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆