get bounds of a location in google map android v2

一笑奈何 提交于 2019-12-03 22:30:53
MaciejGórski

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

Usage:

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

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!