Reputation: 4948
I have a Location Manager Class that im using for location updates.
I also have a small Map Fragment in my activity that i want to center on the location that my Manager is spitting out.
I have my map set to enable myLocation so that i can see the blue dot illustrating where i am.
GREAT..
now i am also updating the camera for the map on location updates to the lat and lon i am getting from my locationManager but the map is not centering on the blue dot. which makes me think that the map and my location manager have a different idea of where i am.
I looked into mMap.setLocationSource inhopes that i could tell my map to use my location manager as the source but I am getting very little in the way of documentation as to what the class LocationSource even is. can someone illustrate to me how i can make my map use my location manager as it's source?>
Upvotes: 1
Views: 1577
Reputation: 22232
LocationSource
is not a class, but an interface with two functions.
You need to create a class, that implements it and:
In activate
you are passed LocationSource.OnLocationChangedListener listener
, for which you need to keep a reference.
In this function you would also normally start requesting locations from LocationManager
. When you get a Location
from LocationManager
in your LocationListener
, you need to forward this to LocationSource.OnLocationChangedListener listener
.
In deactivate
you simply stop requesting locations.
For an example look into:
ANDROID_SDK\extras\google\google_play_services\samples\maps\src\com\example\mapdemo\LocationSourceDemoActivity.java
Upvotes: 2
Reputation: 73751
in your map fragment just implement OnMyLocationChangeListener
then set map.setOnMyLocationChangeListener(this)
for the mapfragment then anytime onMyLocationChange
gets called update the camera to the position given because when that gets called the blue dot moves.
your location manager and the maps location are 2 different things
Upvotes: 0