Wednesday, 21 August 2013

GoogleMaps v2 - How to know when blue dot is diplayed

GoogleMaps v2 - How to know when blue dot is diplayed

I want to know if is it possible to be aware when GoogleMaps
provides/displays the blue dot which represents the current location of
the user.
In fact, i'd like to display a progress bar until that blue dot is
provided, that's why I have to know when the latter is available.
I'm currently using the LocationClient class to get user's location after
calling the connect() method but I actually can't determine when it gets a
good location fix (represented by the blue dot).
I also want to zoom in the location found when it is available, that's why
i'm using this callback function which sometimes zoom in a wrong location
if a fix hasn't be found yet.

private LocationResult locDepart = new LocationResult() {
@Override
public void gotLocation(Location location) {
Location loc = location;
if (loc != null) {
LatLng coordonnees = new LatLng(loc.getLatitude(),
loc.getLongitude());
final CameraPosition cameraPosition = new
CameraPosition.Builder()
.target(coordonnees) // Sets the center of the map to
Mountain View
.zoom(18) // Sets the zoom
.bearing(90) // Sets the orientation of the
camera to east
.tilt(10) // Sets the tilt of the camera to
30 degrees
.build(); // Creates a CameraPosition from
the builder
runOnUiThread(new Runnable () {
@Override
public void run() {
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
});
}
mHandler.sendEmptyMessage(0);
}
};
Thanks for your answers.

No comments:

Post a Comment