0

I'm trying to achieve that camera update would center between two positions BUT if resulting zoom level is bigger than 12 it should be set to 12.

So i need some:

 CameraUpdateFactory.newLatLngBounds(bounds,padding);

But instead of padding there should be max zoom level.

My solution requires that i calculate exact screen bounds that will be after camera update and here i got stuck.

Alpha
  • 1,754
  • 3
  • 21
  • 39
  • Is your problem related to getting the zoom level value after the camera has been positioned, or setting the camera zoom level after determining whether the current zoom level is >= 12? – jaolstad Sep 30 '16 at 13:24
  • i need zoom level to be <= 12 as result, while bounding two or more coordinates. 'newLatLngZoom' doesn't guarantee that both coordinates will be visible to user. – Alpha Oct 03 '16 at 06:48
  • `'newLatLngZoom' doesn't guarantee that both coordinates will be visible to user.` yes it does, otherwise what would `padding` be for? – pskink Oct 03 '16 at 09:55
  • @pskink Word "both" stands for two `LatLng` objects. This means that there is two places on the map. – Alpha Oct 03 '16 at 10:09
  • you use `LatLngBounds` as a parameter so any number of `LatLng` in those bounds will be visible: in other words the whole `LatLngBounds` will be visible with the optional `padding` on four screen edges – pskink Oct 03 '16 at 10:12
  • `LatLngBounds` doesn't guarantee that zoom level will be 12 or less (if coordinates doesn't fit). it could zoom in way too much if coordinates ~100m apart. – Alpha Oct 03 '16 at 11:01
  • so you want two or more points to be visible or not? if you limit the zoom it may turn out that no point will be visible – pskink Oct 03 '16 at 11:13
  • There can be no such scenario, since i want to limit maximum zoom not minmum (lesser zoom level - more area is visible on the map). – Alpha Oct 03 '16 at 11:25

1 Answers1

0

If you need to calculate map screen bounds, you should use VisibleRegion

VisibleRegion visibleRegion = googleMap.getProjection().getVisibleRegion();
  • read also this question, may be similar to what you need.
Jossef Harush Kadouri
  • 32,361
  • 10
  • 130
  • 129