diff options
author | Gabriel Miklós <gabriel.miklos@commsignia.com> | 2016-02-09 16:09:01 +0100 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-12 16:47:24 -0800 |
commit | d742c2d3eb3b8f669f0df9c6e5f6596eaf8fb616 (patch) | |
tree | 9e03a237ed093dcaae88be1d266180495211ee84 | |
parent | 9841f940740d56dca347fe9a8383107c41bcee5e (diff) | |
download | qtlocation-mapboxgl-d742c2d3eb3b8f669f0df9c6e5f6596eaf8fb616.tar.gz |
[core] Add support for updating point annotations
-rw-r--r-- | include/mbgl/map/map.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/annotation/annotation_manager.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/annotation/annotation_manager.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/map/map.cpp | 5 |
4 files changed, 18 insertions, 0 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 3a85030169..8c27b1756a 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -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&); diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index 52f8b08ad3..5f5feb456a 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -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()) { diff --git a/src/mbgl/annotation/annotation_manager.hpp b/src/mbgl/annotation/annotation_manager.hpp index 163c7129c7..11860047c2 100644 --- a/src/mbgl/annotation/annotation_manager.hpp +++ b/src/mbgl/annotation/annotation_manager.hpp @@ -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; diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 2df86a8f1c..cfbdbafb6e 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -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 }); } |