How to get the users location and zoom in upon loading maps Android V2 -
i can display map , have button show on map, when tap it want do. in code have this:
googlemap.setmylocationenabled(true); googlemap.getmylocation();
is there way automatically upon loading map, without having tap zoom location button?
i researched , found examples on getting users location, examples found didn't wanted, not sure code v2 maps. certainly there must easy, code minimal way now?
i read through this post on stackoverflow, have no thought code:
googlemap.getcameraposition().target
target takes location think?
any assistance appreciated!
thanks!
i solved using next code:
lm =(locationmanager) getsystemservice(context.location_service); criteria crit = new criteria(); towers = lm.getbestprovider(crit, false); location location = lm.getlastknownlocation(towers); if(location != null){ double glat = location.getlatitude(); double glon = location.getlongitude(); }
then setting map up:
cameraposition cp = new cameraposition.builder() .target(new latlng(glat, glon)) .zoom(15) .build(); googlemap.animatecamera(cameraupdatefactory.newcameraposition(cp));
this users location, , when map loads, automatically zooms location, should see bluish dot sit!
android android-maps-v2
No comments:
Post a Comment