OpenGeoscience / vtkMap

vtkMap
24 stars 13 forks source link

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

Closed embeddedmz closed 5 years ago

embeddedmz commented 5 years ago
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());
embeddedmz commented 5 years ago

Fixed here : https://github.com/OpenGeoscience/vtkMap/pull/116

embeddedmz commented 5 years ago

Fixed here : https://github.com/OpenGeoscience/vtkMap/pull/116