最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

cordova - Opening native map app from JavaScript without relying on longitude and latitude coordinates - Stack Overflow

programmeradmin5浏览0评论

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

So far my research 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 latitude coordinates, which is something I would like to avoid if possible.

In the case of iOS this is a lot 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 opened.

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?

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

So far my research 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 latitude coordinates, which is something I would like to avoid if possible.

In the case of iOS this is a lot 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 opened.

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?

Share Improve this question edited Aug 7, 2020 at 18:39 Jason Aller 3,65428 gold badges41 silver badges39 bronze badges asked Aug 9, 2013 at 12:53 aleczandrualeczandru 5,44915 gold badges67 silver badges114 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 13

Looking at the Android intents list it should be possible using the q parameter within the geo: URI space.

Try this:

<a href="geo:0,0?q=Bacau">Test</a>

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" />

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论