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

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

问题描述

您好我正在寻找一种方法,从一个phonegap打包的javascript应用程序打开应用程序的本机地图应用程序。



到目前为止,我的reaserch透露,对于Android我必须使用以下格式的链接:

 < a href =geo:38.897096,-77.036545>测试< / a> 

这是有问题的,因为我必须使用外部服务将地址转换为经度和网格坐标,这是我想避免的东西,如果可能的话。



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

 < a href =maps:q = Bacau>测试2< / a> 

原生地图应用程式已被拒绝。



有什么办法,类似于iOS中的一个,Android的给它一个明确的链接与一个特定格式的地址,设备将知道打开它的本地地图应用程序?


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



Cordova 3.6.0白名单指南



因此,您需要在config.xml中显式添加:

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


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

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.

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.

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 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 Whitelist Guide

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天全站免登陆