summaryrefslogtreecommitdiff
path: root/platform/osx/app/MapDocument.m
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-06-05 00:37:42 -0700
committerMinh Nguyễn <mxn@1ec5.org>2016-06-06 15:40:52 -0700
commit62149410fa49b7ceb6ae3491a1fcde506e13669b (patch)
tree74edc8d1b6bc854a47c4c497c21cd65381b48264 /platform/osx/app/MapDocument.m
parent126f388fdbb3b9572aa1ccafaf27967da385ccdd (diff)
downloadqtlocation-mapboxgl-62149410fa49b7ceb6ae3491a1fcde506e13669b.tar.gz
[ios, osx] Ignore multipoints
Ignore multipoints (as opposed to polylines and polygons) when adding annotations, just like we ignore multipolylines, multipolygons, and shape collections. In osxapp, break multipoint features into points before adding them as annotations.
Diffstat (limited to 'platform/osx/app/MapDocument.m')
-rw-r--r--platform/osx/app/MapDocument.m13
1 files changed, 12 insertions, 1 deletions
diff --git a/platform/osx/app/MapDocument.m b/platform/osx/app/MapDocument.m
index 4274126747..e9f3b99592 100644
--- a/platform/osx/app/MapDocument.m
+++ b/platform/osx/app/MapDocument.m
@@ -18,7 +18,18 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio
NSMutableArray *flattenedShapes = [NSMutableArray arrayWithCapacity:shapes.count];
for (id <MGLAnnotation> shape in shapes) {
NSArray *subshapes;
- if ([shape isKindOfClass:[MGLMultiPolyline class]]) {
+ // Flatten multipoints but not polylines or polygons.
+ if ([shape isMemberOfClass:[MGLMultiPoint class]]) {
+ NSUInteger pointCount = [(MGLMultiPoint *)shape pointCount];
+ CLLocationCoordinate2D *coordinates = [(MGLMultiPoint *)shape coordinates];
+ NSMutableArray *pointAnnotations = [NSMutableArray arrayWithCapacity:pointCount];
+ for (NSUInteger i = 0; i < pointCount; i++) {
+ MGLPointAnnotation *pointAnnotation = [[MGLPointAnnotation alloc] init];
+ pointAnnotation.coordinate = coordinates[i];
+ [pointAnnotations addObject:pointAnnotation];
+ }
+ subshapes = pointAnnotations;
+ } else if ([shape isKindOfClass:[MGLMultiPolyline class]]) {
subshapes = [(MGLMultiPolyline *)shape polylines];
} else if ([shape isKindOfClass:[MGLMultiPolygon class]]) {
subshapes = [(MGLMultiPolygon *)shape polygons];