android - CameraUpdate, SupportMapFragment inside ViewPager, not loading second time -
i'm facing problems when placing supportmapfragment inside fragment part of viewpager 5 tabs, works correctly when viewpager loads map first time, not showing whe comming tab. load map follows:
@override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); fragmentmanager fm = getfragmentmanager(); mapfragment = (supportmapfragment) fm.findfragmentbyid(r.id.map_estate); if (mapfragment == null) { mapfragment = supportmapfragment.newinstance(); fm.begintransaction().replace(r.id.map_estate, mapfragment).commit(); } mapfragment.getmapasync(this); }
and use like:
@override public void onmapready(googlemap googlemap) { this.map = googlemap; this.map.setmylocationenabled(true); this.map.setmaptype(googlemap.map_type_hybrid); this.map.getuisettings().setmylocationbuttonenabled(false); cameraupdate cameraupdate = cameraupdatefactory.newlatlngzoom(center, 16); mapfragment.getmap().movecamera(cameraupdate); }
anyone facing same problem? in advance
replacingfragmentmanager fm = getfragmentmanager();
fragmentmanager fm = getchildfragmentmanager();
solved problem.
Comments
Post a Comment