diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-28 16:03:09 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-28 17:18:38 +0200 |
commit | ad03e42b2890fd430e99e543a40be42f09f47fba (patch) | |
tree | 0644ddaab4f30ac1dc2c59507125cad832b366b2 /src/mbgl/map/map.cpp | |
parent | a0b8f01c1baf640f34c0f46ba22efd399b7a0012 (diff) | |
download | qtlocation-mapboxgl-ad03e42b2890fd430e99e543a40be42f09f47fba.tar.gz |
[core] LayerManager can disable annotations
At the moment, the annotations implementation in the `mapbox-gl-native`
core is creating concrete layer instances apart from `LayerManager/LayerFactory`
code path.
So, annotations must be disabled if the `LayerManager` implementation does
not provide line, fill or symbol layers (those, used by the annotations).
Note: in future, annotations implementation will be moved from the core to the
platform SDK level(see https://github.com/mapbox/mapbox-plugins-android/tree/master/plugin-annotation)
and `LayerManager` won't need to disable it.
Diffstat (limited to 'src/mbgl/map/map.cpp')
-rw-r--r-- | src/mbgl/map/map.cpp | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index c963140652..b8d5186729 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -239,7 +239,9 @@ void Map::setStyle(std::unique_ptr<Style> style) { assert(style); impl->onStyleLoading(); impl->style = std::move(style); - impl->annotationManager.setStyle(*impl->style); + if (LayerManager::annotationsEnabled) { + impl->annotationManager.setStyle(*impl->style); + } } #pragma mark - Transitions @@ -636,32 +638,46 @@ LatLng Map::latLngForPixel(const ScreenCoordinate& pixel) const { #pragma mark - Annotations void Map::addAnnotationImage(std::unique_ptr<style::Image> image) { - impl->annotationManager.addImage(std::move(image)); + if (LayerManager::annotationsEnabled) { + impl->annotationManager.addImage(std::move(image)); + } } void Map::removeAnnotationImage(const std::string& id) { - impl->annotationManager.removeImage(id); + if (LayerManager::annotationsEnabled) { + impl->annotationManager.removeImage(id); + } } double Map::getTopOffsetPixelsForAnnotationImage(const std::string& id) { - return impl->annotationManager.getTopOffsetPixelsForImage(id); + if (LayerManager::annotationsEnabled) { + return impl->annotationManager.getTopOffsetPixelsForImage(id); + } + return 0.0; } AnnotationID Map::addAnnotation(const Annotation& annotation) { - auto result = impl->annotationManager.addAnnotation(annotation); - impl->onUpdate(); - return result; + if (LayerManager::annotationsEnabled) { + auto result = impl->annotationManager.addAnnotation(annotation); + impl->onUpdate(); + return result; + } + return 0; } void Map::updateAnnotation(AnnotationID id, const Annotation& annotation) { - if (impl->annotationManager.updateAnnotation(id, annotation)) { - impl->onUpdate(); + if (LayerManager::annotationsEnabled) { + if (impl->annotationManager.updateAnnotation(id, annotation)) { + impl->onUpdate(); + } } } void Map::removeAnnotation(AnnotationID annotation) { - impl->annotationManager.removeAnnotation(annotation); - impl->onUpdate(); + if (LayerManager::annotationsEnabled) { + impl->annotationManager.removeAnnotation(annotation); + impl->onUpdate(); + } } #pragma mark - Toggles @@ -762,8 +778,9 @@ void Map::Impl::onStyleLoaded() { if (!cameraMutated) { map.jumpTo(style->getDefaultCamera()); } - - annotationManager.onStyleLoaded(); + if (LayerManager::annotationsEnabled) { + annotationManager.onStyleLoaded(); + } observer.onDidFinishLoadingStyle(); } |