set GoogleMap initial location (from gps)

436 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 best solutions below

2
On

you can use this way also:

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