Wednesday 18 September 2013

SupportMapFragment overriding setOnMyLocationChangeListener

SupportMapFragment overriding setOnMyLocationChangeListener

I'm trying to override setOnMyLocationChangeListener on a
SupportMapFragment using this
map.setOnMyLocationChangeListener(new
GoogleMap.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange(Location location) {
LatLng you = new LatLng(location.getLatitude(),
location.getLongitude());
float distanceTo =
location.distanceTo(venueLocation);
String miles = metersToMiles(distanceTo);
dist.setText(miles + " miles away");
LatLngBounds.Builder builder = new
LatLngBounds.Builder();
map.clear();
map.addMarker(new MarkerOptions()
.position(venue)
.title(centerName)
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.fu_map_marker)));
map.addMarker(new MarkerOptions()
.title("You are here")
.position(you));
builder.include(venue);
builder.include(you);
LatLngBounds bounds = builder.build();
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds,
75));
}
});
Which kind of works, however, before the camera animates using the
LatLngBounds, it automatically zooms to the users location and adds a blue
dot. Is there anyway I can disable this?

No comments:

Post a Comment