如何强制 Google 手机地图在地图视图而不是列表/文本视图中打开?
当我在手机上打开嵌入方向的链接(例如下面的链接)时,它默认为文本/列表视图而不是地图视图,即使尝试使用 URL 中的参数强制其为地图视图也是如此。
<一href="http://maps.google.com/maps?saddr=(37,-122)&daddr=(37,-120)&hl=en&ll=36.971838,-121.003418&spn=3.651097 ,7.020264& ;sll=37,-122.25&sspn=0.456252,0.877533&geocode=FUCTNAIdgG26-A%3BFUCTNAIdAPLY-A&vpsrc=6&mra=ls&t=m&z=8&视图=地图" rel="nofollow">http://maps.google.com/maps?saddr=(37,-122)&daddr=(37,-120)&hl=en&ll=36.971838,-121.003418& spn=3.651097,7.020264& amp;sll=37,-122.25&sspn=0.456252,0.877533&geocode=FUCTNAIdgG26-A%3BFUCTNAIdAPLY-A&vpsrc=6&mra=ls&t=m&z=8&view=map
您可以通过在移动设备上打开它或强制浏览器的用户代理使用 iPhone/iPad 来测试它。要在 Mac 上使用 Chrome 执行此操作,请打开终端并将以下内容粘贴到:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome -user-agent="Mozilla/5.0(iPad; U; CPU iPhone OS 3_2,如 Mac OS X;en-us) AppleWebKit/531.21.10(KHTML,如 Gecko)版本/4.0.4 Mobile/7B314 Safari/531.21.10”
是否有某种方法可以强制其打开地图视图而不是列表/文本视图?
我搜索了 Stack Overflow 和 Google API 论坛,但未能找到解决方案(另外两个用户提出了类似的问题,但他们没有得到答复,而且鉴于我是该网站的新手,它不会让我对他们的问题进行投票)。最好有一种方法可以通过 URL 参数来做到这一点,但我也愿意接受其他解决方案。
When I open a link with directions embedded (such as the one below) on a mobile phone, it defaults to text/list view instead of the map view, even when trying to use parameters in the URL to force it to map view.
You can test this by either opening it on a mobile device, or forcing your browser's user agent to iphone/ipad. To do this with Chrome on a Mac, open the terminal and paste the following in:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome -user-agent="Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10"
Is there some way to force it to open into map view instead of list/text view?
I searched Stack Overflow and the Google API forums but was not able to find a solution (two other users asked similar questions, but they went unanswered and given I am new to the site it will not let me up vote their questions). Preferably there would be a way to do this via URL parameters, but I am open to other solutions as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能无法完全回答您的问题,但在更新到 iOS 6 后,我在引用
maps.google.com
的现有 iOS 应用上遇到了同样的问题。我发现解决方案是引用maps.apple.com
(将 URL 中的google
更改为apple
)。我在 iOS 6 Safari 上对此进行了测试,发现新的 URL 按预期工作,并在新的 Apple 地图中打开地图视图,而旧的 Google 参考现在打开到列表/文本视图,如 OP 中所述。我猜测,当苹果公司删除谷歌地图库时,它造成了一个副作用,即 iOS 版本的 Safari 现在被谷歌视为任何其他移动平台。
参考: Apple Safari 地图链接
This may not exactly answer your question, but after updating to iOS 6 I've had the same problem on existing iOS apps that referenced
maps.google.com
. I found the solution is to referencemaps.apple.com
(changegoogle
toapple
in the URL). I tested this on iOS 6 Safari and found that the new URL works as expected and opens to the maps view in the new Apple maps whereas the old Google reference now opens to the list/text view as described in the OP.I am guessing that when Apple ripped out the Google map library it caused the side-effect that the iOS version of Safari is now treated by Google as any other mobile platform.
Reference: Apple Safari Map Links