iPhone - 从提示启用位置服务中禁用UIWebView [英] iPhone - Disable UIWebView from prompting to enable location services

查看:88
本文介绍了iPhone - 从提示启用位置服务中禁用UIWebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone应用程序开发过程中,我决定通过包含一个带有指向maps.google.com的URL构造的UIWebView来集成Google地图。问题是网站试图获取用户的位置,显示这个应用程序想要使用您的位置。这为我创造了很多问题,我可以在必要时解释。



有什么办法可以禁用UIWebView / Mobile Safari来询问用户的位置。我能想到的唯一解决方法是使用Google的Javascript v3 API制作我自己的地图,但我必须获得许可证,并且我不能100%确定我能够禁用要求的位置(尽管我认为我可以)。



有没有人有另一种解决方法或解决此问题的方法?感谢!

解决方案

我相信我现在找到了一个合适的解决方法。我记得您可以使用iframe在Google网站中嵌入Google地图。我检查了它们构造的URL,注意到它们附加了一个额外的参数output = embed。我在url中追加了output变量,并将其粘贴到模拟器的Mobile Safari中,它不再询问我的位置。



这个唯一的缺点是到目前为止,我可以看到,页面上有一些额外的UI组件,因为它包含页面上的移动控件和网站嵌入控件。编辑:在设备上测试显示嵌入控件不起作用,但移动控件的工作原理如下:做了地图的每一个其他方面。


During the development of my iPhone app, I decided to integrate Google Maps by including a UIWebView with a URL I construct pointing to maps.google.com. The problem is that the website tries to get the user's location, displaying the "This app wants to use your location". This creates a number of issues for me, which I can explain if necessary.

Is there any way to disable the UIWebView / Mobile Safari from asking for the user's location. The only workaround I can think of is to use Google's Javascript v3 API to make my own map, but I would have to get a license and I'm not 100% certain I would be able to disable asking for location (although I think I can).

Does anyone have an alternate workaround or way of tackling this issue? Thanks!

解决方案

I believe I found a suitable workaround for now. I remembered that you can embed maps from Google in your website using an iframe. I checked the url they construct to do this and noticed they appended an extra parameter, "output=embed". I appended the "output" variable in the url and pasted this into Mobile Safari on the simulator and it no longer asks me for my location.

The only drawback of this is that I can see so far is that there are some extra UI components on the page as it includes both the mobile controls and website embed controls on the page. Also, I have not tested this on an actual device yet.

Edit: Testing on the device showed that the embed controls don't work, but the mobile controls work as does every other aspect of the map.

这篇关于iPhone - 从提示启用位置服务中禁用UIWebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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