[core] Remove shape layers from the style (fixes #2405)

This commit is contained in:
John Firebaugh
2015-10-19 12:13:15 -07:00
parent c5b95032a5
commit 00a1c2343a
6 changed files with 58 additions and 13 deletions

View File

@@ -51,7 +51,7 @@ void AnnotationManager::removeAnnotations(const AnnotationIDs& ids) {
pointTree.remove(pointAnnotations.at(id));
pointAnnotations.erase(id);
} else if (shapeAnnotations.find(id) != shapeAnnotations.end()) {
// TODO: remove style layer
obsoleteShapeAnnotationLayers.push_back(shapeAnnotations.at(id)->layerID);
shapeAnnotations.erase(id);
}
}
@@ -132,6 +132,11 @@ void AnnotationManager::updateStyle(Style& style) {
shape.second->updateStyle(style);
}
for (const auto& layer : obsoleteShapeAnnotationLayers) {
style.removeLayer(layer);
}
obsoleteShapeAnnotationLayers.clear();
style.getSource(SourceID)->invalidateTiles();
}

View File

@@ -40,6 +40,7 @@ private:
PointAnnotationImpl::Tree pointTree;
PointAnnotationImpl::Map pointAnnotations;
ShapeAnnotationImpl::Map shapeAnnotations;
std::vector<std::string> obsoleteShapeAnnotationLayers;
};
}

View File

@@ -24,10 +24,11 @@ public:
void updateStyle(Style&);
void updateTile(const TileID&, AnnotationTile&);
private:
const AnnotationID id;
const std::string layerID;
const ShapeAnnotation shape;
private:
mapbox::util::geojsonvt::GeoJSONVT shapeTiler;
};