要将标记放在当前位置,我使用onLocationChange。但如果设备移动超过10米我想删除该标记,我不想要新的标记来。请有人帮忙。 我把标记放在当前位置,如下所示: 这是我的代码
@Override
public void onLocationChanged(Location location) {
mLastLocation = location;
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();
}
//Place current location marker
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Current Position").snippet(act);
markerOptions.icon(BitmapDescriptorFactory.fromBitmap(getBitmap(imagePath,1)));
mCurrLocationMarker = mMap.addMarker(markerOptions);
mMap.setOnMarkerClickListener(this);
//move map camera
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(initialZoom));
//stop location updates
if (mGoogleApiClient != null) {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
}
}