Skip to content

vtkMapMarkerSet::DeleteMarker doesn't delete a marker #114

Closed
@embeddedmz

Description

@embeddedmz
vtkWeakPointer<vtkFeatureLayer> m_layer;
vtkSmartPointer<vtkMapMarkerSet> m_orangeMarkerSet;
std::vector<vtkIdType> m_orangeMarkers; // used to store markers ID in order to delete them later
...
double orange[4] = {1, 0.647059, 0, 1};
// Setup the colors of markers
m_orangeMarkerSet->SetColor(orange);
m_orangeMarkerSet->SetClustering(true);
...
m_layer->AddFeature(m_orangeMarkerSet.GetPointer());

// adding a marker at a particular lat/long
const vtkIdType markerId = m_orangeMarkerSet->AddMarker(latitude, longitude);
m_orangeMarkers.push_back(markerId); // saving its ID to remove it later

DeleteMarker doesn't do its job, the old markers are still there after refreshing the map.

   for (const auto id : m_orangeMarkers)
    {
        m_orangeMarkerSet->DeleteMarker(id);
    }
    m_orangeMarkers.clear();
    m_orangeMarkerSet->Update();
//....
// refreshing vtkMap... the map is showing old and new markers !

The solution I found, is to recreate a new vtkMapMarkerSet :

m_layer->RemoveFeature(m_orangeMarkerSet.GetPointer());
m_orangeMarkerSet = vtkSmartPointer<vtkMapMarkerSet>::New();
m_layer->AddFeature(m_orangeMarkerSet.GetPointer());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions