From 5f9e675ee0635d586ebe313702c270b48ea39159 Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Mon, 6 Jul 2015 18:41:37 -0700 Subject: [PATCH] stub annotation symbol cleanup --- platform/ios/MGLMapView.mm | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index fb0705ef0..e0a5407f3 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -1977,12 +1977,16 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) std::vector annotationIDsToRemove; annotationIDsToRemove.reserve(annotations.count); + NSMutableSet *affectedSymbols = [NSMutableSet set]; + for (id annotation in annotations) { assert([annotation conformsToProtocol:@protocol(MGLAnnotation)]); - annotationIDsToRemove.push_back([[[self.annotationIDsByAnnotation objectForKey:annotation] - objectForKey:MGLAnnotationIDKey] unsignedIntValue]); + NSDictionary *infoDictionary = [self.annotationIDsByAnnotation objectForKey:annotation]; + annotationIDsToRemove.push_back([[infoDictionary objectForKey:MGLAnnotationIDKey] unsignedIntValue]); + [affectedSymbols addObject:[infoDictionary objectForKey:MGLAnnotationSymbolKey]]; + [self.annotationIDsByAnnotation removeObjectForKey:annotation]; if (annotation == self.selectedAnnotation) @@ -1992,6 +1996,22 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng) } _mbglMap->removeAnnotations(annotationIDsToRemove); + +// NSArray *symbolsInUse = (self.annotationIDsByAnnotation.count ? +// [self.annotationIDsByAnnotation valueForKey:MGLAnnotationSymbolKey] : +// @[]); +// NSSet *uniqueSymbolsInUse = [NSSet setWithArray:symbolsInUse]; +// +// for (NSString *symbol in affectedSymbols) +// { +// if ([symbol length] && ! [uniqueSymbolsInUse containsObject:symbol]) +// { +// std::string sprite([symbol UTF8String]); +// _mbglMap->removeSprite(sprite); +// +// NSLog(@"cleaned up sprite %s", sprite.c_str()); +// } +// } } - (MGLAnnotationImage *)dequeueReusableAnnotationImageWithIdentifier:(NSString *)identifier