android - Zoom GoogleMap to my location -


i have sherlockfragmentactivity displays googlemap using google maps android api v2. want map zoom current location fragment launches. couldn't find such method in documentation. how achieve this?

private googlemap mmap;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.ui_settings_demo);     setupmapifneeded(); }  @override protected void onresume() {     super.onresume();     setupmapifneeded(); }  private void setupmapifneeded() {     // null check confirm have not instantiated map.     if (mmap == null) {         // try obtain map supportmapfragment.         mmap = ((supportmapfragment) getsupportfragmentmanager()                 .findfragmentbyid(r.id.map))                 .getmap();         if (mmap != null) {             setupmap();         }     }  }  private void setupmap() {     mmap.setmylocationenabled(true);     //how zoom current location?   } 

like this

cameraposition position = new cameraposition.builder()         .target(new latlng(lat,lon))         .zoom(zoom).build();       map.animatecamera(cameraupdatefactory.newcameraposition(position)); 

docs


Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -