set GoogleMap initial location (from gps)

415 views Asked by At

I have a GoogleMap in my App. When my app starts, it finds out the current position via gps and changes the map to this position. If my app was already started before and the initial position was changed, then I want to keep this user selected position and donĀ“t want my map to change again to the current gps-position.

Is there a better way than this?

private final CameraPosition cameraPositionNull = new CameraPosition(new LatLng(0.0,0.0),2f, 0f,0f);
if (map.getCameraPosition().equals(cameraPositionNull)) {
    ...
}

Greetings, masrlinu

1

There are 1 answers

2
Shivang Trivedi On

you can use this way also:

   mapView.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), 0));