firstly sorry english. try set exact visibile bounds in google maps android api. example map show america's region , user can't scroll map canada. when link can understand try do.i think can camerachangelistener , getting visible regions couldn't implement algorithm. can me ? http://sehirharitasi.ibb.gov.tr/
it not easy , link it's can work:
//when setup map: map.setoncamerachangelistener(new oncamerachangelistener() { @override public void oncamerachange(cameraposition cameraposition) { checkbounds(); } }); and checkbounds function can either check if visible area inside allowed one:
public void checkbounds() { //non ricostruire allowedbounds ogni volta, sono sempre gli stessi, fatti il build nell'oncreate latlngbounds actualvisiblebounds = map.getprojection().getvisibleregion().latlngbounds; if (allowedbounds.contains(actualvisiblebounds)){ return }else{ map.animatecamera(cameraupdatefactory.newlatlngbounds(allowedbounds)); } } or can use center of viewport , check if inside allowed area (to allow bounding zooms)
public void checkbounds() { latlngbounds.builder builder = new latlngbounds.builder(); builder.include(northeast); builder.include(southwest); final latlngbounds allowedbounds = builder.build(); latlngbounds centro = map.getprojection().getvisibleregion().latlngbounds; if (allowedbounds.contains(centro.getcenter())) return; else { map.animatecamera(cameraupdatefactory.newlatlngzoom(defaultlatlng, zoomlevel)); } }
Comments
Post a Comment