[core] Use a separate atlas and store for annotation sprites
Fixes #1488
This commit is contained in:
committed by
John Firebaugh
parent
58886842bc
commit
e1091db45e
@@ -10,7 +10,11 @@ namespace mbgl {
|
||||
const std::string AnnotationManager::SourceID = "com.mapbox.annotations";
|
||||
const std::string AnnotationManager::PointLayerID = "com.mapbox.annotations.points";
|
||||
|
||||
AnnotationManager::AnnotationManager() = default;
|
||||
AnnotationManager::AnnotationManager(float pixelRatio)
|
||||
: spriteStore(pixelRatio),
|
||||
spriteAtlas(512, 512, pixelRatio, spriteStore) {
|
||||
}
|
||||
|
||||
AnnotationManager::~AnnotationManager() = default;
|
||||
|
||||
AnnotationIDs
|
||||
@@ -122,6 +126,7 @@ void AnnotationManager::updateStyle(Style& style) {
|
||||
layer->sourceLayer = PointLayerID;
|
||||
layer->layout.icon.image = std::string("{sprite}");
|
||||
layer->layout.icon.allowOverlap = true;
|
||||
layer->spriteAtlas = &spriteAtlas;
|
||||
|
||||
style.addLayer(std::move(layer));
|
||||
}
|
||||
@@ -152,4 +157,14 @@ void AnnotationManager::removeTileMonitor(AnnotationTileMonitor& monitor) {
|
||||
monitors.erase(&monitor);
|
||||
}
|
||||
|
||||
void AnnotationManager::setSprite(const std::string& name, std::shared_ptr<const SpriteImage> sprite) {
|
||||
spriteStore.setSprite(name, sprite);
|
||||
spriteAtlas.updateDirty();
|
||||
}
|
||||
|
||||
double AnnotationManager::getTopOffsetPixelsForAnnotationSymbol(const std::string& name) {
|
||||
auto sprite = spriteStore.getSprite(name);
|
||||
return sprite ? -sprite->height / 2 : 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user