Android Maps V2 API Center Current Location On Screen -


i trying accomplish simple task, seemed pretty straightforward, still not working it's supposed do. using method below, phone zooms in city center, 2km blue location dot is.

public void setupmap() {         mgooglemap.setmylocationenabled(true);          string context = context.location_service;          locationmanager locationmanager = (locationmanager)mcontext.getsystemservice(context);          criteria criteria = new criteria();         string provider = locationmanager.getbestprovider(criteria, true);         location mylocation = locationmanager.getlastknownlocation(provider);          double latitude = mylocation.getlatitude();         double longitude = mylocation.getlongitude();          latlng latlng = new latlng(latitude, longitude);          mgooglemap.movecamera(cameraupdatefactory.newlatlngzoom(latlng, 10));       } 

i have tried set different zoom values, nothing changes much. not sure if should set newlatlngbounds or not, since says right way. seems not getting current location, city's location.

new answer:-

mmap.setmylocationenabled(true);                  location mylocation = mmap.getmylocation();                  if (mylocation != null) {                     mmap.animatecamera(cameraupdatefactory.newlatlngzoom(                             new latlng(mylocation.getlatitude(), mylocation                                     .getlongitude()), 14));                 } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -