我正在尝试使用此覆盖 SupportMapFragment 上的 setOnMyLocationChangeListener
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));
}
});
然而,哪种方法有效,在相机使用 LatLngBounds 进行动画处理之前,它会自动缩放到用户位置并添加一个蓝点。无论如何我可以禁用它吗?