I want to confirm one thing in Google maps that is why Google maps always showing South Africa as default location... Can't we change Australia as Default one. If GPRS enabled I can trace the current location if not i want to show Sidney in Australia . Is it possible ???
-
Possible duplicate of How do I set default location and Zoom level for google map api v2?– mbelskyDec 7, 2015 at 13:03
1 Answer
Google Maps will show the user's current location if you ask for it.
You can also manually set the "default" location by moving the map to give a particular location.
CameraUpdate point = CameraUpdateFactory.newLatLng(new LatLng(53, 2));
// moves camera to coordinates
map.moveCamera(point);
// animates camera to coordinates
map.animateCamera(point);
Best to use moveCamera
rather than animateCamera
for the default position.
The reason you are seeing South Africa is because the map defaults to (0,0)
when initialised without any extra data, so it doesn't have somewhere to point to other than it's default. (0,0)
happens to be near Africa.
Use moveCamera
before the map is shown to the user and it will be showing wherever you have selected by default.
-
thanks for reply... but app is crashing at moveCamera with java.lang.NullPointerException– AndroidFeb 3, 2014 at 15:07
-
Well have you initialised your GoogleMap instance, and is your CameraUpdate instance initialised as well? You have to initialise things before you can use them. Have you gone through the tutorial at developers.google.com/maps/documentation/android/map and used the code to init from the Verify Map availability section? Feb 3, 2014 at 15:09