Denn
Denn

Reputation: 113

How would I make my google maps app start with zoom on my current location

How would I make my google maps app on android start with zoom on my current location without pressing or doing anything?

edit. problem solved

Criteria cri= new Criteria();
    String bbb = locationmanager.getBestProvider(cri, true);
    Location myLocation = locationmanager.getLastKnownLocation(bbb);

    double lat= myLocation.getLatitude();
    double long = myLocation.getLongitude();
    LatLng ll = new LatLng(lat, long);

    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(ll, 20));

Upvotes: 3

Views: 6427

Answers (2)

Denn
Denn

Reputation: 113

Problem solved

Criteria cri= new Criteria();
String bbb = locationmanager.getBestProvider(cri, true);
Location myLocation = locationmanager.getLastKnownLocation(bbb);

double lat= myLocation.getLatitude();
double long = myLocation.getLongitude();
LatLng ll = new LatLng(lat, long);

mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(ll, 20));

Upvotes: 4

Rachel Gallen
Rachel Gallen

Reputation: 28563

you could do it this way

CameraUpdate center= CameraUpdateFactory.newLatLng(new LatLng(lat,long));
CameraUpdate zoom=CameraUpdateFactory.zoomTo(5);

map.moveCamera(center);
map.animateCamera(zoom);

Upvotes: 0

Related Questions