diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-04-19 12:36:17 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-04-19 14:24:59 -0700 |
commit | 3976448479d85cab2f0554995acf92fa0403deda (patch) | |
tree | 0008b8445a6e4073de1096d8563b444d318324c7 /platform | |
parent | 8a4c2d4b0e9e39f0f183bc1b9aa549b9d65309bb (diff) | |
download | qtlocation-mapboxgl-3976448479d85cab2f0554995acf92fa0403deda.tar.gz |
[ios] Refactored annotation image updating
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 44e3c37ac4..38e0070571 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -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 ?: "" }); } } } |