[core] Add support for updating point annotations

This commit is contained in:
Gabriel Miklós
2016-02-09 16:09:01 +01:00
committed by John Firebaugh
parent 9841f94074
commit d742c2d3eb
4 changed files with 18 additions and 0 deletions

View File

@@ -161,6 +161,8 @@ public:
AnnotationID addShapeAnnotation(const ShapeAnnotation&);
AnnotationIDs addShapeAnnotations(const std::vector<ShapeAnnotation>&);
void updatePointAnnotation(AnnotationID, const PointAnnotation&);
void removeAnnotation(AnnotationID);
void removeAnnotations(const AnnotationIDs&);

View File

@@ -48,6 +48,16 @@ AnnotationManager::addShapeAnnotations(const std::vector<ShapeAnnotation>& shape
return annotationIDs;
}
void AnnotationManager::updatePointAnnotation(const AnnotationID& id, const PointAnnotation& point, const uint8_t) {
auto foundAnnotation = pointAnnotations.find(id);
if (foundAnnotation != pointAnnotations.end()) {
auto updatedAnnotation = std::make_shared<PointAnnotationImpl>(id, point);
pointTree.remove(foundAnnotation->second);
pointTree.insert(updatedAnnotation);
foundAnnotation->second = updatedAnnotation;
}
}
void AnnotationManager::removeAnnotations(const AnnotationIDs& ids) {
for (const auto& id : ids) {
if (pointAnnotations.find(id) != pointAnnotations.end()) {

View File

@@ -28,6 +28,7 @@ public:
AnnotationIDs addPointAnnotations(const std::vector<PointAnnotation>&, const uint8_t maxZoom);
AnnotationIDs addShapeAnnotations(const std::vector<ShapeAnnotation>&, const uint8_t maxZoom);
void updatePointAnnotation(const AnnotationID&, const PointAnnotation&, const uint8_t maxZoom);
void removeAnnotations(const AnnotationIDs&);
AnnotationIDs getPointAnnotationsInBounds(const LatLngBounds&) const;

View File

@@ -452,6 +452,11 @@ AnnotationIDs Map::addShapeAnnotations(const std::vector<ShapeAnnotation>& annot
return result;
}
void Map::updatePointAnnotation(AnnotationID annotationId, const PointAnnotation& annotation) {
data->getAnnotationManager()->updatePointAnnotation(annotationId, annotation, getMaxZoom());
update(Update::Annotations);
}
void Map::removeAnnotation(AnnotationID annotation) {
removeAnnotations({ annotation });
}