我正在使用谷歌地图 api v2。我在地图上长按放置标记,当拖动到我在地图左侧设置的 android“ic_delete”可绘制边界时,我想删除它们(就像我们在启动器中删除应用程序时所做的那样)。帮助 !
这是我的代码:
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
markers = new ArrayList<Marker>();
boolean mReturn = false;
if (map != null) {
map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
mapSettings = map.getUiSettings();
mapSettings.setCompassEnabled(true);
mapSettings.setRotateGesturesEnabled(true);
mapSettings.setZoomControlsEnabled(true);
map.setMyLocationEnabled(true);
map.setOnMapLongClickListener(this);
map.setOnMarkerDragListener(this);
mReturn = true;
}
@Override
public void onMapLongClick(LatLng position) {
// TODO Auto-generated method stub
final LatLng point = position;
Marker marker = map.addMarker(createMarkerOptions("test", "snippet", point, true));
markers.add(marker);
// ...
}
@Override
public void onMarkerDrag(Marker marker) {
// TODO Auto-generated method stub
}
@Override
public void onMarkerDragEnd(Marker marker) {
// TODO Auto-generated method stub
ImageView deleteMarker = (ImageView) findViewById(R.id.deleteMarker);
deleteMarker.setVisibility(View.GONE);
// I want to delete that "marker" if dragged over the "deleteMarker" imageview
}
@Override
public void onMarkerDragStart(Marker marker) {
// TODO Auto-generated method stub
findViewById(R.id.deleteMarker).setVisibility(View.VISIBLE);
}