2210: Sprites can be removed / updated correctly
This commit is contained in:
committed by
Minh Nguyễn
parent
02a32b55e4
commit
af45d87e54
@@ -2718,7 +2718,7 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration)
|
||||
{
|
||||
// remove sprite
|
||||
NSString *symbolName = [MGLAnnotationSpritePrefix stringByAppendingString:annotationImage.reuseIdentifier];
|
||||
_mbglMap->removeSprite(symbolName.UTF8String);
|
||||
_mbglMap->removeAnnotationIcon(symbolName.UTF8String);
|
||||
[self installAnnotationImage:annotationImage];
|
||||
_mbglMap->update(mbgl::Update::Annotations);
|
||||
}
|
||||
|
||||
@@ -159,6 +159,11 @@ void AnnotationManager::addIcon(const std::string& name, std::shared_ptr<const S
|
||||
spriteStore.setSprite(name, sprite);
|
||||
spriteAtlas.updateDirty();
|
||||
}
|
||||
|
||||
void AnnotationManager::removeIcon(const std::string& name) {
|
||||
spriteStore.removeSprite(name);
|
||||
spriteAtlas.updateDirty();
|
||||
}
|
||||
|
||||
double AnnotationManager::getTopOffsetPixelsForIcon(const std::string& name) {
|
||||
auto sprite = spriteStore.getSprite(name);
|
||||
|
||||
@@ -34,6 +34,7 @@ public:
|
||||
LatLngBounds getBoundsForAnnotations(const AnnotationIDs&) const;
|
||||
|
||||
void addIcon(const std::string& name, std::shared_ptr<const SpriteImage>);
|
||||
void removeIcon(const std::string& name);
|
||||
double getTopOffsetPixelsForIcon(const std::string& name);
|
||||
SpriteAtlas& getSpriteAtlas() { return spriteAtlas; }
|
||||
|
||||
|
||||
@@ -392,7 +392,7 @@ void Map::addAnnotationIcon(const std::string& name, std::shared_ptr<const Sprit
|
||||
}
|
||||
|
||||
void Map::removeAnnotationIcon(const std::string& name) {
|
||||
addAnnotationIcon(name, nullptr);
|
||||
removeAnnotationIcon(name);
|
||||
}
|
||||
|
||||
double Map::getTopOffsetPixelsForAnnotationIcon(const std::string& symbol) {
|
||||
|
||||
@@ -272,6 +272,11 @@ void MapContext::addAnnotationIcon(const std::string& name, std::shared_ptr<cons
|
||||
assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
|
||||
data.getAnnotationManager()->addIcon(name, sprite);
|
||||
}
|
||||
|
||||
void MapContext::removeAnnotationIcon(const std::string& name) {
|
||||
assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
|
||||
data.getAnnotationManager()->removeIcon(name);
|
||||
}
|
||||
|
||||
double MapContext::getTopOffsetPixelsForAnnotationIcon(const std::string& name) {
|
||||
assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
|
||||
@@ -298,7 +303,7 @@ void MapContext::onLowMemory() {
|
||||
style->onLowMemory();
|
||||
asyncInvalidate.send();
|
||||
}
|
||||
|
||||
|
||||
void MapContext::onTileDataChanged() {
|
||||
assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
|
||||
updateFlags |= Update::Repaint;
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
|
||||
// Annotations
|
||||
void addAnnotationIcon(const std::string&, std::shared_ptr<const SpriteImage>);
|
||||
void removeAnnotationIcon(const std::string&);
|
||||
double getTopOffsetPixelsForAnnotationIcon(const std::string&);
|
||||
void updateAnnotations();
|
||||
|
||||
|
||||
@@ -187,8 +187,15 @@ void SpriteAtlas::updateDirty() {
|
||||
// The two names match;
|
||||
Holder& holder = imageIterator->second;
|
||||
holder.texture = spriteIterator->second;
|
||||
copy(holder, imageIterator->first.second);
|
||||
|
||||
if (holder.texture != nullptr)
|
||||
{
|
||||
copy(holder, imageIterator->first.second);
|
||||
}
|
||||
else
|
||||
{
|
||||
images.erase(imageIterator);
|
||||
}
|
||||
|
||||
++imageIterator;
|
||||
// Don't advance the spriteIterator because there might be another sprite with the same
|
||||
// name, but a different wrap value.
|
||||
|
||||
Reference in New Issue
Block a user