summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel Miklós <gabriel.miklos@commsignia.com>2016-02-09 16:09:01 +0100
committerJohn Firebaugh <john.firebaugh@gmail.com>2016-02-12 16:47:24 -0800
commitd742c2d3eb3b8f669f0df9c6e5f6596eaf8fb616 (patch)
tree9e03a237ed093dcaae88be1d266180495211ee84 /src
parent9841f940740d56dca347fe9a8383107c41bcee5e (diff)
downloadqtlocation-mapboxgl-d742c2d3eb3b8f669f0df9c6e5f6596eaf8fb616.tar.gz
[core] Add support for updating point annotations
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/annotation/annotation_manager.cpp10
-rw-r--r--src/mbgl/annotation/annotation_manager.hpp1
-rw-r--r--src/mbgl/map/map.cpp5
3 files changed, 16 insertions, 0 deletions
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 });
}