Using the MapView in android, how can I set a default location, so that everytime I load up this application, it automatically centers/zooms location in on London?
Look to the top-left corner of the map, and click the three horizontal menu bars. From the options, select Your places. Next, click Home. Type the name of the location you want to set as your home address in the address field.
Click the "Gear" icon and choose "Search Settings". Click "Location". Put in as detailed a location as you want. (A full address, a city and state, just a state, a country, etc.)
Firstly, get the controller for the given map:
MapController myMapController = myMapView.getController();
and then call:
myMapController.setCenter(new GeoPoint())
This will set the center of the map on the given GeoPoint.
See docs for MapView and MapController for more info
For new Google Maps API you need to do this:
mapFragment.getMapAsync(this::setUpMaps);
And inside setUpMaps(GoogleMap googleMap)
you should move camera to your default location:
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, zoom));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With