diff --git a/platform/osx/app/AppDelegate.m b/platform/osx/app/AppDelegate.m index d788a0a27..dd4562090 100644 --- a/platform/osx/app/AppDelegate.m +++ b/platform/osx/app/AppDelegate.m @@ -238,6 +238,39 @@ static NSString * const MGLDroppedPinAnnotationImageIdentifier = @"dropped"; _randomizesCursorsOnDroppedPins = !_randomizesCursorsOnDroppedPins; } +- (IBAction)dropManyPins:(id)sender { + [self.mapView removeAnnotations:self.mapView.annotations]; + + NSRect bounds = self.mapView.bounds; + NSMutableArray *annotations = [NSMutableArray array]; + for (CGFloat x = NSMinX(bounds); x < NSMaxX(bounds); x += arc4random_uniform(50)) { + for (CGFloat y = NSMaxY(bounds); y >= NSMinY(bounds); y -= arc4random_uniform(100)) { + [annotations addObject:[self pinAtPoint:NSMakePoint(x, y)]]; + } + } + + [NSTimer scheduledTimerWithTimeInterval:1/60 + target:self + selector:@selector(dropOneOfManyPins:) + userInfo:annotations + repeats:YES]; +} + +- (void)dropOneOfManyPins:(NSTimer *)timer { + NSMutableArray *annotations = timer.userInfo; + NSUInteger numberOfAnnotationsToAdd = 50; + if (annotations.count < numberOfAnnotationsToAdd) { + numberOfAnnotationsToAdd = annotations.count; + } + NSArray *annotationsToAdd = [annotations subarrayWithRange: + NSMakeRange(0, numberOfAnnotationsToAdd)]; + [self.mapView addAnnotations:annotationsToAdd]; + [annotations removeObjectsInRange:NSMakeRange(0, numberOfAnnotationsToAdd)]; + if (!annotations.count) { + [timer invalidate]; + } +} + #pragma mark Help methods - (IBAction)showShortcuts:(id)sender { @@ -282,6 +315,12 @@ static NSString * const MGLDroppedPinAnnotationImageIdentifier = @"dropped"; } - (void)dropPinAtPoint:(NSPoint)point { + DroppedPinAnnotation *annotation = [self pinAtPoint:point]; + [self.mapView addAnnotation:annotation]; + [self.mapView selectAnnotation:annotation animated:YES]; +} + +- (DroppedPinAnnotation *)pinAtPoint:(NSPoint)point { DroppedPinAnnotation *annotation = [[DroppedPinAnnotation alloc] init]; annotation.coordinate = [self.mapView convertPoint:point toCoordinateFromView:self.mapView]; annotation.title = @"Dropped Pin"; @@ -290,8 +329,7 @@ static NSString * const MGLDroppedPinAnnotationImageIdentifier = @"dropped"; NSString *formattedNumber = [_spellOutNumberFormatter stringFromNumber:@(++_droppedPinCounter)]; annotation.toolTip = formattedNumber; } - [self.mapView addAnnotation:annotation]; - [self.mapView selectAnnotation:annotation animated:YES]; + return annotation; } - (IBAction)removePin:(NSMenuItem *)sender { @@ -389,6 +427,9 @@ static NSString * const MGLDroppedPinAnnotationImageIdentifier = @"dropped"; menuItem.title = isRandom ? @"Use Default Cursor for Dropped Pins" : @"Use Random Cursors for Dropped Pins"; return _showsToolTipsOnDroppedPins; } + if (menuItem.action == @selector(dropManyPins:)) { + return YES; + } if (menuItem.action == @selector(showShortcuts:)) { return YES; } diff --git a/platform/osx/app/MainMenu.xib b/platform/osx/app/MainMenu.xib index bc476d276..56b35dbbf 100644 --- a/platform/osx/app/MainMenu.xib +++ b/platform/osx/app/MainMenu.xib @@ -469,6 +469,13 @@ + + + + + + +