android - getProjection().getVisibleRegion().latLngBounds; returns 0 after onMapReady -


i trying latlngbounds visible region on device's screen after google map has been initialized. receive 0 values. guess map has not been loaded, after onmapready has been called. i've looked on better way of checking map initialization , found nothing. how ensure receive correct data?

initialize map

public void initmap(){     mapfragment map = (mapfragment) getfragmentmanager().findfragmentbyid(r.id.mapfragment);     map.getmapasync(this); } 

on map ready callback

@override public void onmapready(googlemap googlemap) {          try {         if (googlemap != null) {             mgooglemap = googlemap;             mgooglemap.setonmarkerclicklistener(this);             mgooglemap.setoncamerachangelistener(this);             mgooglemap.setonmapclicklistener(this);             mgooglemap.setmaptype(googlemap.map_type_normal);             search();         }      } catch (exception exception) {         mutility.getthemedalert(this,                 getresources().getstring(r.string.error_google_maps),                 getresources().getstring(r.string.unable_build_google_maps)).show();     } } 

get bounds

public void search() {     latlngbounds bounds = mgooglemap.getprojection().getvisibleregion().latlngbounds;     log.e("test", bounds.tostring()); } 

log output

e/test﹕ latlngbounds{southwest=lat/lng: (0.0,0.0), northeast=lat/lng: (0.0,0.0)} 

onmaploaded function helps. thank you.

here code,

map.setonmaploadedcallback(new googlemap.onmaploadedcallback() {                 @override                 public void onmaploaded() {                      invokeapi();                 } }); 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -