单击Google Maps链接后不能返回 [英] Can't go back after clicking on a Google Maps link

查看:57
本文介绍了单击Google Maps链接后不能返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的用Cordova编码的应用程序中,有类似的链接:

In my app, coded with Cordova, there are links like:

<a href="http://maps.google.com/maps?q=London,+GB">Show map for London</a>

单击它们时,将打开Goog​​le Maps并显示正确的地址.问题是我无法通过点击后退"按钮返回到我的应用程序.

When clicking on them, Google Maps opens and shows the correct address. The problem is that I can't go back to my app by tapping on the back button.

我认为这是因为我正在覆盖 backbutton 事件监听器.实际上,如果我注释掉以下行:

I think it's because I'm overwriting the backbutton event listener. In fact, If I comment out the following line:

document.addEventListener("backbutton", historyBack, true);

一切正常.问题是,我显然想在按下后退"按钮时调用自定义的 historyBack()函数.即使 historyBack()函数仅包含 alert("test"); 函数,在查看地图时按后退"按钮也不会触发.

Everything works fine. The thing is that I obviously want to call my custom historyBack() function when pressing the back button. Even if the historyBack() function only contains alert("test"); it doesn't fire when pressing the back button while viewing the map.

有没有解决此问题的方法?

Is there any workaround to this issue?

推荐答案

在Android上,将地址更改为:

On Android, change the address to:

<a href="geo:0,0?q=London,+GB" target="_blank">Show map for London</a>

这将打开实际的Google Maps应用程序(或您选择的任何其他应用程序),而不是在应用程序内部显示地图.

This will open the actual Google Maps app (or any other app of your choice), instead of showing the map inside your app.

这篇关于单击Google Maps链接后不能返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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