I have 10 markers in the GoogleMap
. I want to zoom in as much as possible and keep all markers in view? In the earlier version this can be achieved from zoomToSpan()
but in v2 I have no idea how about doing that. Further, I know the radius of the circle that needs to be visible.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
http://i64.tinypic.com/2qjybh4.png
http://i63.tinypic.com/flzwus.png
http://i63.tinypic.com/112g5fm.png
I had similar problem, using following code solved the issue:
CameraUpdateFactory.newLatLngBounds(bounds, 200, 200, 5)
generally the location differences in my case are no more than two neighbour cities.zoom to fit all markers on map google maps v2
Google Map V2
The following solution works for Android Marshmallow 6 (API 23, API 24, API 25). It also works in Xamarin.
Show All Markers with Google map
In these Methods store all Markers and automatically zoom to show all markers in google map.
Note - This is not a solution to the original question. This is a solution to one of the subproblems discussed above.
Solution to @andr Clarification 2 -
Its really problematic when there's only one marker in the bounds and due to it the zoom level is set to a very high level (level 21). And Google does not provide any way to set the max zoom level at this point. This can also happen when there are more than 1 marker but they are all pretty close to each other. Then also the same problem will occur.
Solution - Suppose you want your Map to never go beyond 16 zoom level. Then after doing -
Check if your zoom level has crossed level 16(or whatever you want) -
And if this level is greater than 16, which it will only be if there are very less markers or all the markers are very close to each other, then simply zoom out your map at that particular position only by seting the zoom level to 16.
This way you'll never have the problem of "bizarre" zoom level explained very well by @andr too.
Use the method "getCenterCoordinate" to obtain the center coordinate and use in CameraPosition.