Search code examples
androidgoogle-mapsitemizedoverlay

Google Maps Still showing a marker after its removal


ive been writing some app, and got stuck with removing an item from the map, this is a relavant snippet from my code:

protected boolean onTap(final int index) {
    tapped=true;
    AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
    dialog.setTitle("Remove Item");
    dialog.setMessage("Are you sure you want to Remove this Item?");
    dialog.setNegativeButton("No", null);
    dialog.setPositiveButton("Yes", new OnClickListener() {
        @SuppressWarnings("unchecked")
        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            mOverlays.remove(index);
            ItemOverlay.this.populate();
            ItemOverlay.this.setLastFocusedIndex(-1);
            ItemOverlay.this.setFocus(null);
        }
    });
    dialog.show();
    return true;
}

as you can see i removed the item that was tapped, and made sure nothing is at focus, yet the removed item still get drawn, untill user taps on another point of the screen, or scroll the map.

what else should i try?


Solution

  • You should remember to update the mapview:

    mapview.invalidate();