获得一个位置界于谷歌地图的Andr​​oid V2 [英] get bounds of a location in google map android v2

查看:149
本文介绍了获得一个位置界于谷歌地图的Andr​​oid V2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑我位置的经纬度在地图上。我如何能得到的B和C在地图上的位置的经纬度?我想要得到的红色框的范围。

Consider I have the LatLng of location A in the map. how can I get the Latlng of B and C position on the map? I want to get the bounds of the red box.

编辑:我想绑定此框并限制相机的束缚,所以用户不能更改摄像头和外出这个边界

I want to get the bound of this box and limit the camera to that bound, so user can not change the camera and go outside this bound

推荐答案

在code我张贴在这样的回答:<一href="http://stackoverflow.com/questions/6224671/mkcoordinateregionmakewithdistance-equvivalent-in-android/16417396#16417396">MKCoordinateRegionMakeWithDistance equvivalent Android中将得到边界你。

The code I posted in this answer: MKCoordinateRegionMakeWithDistance equvivalent in Android will get bounds for you.

用法:

LatLngBounds bounds = boundsWithCenterAndLatLngDistance(centerPointPosition, 12000, 12000); // 12000 in meters

这回答您关于得到边界原来的问题。您也可以从边界容易B点和C。

This answers your original question about getting bounds. You can also get point B and C from bounds easily.

现在的问题是,你不能限制用户与当前API平移。你可以尝试使用 onCameraChange 当你在室外检测,并逼退,但不会放弃在我看来,任何良好的用户体验。

Now the problem is you cannot restrict user panning with the current API. You may try to use onCameraChange to detect when you are outside and force it back, but that won't give any good user experience in my opinion.

我觉得你是移动的摄像头这个界限只有一次,给他们腾出手来刷到自己想要随时非洲更好。最后,他们将使用应用程序的功能,这是在你的边界。

I think you are better of moving camera to this bounds only once and giving them free hand to swipe to Africa anytime they want. In the end they will use app functionality, which is in your bounds.

这篇关于获得一个位置界于谷歌地图的Andr​​oid V2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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