我正在使用google map api v2。我將地圖上的標記放在地圖上長按,當我拖拽到位於地圖左側的android「ic_delete」可繪製邊界上時(我們在啓動器中刪除應用程序時完成),我想刪除它們。幫幫我 !刪除地圖標記,同時拖動ImageView邊界
該處是我的代碼:
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);
}
這取決於您是否使用mapview,mapfragment或supportmapfragment。發佈你的代碼,這樣就不會受到影響。 – yams
@MarkBasler我正在使用mapfragment。我已經發布了代碼! –