[ios] Refactored annotation image updating

This commit is contained in:
Minh Nguyễn
2016-04-19 12:36:17 -07:00
committed by Minh Nguyễn
parent 8a4c2d4b0e
commit 3976448479

View File

@@ -3098,14 +3098,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
if ([iconIdentifier isEqualToString:fallbackIconIdentifier])
{
// Update any annotations associated with the annotation image.
for (auto &pair : _annotationContextsByAnnotationTag)
{
if ([pair.second.imageReuseIdentifier isEqualToString:reuseIdentifier])
{
const mbgl::LatLng latLng = MGLLatLngFromLocationCoordinate2D(pair.second.annotation.coordinate);
_mbglMap->updatePointAnnotation(pair.first, { latLng, updatedIconIdentifier.UTF8String ?: "" });
}
}
[self applyIconIdentifier:updatedIconIdentifier toAnnotationsWithImageReuseIdentifier:reuseIdentifier];
}
}
else
@@ -3118,13 +3111,18 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration)
}
// Update any annotations associated with the annotation image.
for (auto &pair : _annotationContextsByAnnotationTag)
[self applyIconIdentifier:fallbackIconIdentifier toAnnotationsWithImageReuseIdentifier:reuseIdentifier];
}
}
- (void)applyIconIdentifier:(NSString *)iconIdentifier toAnnotationsWithImageReuseIdentifier:(NSString *)reuseIdentifier
{
for (auto &pair : _annotationContextsByAnnotationTag)
{
if ([pair.second.imageReuseIdentifier isEqualToString:reuseIdentifier])
{
if ([pair.second.imageReuseIdentifier isEqualToString:reuseIdentifier])
{
const mbgl::LatLng latLng = MGLLatLngFromLocationCoordinate2D(pair.second.annotation.coordinate);
_mbglMap->updatePointAnnotation(pair.first, { latLng, fallbackIconIdentifier.UTF8String ?: "" });
}
const mbgl::LatLng latLng = MGLLatLngFromLocationCoordinate2D(pair.second.annotation.coordinate);
_mbglMap->updatePointAnnotation(pair.first, { latLng, iconIdentifier.UTF8String ?: "" });
}
}
}