android Gmaps v2 : Bounds and max zoom level -


it android , google maps v2. want set max zoom level bounds. here method i'm using :

gmap.animatecamera(cameraupdatefactory.newlatlngbounds(bounds, width, height, padding)); 

i've found link gave me possible workaround setting max zoom level in google maps android api v2

here workaraound found

gmap.setoncamerachangelistener(new oncamerachangelistener() {     @override     public void oncamerachange(cameraposition position) {         if (position.zoom > default_zoom)             gmap.animatecamera(cameraupdatefactory.zoomto(default_zoom));     } }); 

but solution zoom in until zoom level defined first animatecamera , zoom out until default_zoom if (default_zoom < position.zoom). in case, there 2 animatecamera

how avoid ? , make 1 animatecamera

thx in advance

ok, now, solution related here https://stackoverflow.com/a/19343818/1646479

here workaround:

private latlngbounds adjustboundsformaxzoomlevel(latlngbounds bounds) {   latlng sw = bounds.southwest;   latlng ne = bounds.northeast;   double deltalat = math.abs(sw.latitude - ne.latitude);   double deltalon = math.abs(sw.longitude - ne.longitude);    final double zoomn = 0.005; // minimum zoom coefficient   if (deltalat < zoomn) {      sw = new latlng(sw.latitude - (zoomn - deltalat / 2), sw.longitude);      ne = new latlng(ne.latitude + (zoomn - deltalat / 2), ne.longitude);      bounds = new latlngbounds(sw, ne);   }   else if (deltalon < zoomn) {      sw = new latlng(sw.latitude, sw.longitude - (zoomn - deltalon / 2));      ne = new latlng(ne.latitude, ne.longitude + (zoomn - deltalon / 2));      bounds = new latlngbounds(sw, ne);   }    return bounds; } 

but i'm looking solution translate android zoom level (16 in case) zoomn.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -