/** * Removes a Feature from the map if its geometry property is not null * * @param feature feature to remove from map */ protected void removeFeature(Feature feature) { // Check if given feature is stored if (mFeatures.containsKey(feature)) { removeFromMap(mFeatures.remove(feature)); } }
/** * Given a Marker, Polyline, Polygon or an array of these and removes it from the map * * @param mapObject map object or array of map objects to remove from the map */ public static void removeFromMap(Object mapObject) { if (mapObject instanceof Marker) { ((Marker) mapObject).remove(); } else if (mapObject instanceof Polyline) { ((Polyline) mapObject).remove(); } else if (mapObject instanceof Polygon) { ((Polygon) mapObject).remove(); } else if (mapObject instanceof ArrayList) { for (Object mapObjectElement : (ArrayList) mapObject) { removeFromMap(mapObjectElement); } } }
if (mFeatures.containsKey(feature)) { removeFromMap(mFeatures.get(feature));