diff options
Diffstat (limited to 'platform/macos')
19 files changed, 255 insertions, 255 deletions
diff --git a/platform/macos/app/AppDelegate.m b/platform/macos/app/AppDelegate.m index 44f87092c9..5b848cc79b 100644 --- a/platform/macos/app/AppDelegate.m +++ b/platform/macos/app/AppDelegate.m @@ -20,10 +20,10 @@ NSString * const MGLLastMapDebugMaskDefaultsKey = @"MGLLastMapDebugMask"; switch (self.state) { case MGLOfflinePackStateComplete: return [NSImage imageNamed:@"NSMenuOnStateTemplate"]; - + case MGLOfflinePackStateActive: return [NSImage imageNamed:@"NSFollowLinkFreestandingTemplate"]; - + default: return nil; } @@ -104,7 +104,7 @@ NSString * const MGLLastMapDebugMaskDefaultsKey = @"MGLLastMapDebugMask"; andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; - + if (![[NSUserDefaults standardUserDefaults] boolForKey:@"NSQuitAlwaysKeepsWindows"]) { NSData *cameraData = [[NSUserDefaults standardUserDefaults] objectForKey:MGLLastMapCameraDefaultsKey]; if (cameraData) { @@ -130,7 +130,7 @@ NSString * const MGLLastMapDebugMaskDefaultsKey = @"MGLLastMapDebugMask"; [alert runModal]; [self showPreferences:nil]; } - + [self.offlinePacksArrayController bind:@"content" toObject:[MGLOfflineStorage sharedOfflineStorage] withKeyPath:@"packs" options:nil]; } @@ -148,7 +148,7 @@ NSString * const MGLLastMapDebugMaskDefaultsKey = @"MGLLastMapDebugMask"; [[NSUserDefaults standardUserDefaults] setInteger:mapView.debugMask forKey:MGLLastMapDebugMaskDefaultsKey]; } } - + [self.offlinePacksArrayController unbind:@"content"]; } @@ -164,16 +164,16 @@ NSString * const MGLLastMapDebugMaskDefaultsKey = @"MGLLastMapDebugMask"; params[parts[0]] = [parts[1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; } } - + MGLMapCamera *camera = [MGLMapCamera camera]; NSString *zoomLevelString = params[@"zoom"]; self.pendingZoomLevel = zoomLevelString.length ? zoomLevelString.doubleValue : -1; - + NSString *directionString = params[@"bearing"]; if (directionString.length) { camera.heading = directionString.doubleValue; } - + NSString *centerString = params[@"center"]; if (centerString) { NSArray *coordinateValues = [centerString componentsSeparatedByString:@","]; @@ -182,12 +182,12 @@ NSString * const MGLLastMapDebugMaskDefaultsKey = @"MGLLastMapDebugMask"; [coordinateValues[1] doubleValue]); } } - + NSString *pitchString = params[@"pitch"]; if (pitchString.length) { camera.pitch = pitchString.doubleValue; } - + self.pendingCamera = camera; [[NSDocumentController sharedDocumentController] openUntitledDocumentAndDisplay:YES error:NULL]; } @@ -196,7 +196,7 @@ NSString * const MGLLastMapDebugMaskDefaultsKey = @"MGLLastMapDebugMask"; - (IBAction)showOfflinePacksPanel:(id)sender { [self.offlinePacksPanel makeKeyAndOrderFront:sender]; - + for (MGLOfflinePack *pack in self.offlinePacksArrayController.arrangedObjects) { [pack requestProgress]; } @@ -226,15 +226,15 @@ NSString * const MGLLastMapDebugMaskDefaultsKey = @"MGLLastMapDebugMask"; } break; } - + case MGLOfflinePackStateInactive: [pack resume]; break; - + case MGLOfflinePackStateActive: [pack suspend]; break; - + default: break; } diff --git a/platform/macos/app/DroppedPinAnnotation.m b/platform/macos/app/DroppedPinAnnotation.m index 5b19fd7401..d7bd4068dc 100644 --- a/platform/macos/app/DroppedPinAnnotation.m +++ b/platform/macos/app/DroppedPinAnnotation.m @@ -11,7 +11,7 @@ static MGLCoordinateFormatter *DroppedPinCoordinateFormatter; NSTimer *_timer; NSTimeInterval _priorShownTimeInterval; NSDate *_dateShown; - + NSValueTransformer *_timeIntervalTransformer; } diff --git a/platform/macos/app/LimeGreenStyleLayer.m b/platform/macos/app/LimeGreenStyleLayer.m index 0d2e642db9..40c336cd98 100644 --- a/platform/macos/app/LimeGreenStyleLayer.m +++ b/platform/macos/app/LimeGreenStyleLayer.m @@ -14,11 +14,11 @@ - (void)didMoveToMapView:(MGLMapView *)mapView { static const GLchar *vertexShaderSource = "attribute vec2 a_pos; void main() { gl_Position = vec4(a_pos, 0, 1); }"; static const GLchar *fragmentShaderSource = "void main() { gl_FragColor = vec4(0, 1, 0, 1); }"; - + _program = glCreateProgram(); _vertexShader = glCreateShader(GL_VERTEX_SHADER); _fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); - + glShaderSource(_vertexShader, 1, &vertexShaderSource, NULL); glCompileShader(_vertexShader); glAttachShader(_program, _vertexShader); @@ -27,7 +27,7 @@ glAttachShader(_program, _fragmentShader); glLinkProgram(_program); _aPos = glGetAttribLocation(_program, "a_pos"); - + GLfloat background[] = { -1,-1, 1,-1, -1,1, 1,1 }; glGenBuffers(1, &_buffer); glBindBuffer(GL_ARRAY_BUFFER, _buffer); @@ -48,7 +48,7 @@ if (!_program) { return; } - + glDeleteBuffers(1, &_buffer); glDetachShader(_program, _vertexShader); glDetachShader(_program, _fragmentShader); diff --git a/platform/macos/app/MGLVectorSource+MBXAdditions.m b/platform/macos/app/MGLVectorSource+MBXAdditions.m index f59b72aa9f..644b43a651 100644 --- a/platform/macos/app/MGLVectorSource+MBXAdditions.m +++ b/platform/macos/app/MGLVectorSource+MBXAdditions.m @@ -35,7 +35,7 @@ if (!self.mapboxStreets) { return @{}; } - + // Replace {name} and {name_*} with the matching localized name tag. NSString *localizedKey = preferredLanguage ? [NSString stringWithFormat:@"name_%@", preferredLanguage] : @"name"; NSMutableDictionary *localizedKeysByKey = [NSMutableDictionary dictionaryWithObject:localizedKey forKey:@"name"]; diff --git a/platform/macos/app/MapDocument.m b/platform/macos/app/MapDocument.m index 40fd9e4600..225bb4d3af 100644 --- a/platform/macos/app/MapDocument.m +++ b/platform/macos/app/MapDocument.m @@ -40,7 +40,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio } else if ([shape isKindOfClass:[MGLShapeCollection class]]) { subshapes = MBXFlattenedShapes([(MGLShapeCollection *)shape shapes]); } - + if (subshapes) { [flattenedShapes addObjectsFromArray:subshapes]; } else { @@ -63,11 +63,11 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio /// Style URL inherited from an existing document at the time this document /// was created. NSURL *_inheritedStyleURL; - + NSPoint _mouseLocationForMapViewContextMenu; NSUInteger _droppedPinCounter; NSNumberFormatter *_spellOutNumberFormatter; - + BOOL _isLocalizingLabels; BOOL _showsToolTipsOnDroppedPins; BOOL _randomizesCursorsOnDroppedPins; @@ -95,19 +95,19 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio - (void)windowControllerDidLoadNib:(NSWindowController *)controller { [super windowControllerDidLoadNib:controller]; - + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDefaultsDidChange:) name:NSUserDefaultsDidChangeNotification object:nil]; - + _spellOutNumberFormatter = [[NSNumberFormatter alloc] init]; - + NSPressGestureRecognizer *pressGestureRecognizer = [[NSPressGestureRecognizer alloc] initWithTarget:self action:@selector(handlePressGesture:)]; [self.mapView addGestureRecognizer:pressGestureRecognizer]; - + [self.splitView setPosition:0 ofDividerAtIndex:0]; - + [self applyPendingState]; } @@ -263,7 +263,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio [self.undoManager registerUndoWithTarget:self handler:^(MapDocument * _Nonnull target) { [target toggleStyleLayersAtArrangedObjectIndexes:indices]; }]; - + if (!self.undoManager.undoing) { NSString *actionName; if (indices.count == 1) { @@ -276,11 +276,11 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio [self.undoManager setActionIsDiscardable:YES]; [self.undoManager setActionName:actionName]; } - + for (MGLStyleLayer *layer in layers) { layer.visible = !isVisible; } - + NSIndexSet *columnIndices = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 2)]; [self.styleLayersTableView reloadDataForRowIndexes:indices columnIndexes:columnIndices]; } @@ -298,7 +298,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio [self.undoManager registerUndoWithTarget:self handler:^(id _Nonnull target) { [self deleteStyleLayersAtArrangedObjectIndexes:indices]; }]; - + if (!self.undoManager.undoing) { NSString *actionName; if (indices.count == 1) { @@ -309,7 +309,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio } [self.undoManager setActionName:actionName]; } - + [self.styleLayersArrayController insertObjects:layers atArrangedObjectIndexes:indices]; } @@ -318,7 +318,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio [self.undoManager registerUndoWithTarget:self handler:^(id _Nonnull target) { [self insertStyleLayers:layers atArrangedObjectIndexes:indices]; }]; - + if (!self.undoManager.undoing) { NSString *actionName; if (indices.count == 1) { @@ -329,7 +329,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio } [self.undoManager setActionName:actionName]; } - + [self.styleLayersArrayController removeObjectsAtArrangedObjectIndexes:indices]; } @@ -346,17 +346,17 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio if (![layer isKindOfClass:[MGLSymbolStyleLayer class]]) { continue; } - + MGLVectorSource *source = (MGLVectorSource *)[style sourceWithIdentifier:layer.sourceIdentifier]; if (![source isKindOfClass:[MGLVectorSource class]] || !source.mapboxStreets) { continue; } - + NSDictionary *localizedKeysByKey = localizedKeysByKeyBySourceIdentifier[layer.sourceIdentifier]; if (!localizedKeysByKey) { localizedKeysByKey = localizedKeysByKeyBySourceIdentifier[layer.sourceIdentifier] = [source localizedKeysByKeyForPreferredLanguage:preferredLanguage]; } - + NSString *(^stringByLocalizingString)(NSString *) = ^ NSString * (NSString *string) { NSMutableString *localizedString = string.mutableCopy; [localizedKeysByKey enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull key, NSString * _Nonnull localizedKey, BOOL * _Nonnull stop) { @@ -369,7 +369,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio }]; return localizedString; }; - + if ([layer.text isKindOfClass:[MGLStyleConstantValue class]]) { NSString *textField = [(MGLStyleConstantValue<NSString *> *)layer.text rawValue]; layer.text = [MGLStyleValue<NSString *> valueWithRawValue:stringByLocalizingString(textField)]; @@ -391,7 +391,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio self.mapView.styleURL = _inheritedStyleURL; _inheritedStyleURL = nil; } - + AppDelegate *appDelegate = (AppDelegate *)NSApp.delegate; if (appDelegate.pendingStyleURL) { self.mapView.styleURL = appDelegate.pendingStyleURL; @@ -420,7 +420,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio self.mapView.zoomLevel = MIN(appDelegate.pendingMaximumZoomLevel, self.mapView.zoomLevel); appDelegate.pendingMaximumZoomLevel = -1; } - + // Temporarily set the display name to the default center coordinate instead // of “Untitled” until the binding kicks in. NSValue *coordinateValue = [NSValue valueWithMGLCoordinate:self.mapView.centerCoordinate]; @@ -475,7 +475,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio - (IBAction)dropManyPins:(id)sender { [self removeAllAnnotations:sender]; - + NSRect bounds = self.mapView.bounds; NSMutableArray *annotations = [NSMutableArray array]; for (CGFloat x = NSMinX(bounds); x < NSMaxX(bounds); x += arc4random_uniform(50)) { @@ -483,7 +483,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio [annotations addObject:[self pinAtPoint:NSMakePoint(x, y)]]; } } - + [NSTimer scheduledTimerWithTimeInterval:1.0/60.0 target:self selector:@selector(dropOneOfManyPins:) @@ -518,7 +518,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio - (IBAction)startWorldTour:(id)sender { _isTouringWorld = YES; - + [self removeAllAnnotations:sender]; NSUInteger numberOfAnnotations = sizeof(WorldTourDestinations) / sizeof(WorldTourDestinations[0]); NSMutableArray *annotations = [NSMutableArray arrayWithCapacity:numberOfAnnotations]; @@ -537,7 +537,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio _isTouringWorld = NO; return; } - + [annotations removeObjectAtIndex:0]; MGLMapCamera *camera = [MGLMapCamera cameraLookingAtCenterCoordinate:nextAnnotation.coordinate fromDistance:0 @@ -612,11 +612,11 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio [self.undoManager registerUndoWithTarget:self handler:^(id _Nonnull target) { [self removeCustomStyleLayer:sender]; }]; - + if (!self.undoManager.isUndoing) { [self.undoManager setActionName:@"Add Lime Green Layer"]; } - + LimeGreenStyleLayer *layer = [[LimeGreenStyleLayer alloc] initWithIdentifier:@"mbx-custom"]; MGLStyleLayer *houseNumberLayer = [self.mapView.style layerWithIdentifier:@"housenum-label"]; if (houseNumberLayer) { @@ -630,11 +630,11 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio [self.undoManager registerUndoWithTarget:self handler:^(id _Nonnull target) { [self insertCustomStyleLayer:sender]; }]; - + if (!self.undoManager.isUndoing) { [self.undoManager setActionName:@"Delete Lime Green Layer"]; } - + MGLStyleLayer *layer = [self.mapView.style layerWithIdentifier:@"mbx-custom"]; [self.mapView.style removeLayer:layer]; } @@ -657,7 +657,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio if ([namePrompt runModal] != NSAlertFirstButtonReturn) { return; } - + id <MGLOfflineRegion> region = [[MGLTilePyramidOfflineRegion alloc] initWithStyleURL:self.mapView.styleURL bounds:self.mapView.visibleCoordinateBounds fromZoomLevel:self.mapView.zoomLevel toZoomLevel:self.mapView.maximumZoomLevel]; NSData *context = [[NSValueTransformer valueTransformerForName:@"OfflinePackNameValueTransformer"] reverseTransformedValue:nameTextField.stringValue]; [[MGLOfflineStorage sharedOfflineStorage] addPackForRegion:region withContext:context completionHandler:^(MGLOfflinePack * _Nullable pack, NSError * _Nullable error) { @@ -687,27 +687,27 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio self.mapView.style.transitionDelay = 1; MGLFillStyleLayer *fillStyleLayer = (MGLFillStyleLayer *)[self.mapView.style layerWithIdentifier:@"water"]; - + MGLStyleValue *colorFunction = [MGLStyleValue<NSColor *> valueWithStops:@{ @0.0: [MGLStyleValue<NSColor *> valueWithRawValue:[NSColor redColor]], @10.0: [MGLStyleValue<NSColor *> valueWithRawValue:[NSColor yellowColor]], @20.0: [MGLStyleValue<NSColor *> valueWithRawValue:[NSColor blackColor]], }]; fillStyleLayer.fillColor = colorFunction; - + NSString *filePath = [[NSBundle bundleForClass:self.class] pathForResource:@"amsterdam" ofType:@"geojson"]; NSURL *geoJSONURL = [NSURL fileURLWithPath:filePath]; MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"ams" URL:geoJSONURL options:nil]; [self.mapView.style addSource:source]; - + MGLFillStyleLayer *fillLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"test" source:source]; fillLayer.fillColor = [MGLStyleValue<NSColor *> valueWithRawValue:[NSColor greenColor]]; fillLayer.predicate = [NSPredicate predicateWithFormat:@"%K == %@", @"type", @"park"]; [self.mapView.style addLayer:fillLayer]; - + NSImage *image = [NSImage imageNamed:NSImageNameIChatTheaterTemplate]; [self.mapView.style setImage:image forName:NSImageNameIChatTheaterTemplate]; - + MGLSource *streetsSource = [self.mapView.style sourceWithIdentifier:@"composite"]; MGLSymbolStyleLayer *theaterLayer = [[MGLSymbolStyleLayer alloc] initWithIdentifier:@"theaters" source:streetsSource]; theaterLayer.sourceLayerIdentifier = @"poi_label"; @@ -740,7 +740,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio title = [feature attributeForKey:@"name_en"] ?: [feature attributeForKey:@"name"]; } } - + DroppedPinAnnotation *annotation = [[DroppedPinAnnotation alloc] init]; annotation.coordinate = [self.mapView convertPoint:point toCoordinateFromView:self.mapView]; annotation.title = title ?: @"Dropped Pin"; @@ -949,7 +949,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio if (![MGLAccountManager accessToken]) { return NSNotFound; } - + NSArray *styleURLs = @[ [MGLStyle streetsStyleURLWithVersion:MGLStyleDefaultVersion], [MGLStyle outdoorsStyleURLWithVersion:MGLStyleDefaultVersion], @@ -965,7 +965,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio if (!self.mapView) { return NO; } - + SEL action = toolbarItem.action; if (action == @selector(showShareMenu:)) { [(NSButton *)toolbarItem.view sendActionOn:NSLeftMouseDownMask]; @@ -1003,14 +1003,14 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio NSImage *browserIcon = [[NSWorkspace sharedWorkspace] iconForFile:browserURL.path]; NSString *browserName = [[NSFileManager defaultManager] displayNameAtPath:browserURL.path]; NSString *browserServiceName = [NSString stringWithFormat:@"Open in %@", browserName]; - + NSSharingService *browserService = [[NSSharingService alloc] initWithTitle:browserServiceName image:browserIcon alternateImage:nil handler:^{ [[NSWorkspace sharedWorkspace] openURL:self.shareURL]; }]; - + NSMutableArray *sharingServices = [proposedServices mutableCopy]; [sharingServices insertObject:browserService atIndex:0]; return sharingServices; diff --git a/platform/macos/app/OfflinePackNameValueTransformer.m b/platform/macos/app/OfflinePackNameValueTransformer.m index 2825e48ed3..d1b3c20ac1 100644 --- a/platform/macos/app/OfflinePackNameValueTransformer.m +++ b/platform/macos/app/OfflinePackNameValueTransformer.m @@ -14,7 +14,7 @@ static NSString * const MBXOfflinePackContextNameKey = @"Name"; - (NSString *)transformedValue:(NSData *)context { NSAssert([context isKindOfClass:[NSData class]], @"Context should be NSData."); - + NSDictionary *userInfo = [NSKeyedUnarchiver unarchiveObjectWithData:context]; NSAssert([userInfo isKindOfClass:[NSDictionary class]], @"Context of offline pack isn’t a dictionary."); NSString *name = userInfo[MBXOfflinePackContextNameKey]; @@ -24,7 +24,7 @@ static NSString * const MBXOfflinePackContextNameKey = @"Name"; - (NSData *)reverseTransformedValue:(NSString *)name { NSAssert([name isKindOfClass:[NSString class]], @"Name should be a string."); - + return [NSKeyedArchiver archivedDataWithRootObject:@{ MBXOfflinePackContextNameKey: name, }]; diff --git a/platform/macos/app/StyleLayerIconTransformer.m b/platform/macos/app/StyleLayerIconTransformer.m index 93f59abb3e..ff2b964b87 100644 --- a/platform/macos/app/StyleLayerIconTransformer.m +++ b/platform/macos/app/StyleLayerIconTransformer.m @@ -31,7 +31,7 @@ if ([layer isKindOfClass:[MGLSymbolStyleLayer class]]) { return [NSImage imageNamed:@"symbol"]; } - + return nil; } diff --git a/platform/macos/app/TimeIntervalTransformer.m b/platform/macos/app/TimeIntervalTransformer.m index 39177dc5bc..2c9cb6fc74 100644 --- a/platform/macos/app/TimeIntervalTransformer.m +++ b/platform/macos/app/TimeIntervalTransformer.m @@ -18,7 +18,7 @@ NSString *NumberAndUnitString(NSInteger quantity, NSString *singular, NSString * if (![value isKindOfClass:[NSValue class]]) { return nil; } - + NSTimeInterval timeInterval = [value doubleValue]; NSInteger seconds = floor(timeInterval); NSInteger minutes = floor(seconds / 60); @@ -29,7 +29,7 @@ NSString *NumberAndUnitString(NSInteger quantity, NSString *singular, NSString * hours -= days * 24; NSInteger weeks = floor(days) / 7; days -= weeks * 7; - + NSMutableArray *components = [NSMutableArray array]; if (seconds || timeInterval < 60) { [components addObject:NumberAndUnitString(seconds, @"second", @"seconds")]; @@ -46,7 +46,7 @@ NSString *NumberAndUnitString(NSInteger quantity, NSString *singular, NSString * if (weeks) { [components insertObject:NumberAndUnitString(weeks, @"week", @"weeks") atIndex:0]; } - + return [components componentsJoinedByString:@", "]; } diff --git a/platform/macos/scripts/deploy-packages.sh b/platform/macos/scripts/deploy-packages.sh index d0c545f8f5..8f61519244 100755 --- a/platform/macos/scripts/deploy-packages.sh +++ b/platform/macos/scripts/deploy-packages.sh @@ -9,7 +9,7 @@ set -u # GITHUB_RELEASE=true: Upload to github # BINARY_DIRECTORY=build/macos/deploy: Directory in which to save test packages -# environment variables and dependencies: +# environment variables and dependencies: # - You must run "mbx auth ..." before running # - Set GITHUB_TOKEN to a GitHub API access token in your environment to use GITHUB_RELEASE # - "wget" is required for downloading the zip files from s3 @@ -20,19 +20,19 @@ function finish { >&2 echo -en "\033[0m"; } trap finish EXIT buildPackageStyle() { - local package=$1 style="" + local package=$1 style="" if [[ ${#} -eq 2 ]]; then style="$2" - fi + fi step "Building: make ${package} ${style}" make ${package} step "Publishing ${package} with ${style}" local file_name="" - if [ -z ${style} ] + if [ -z ${style} ] then - file_name=mapbox-macos-sdk-${PUBLISH_VERSION}.zip + file_name=mapbox-macos-sdk-${PUBLISH_VERSION}.zip else - file_name=mapbox-macos-sdk-${PUBLISH_VERSION}-${style}.zip + file_name=mapbox-macos-sdk-${PUBLISH_VERSION}-${style}.zip fi step "Compressing ${file_name}…" cd build/macos/pkg @@ -98,7 +98,7 @@ step "Deploying version ${PUBLISH_VERSION}…" if [[ ${#} -eq 3 && $3 == "-g" ]]; then GITHUB_RELEASE=true fi - + make clean && make distclean mkdir -p ${BINARY_DIRECTORY} diff --git a/platform/macos/src/MGLAnnotationImage.h b/platform/macos/src/MGLAnnotationImage.h index 0f248c721c..d7336133d1 100644 --- a/platform/macos/src/MGLAnnotationImage.h +++ b/platform/macos/src/MGLAnnotationImage.h @@ -17,7 +17,7 @@ MGL_EXPORT /** Initializes and returns a new annotation image object. - + @param image The image to display for the annotation. @param reuseIdentifier The string that identifies this annotation image in the reuse queue. @@ -34,11 +34,11 @@ MGL_EXPORT /** The string that identifies this annotation image in the reuse queue. (read-only) - + You specify the reuse identifier when you create the image object. You use this type later to retrieve an annotation image object that was created previously but which is currently unused because its annotation is not on-screen. - + If you define distinctly different types of annotations (with distinctly different annotation images to go with them), you can differentiate between the annotation types by specifying different reuse identifiers for each one. @@ -47,7 +47,7 @@ MGL_EXPORT /** A Boolean value indicating whether the annotation is selectable. - + The default value of this property is `YES`. If the value of this property is `NO`, the annotation image ignores click events and cannot be selected. */ @@ -55,7 +55,7 @@ MGL_EXPORT /** The cursor that appears above any annotation using this annotation image. - + By default, this property is set to `nil`, representing the current cursor. */ @property (nonatomic, nullable) NSCursor *cursor; diff --git a/platform/macos/src/MGLAnnotationImage.m b/platform/macos/src/MGLAnnotationImage.m index d19dbe5dfc..8d715b427b 100644 --- a/platform/macos/src/MGLAnnotationImage.m +++ b/platform/macos/src/MGLAnnotationImage.m @@ -47,9 +47,9 @@ - (BOOL)isEqual:(id)other { if (self == other) return YES; if (![other isKindOfClass:[MGLAnnotationImage class]]) return NO; - + MGLAnnotationImage *otherAnnotationImage = other; - + return ((!_reuseIdentifier && !otherAnnotationImage.reuseIdentifier) || [_reuseIdentifier isEqualToString:otherAnnotationImage.reuseIdentifier]) && _selectable == otherAnnotationImage.selectable && ((!_cursor && !otherAnnotationImage.cursor) || [_cursor isEqual:otherAnnotationImage.cursor]) diff --git a/platform/macos/src/MGLAttributionButton.mm b/platform/macos/src/MGLAttributionButton.mm index ed8bb18a66..3df415f60d 100644 --- a/platform/macos/src/MGLAttributionButton.mm +++ b/platform/macos/src/MGLAttributionButton.mm @@ -10,25 +10,25 @@ if (self = [super initWithFrame:NSZeroRect]) { self.bordered = NO; self.bezelStyle = NSRegularSquareBezelStyle; - + // Extract any prefix consisting of intellectual property symbols. NSScanner *scanner = [NSScanner scannerWithString:info.title.string]; NSCharacterSet *symbolSet = [NSCharacterSet characterSetWithCharactersInString:@"©℗®℠™ &"]; NSString *symbol; [scanner scanCharactersFromSet:symbolSet intoString:&symbol]; - + // Remove the underline from the symbol for aesthetic reasons. NSMutableAttributedString *title = info.title.mutableCopy; [title removeAttribute:NSUnderlineStyleAttributeName range:NSMakeRange(0, symbol.length)]; - + self.attributedTitle = title; [self sizeToFit]; - + _URL = info.URL; if (_URL) { self.toolTip = _URL.absoluteString; } - + self.target = self; self.action = @selector(openURL:); } diff --git a/platform/macos/src/MGLMapView+IBAdditions.h b/platform/macos/src/MGLMapView+IBAdditions.h index 81f4506a57..8a4a90917b 100644 --- a/platform/macos/src/MGLMapView+IBAdditions.h +++ b/platform/macos/src/MGLMapView+IBAdditions.h @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN // underscores for display. /** URL of the style currently displayed in the receiver. - + The URL may be a full HTTP or HTTPS URL, a Mapbox URL indicating the style’s map ID (`mapbox://styles/<user>/<style>`), or a path to a local file relative to the application’s resource path. Leave this field blank for the diff --git a/platform/macos/src/MGLMapView.h b/platform/macos/src/MGLMapView.h index 7440ffe793..49cfd18f37 100644 --- a/platform/macos/src/MGLMapView.h +++ b/platform/macos/src/MGLMapView.h @@ -19,11 +19,11 @@ NS_ASSUME_NONNULL_BEGIN /** An interactive, customizable map view with an interface similar to the one provided by Apple’s MapKit. - + Using `MGLMapView`, you can embed the map inside a view, allow users to manipulate it with standard gestures, animate the map between different viewpoints, and present information in the form of annotations and overlays. - + The map view loads scalable vector tiles that conform to the <a href="https://github.com/mapbox/vector-tile-spec">Mapbox Vector Tile Specification</a>. It styles them with a style that conforms to the @@ -31,27 +31,27 @@ NS_ASSUME_NONNULL_BEGIN Such styles can be designed in <a href="https://www.mapbox.com/studio/">Mapbox Studio</a> and hosted on mapbox.com. - + A collection of Mapbox-hosted styles is available through the `MGLStyle` class. These basic styles use <a href="https://www.mapbox.com/developers/vector-tiles/mapbox-streets">Mapbox Streets</a> or <a href="https://www.mapbox.com/satellite/">Mapbox Satellite</a> data sources, but you can specify a custom style that makes use of your own data. - + Mapbox-hosted vector tiles and styles require an API access token, which you can obtain from the <a href="https://www.mapbox.com/studio/account/tokens/">Mapbox account page</a>. Access tokens associate requests to Mapbox’s vector tile and style APIs with your Mapbox account. They also deter other developers from using your styles without your permission. - + Adding your own gesture recognizer to `MGLMapView` will block the corresponding gesture recognizer built into `MGLMapView`. To avoid conflicts, define which gesture recognizer takes precedence. For example, you can subclass `NSClickGestureRecognizer` and override `-[NSGestureRecognizer shouldRequireFailureOfGestureRecognizer:]`, so that your subclass will be invoked only if the default `MGLMapView` click gesture recognizer fails: - + ```swift class MapClickGestureRecognizer: NSClickGestureRecognizer { override func shouldRequireFailure(of otherGestureRecognizer: NSGestureRecognizer) -> Bool { @@ -59,7 +59,7 @@ NS_ASSUME_NONNULL_BEGIN } } ``` - + @note You are responsible for getting permission to use the map data and for ensuring that your use adheres to the relevant terms of use. */ @@ -71,7 +71,7 @@ MGL_EXPORT IB_DESIGNABLE /** Initializes and returns a newly allocated map view with the specified frame and the default style. - + @param frame The frame for the view, measured in points. @return An initialized map view. */ @@ -80,7 +80,7 @@ MGL_EXPORT IB_DESIGNABLE /** Initializes and returns a newly allocated map view with the specified frame and style URL. - + @param frame The frame for the view, measured in points. @param styleURL URL of the map style to display. The URL may be a full HTTP or HTTPS URL, a Mapbox URL indicating the style’s map ID @@ -94,7 +94,7 @@ MGL_EXPORT IB_DESIGNABLE /** The receiver’s delegate. - + A map view sends messages to its delegate to notify it of changes to its contents or the viewpoint. The delegate also provides information about annotations displayed on the map, such as the styles to apply to individual @@ -106,17 +106,17 @@ MGL_EXPORT IB_DESIGNABLE /** The style currently displayed in the receiver. - + Unlike the `styleURL` property, this property is set to an object that allows you to manipulate every aspect of the style locally. - + If the style is loading, this property is set to `nil` until the style finishes loading. If the style has failed to load, this property is set to `nil`. Because the style loads asynchronously, you should manipulate it in the `-[MGLMapViewDelegate mapView:didFinishLoadingStyle:]` or `-[MGLMapViewDelegate mapViewDidFinishLoadingMap:]` method. It is not possible to manipulate the style before it has finished loading. - + @note The default styles provided by Mapbox contain sources and layers with identifiers that will change over time. Applications that use APIs that manipulate a style's sources and layers must first set the style URL to an @@ -128,14 +128,14 @@ MGL_EXPORT IB_DESIGNABLE /** URL of the style currently displayed in the receiver. - + The URL may be a full HTTP or HTTPS URL, a Mapbox URL indicating the style’s map ID (`mapbox://styles/<user>/<style>`), or a path to a local file relative to the application’s resource path. - + If you set this property to `nil`, the receiver will use the default style and this property will automatically be set to that style’s URL. - + If you want to modify the current style without replacing it outright, or if you want to introspect individual style attributes, use the `style` property. */ @@ -143,7 +143,7 @@ MGL_EXPORT IB_DESIGNABLE /** Reloads the style. - + You do not normally need to call this method. The map view automatically responds to changes in network connectivity by reloading the style. You may need to call this method if you change the access token after a style has @@ -164,7 +164,7 @@ MGL_EXPORT IB_DESIGNABLE /** The Mapbox logo, positioned in the lower-left corner. - + @note The Mapbox terms of service, which governs the use of Mapbox-hosted vector tiles and styles, <a href="https://www.mapbox.com/help/mapbox-logo/">requires</a> most Mapbox @@ -176,7 +176,7 @@ MGL_EXPORT IB_DESIGNABLE /** A view showing legally required copyright notices, positioned along the bottom of the map view, to the left of the Mapbox logo. - + @note The Mapbox terms of service, which governs the use of Mapbox-hosted vector tiles and styles, <a href="https://www.mapbox.com/help/attribution/">requires</a> these @@ -191,10 +191,10 @@ MGL_EXPORT IB_DESIGNABLE /** The geographic coordinate at the center of the map view. - + Changing the value of this property centers the map on the new coordinate without changing the current zoom level. - + Changing the value of this property updates the map view immediately. If you want to animate the change, use the `-setCenterCoordinate:animated:` method instead. @@ -203,10 +203,10 @@ MGL_EXPORT IB_DESIGNABLE /** Changes the center coordinate of the map and optionally animates the change. - + Changing the center coordinate centers the map on the new coordinate without changing the current zoom level. - + @param coordinate The new center coordinate for the map. @param animated Specify `YES` if you want the map view to scroll to the new location or `NO` if you want the map to display the new location @@ -216,12 +216,12 @@ MGL_EXPORT IB_DESIGNABLE /** The zoom level of the receiver. - + In addition to affecting the visual size and detail of features on the map, the zoom level affects the size of the vector tiles that are loaded. At zoom level 0, each tile covers the entire world map; at zoom level 1, it covers ¼ of the world; at zoom level 2, <sup>1</sup>⁄<sub>16</sub> of the world, and so on. - + Changing the value of this property updates the map view immediately. If you want to animate the change, use the `-setZoomLevel:animated:` method instead. */ @@ -229,34 +229,34 @@ MGL_EXPORT IB_DESIGNABLE /** The minimum zoom level at which the map can be shown. - + Depending on the map view’s aspect ratio, the map view may be prevented from reaching the minimum zoom level, in order to keep the map from repeating within the current viewport. - + If the value of this property is greater than that of the `maximumZoomLevel` property, the behavior is undefined. - + The default value of this property is 0. */ @property (nonatomic) double minimumZoomLevel; /** The maximum zoom level the map can be shown at. - + If the value of this property is smaller than that of the `minimumZoomLevel` property, the behavior is undefined. - + The default value of this property is 20. */ @property (nonatomic) double maximumZoomLevel; /** Changes the zoom level of the map and optionally animates the change. - + Changing the zoom level scales the map without changing the current center coordinate. - + @param zoomLevel The new zoom level for the map. @param animated Specify `YES` if you want the map view to animate the change to the new zoom level or `NO` if you want the map to display the new zoom @@ -266,11 +266,11 @@ MGL_EXPORT IB_DESIGNABLE /** The heading of the map, measured in degrees clockwise from true north. - + The value `0` means that the top edge of the map view corresponds to true north. The value `90` means the top of the map is pointing due east. The value `180` means the top of the map points due south, and so on. - + Changing the value of this property updates the map view immediately. If you want to animate the change, use the `-setDirection:animated:` method instead. */ @@ -278,10 +278,10 @@ MGL_EXPORT IB_DESIGNABLE /** Changes the heading of the map and optionally animates the change. - + Changing the heading rotates the map without changing the current center coordinate or zoom level. - + @param direction The heading of the map, measured in degrees clockwise from true north. @param animated Specify `YES` if you want the map view to animate the change @@ -298,7 +298,7 @@ MGL_EXPORT IB_DESIGNABLE /** Moves the viewpoint to a different location with respect to the map with an optional transition animation. - + @param camera The new viewpoint. @param animated Specify `YES` if you want the map view to animate the change to the new viewpoint or `NO` if you want the map to display the new viewpoint @@ -309,7 +309,7 @@ MGL_EXPORT IB_DESIGNABLE /** Moves the viewpoint to a different location with respect to the map with an optional transition duration and timing function. - + @param camera The new viewpoint. @param duration The amount of time, measured in seconds, that the transition animation should take. Specify `0` to jump to the new viewpoint @@ -325,10 +325,10 @@ MGL_EXPORT IB_DESIGNABLE Moves the viewpoint to a different location using a transition animation that evokes powered flight and a default duration based on the length of the flight path. - + The transition animation seamlessly incorporates zooming and panning to help the user find his or her bearings even after traversing a great distance. - + @param camera The new viewpoint. @param completion The block to execute after the animation finishes. */ @@ -337,10 +337,10 @@ MGL_EXPORT IB_DESIGNABLE /** Moves the viewpoint to a different location using a transition animation that evokes powered flight and an optional transition duration. - + The transition animation seamlessly incorporates zooming and panning to help the user find his or her bearings even after traversing a great distance. - + @param camera The new viewpoint. @param duration The amount of time, measured in seconds, that the transition animation should take. Specify `0` to jump to the new viewpoint @@ -353,10 +353,10 @@ MGL_EXPORT IB_DESIGNABLE /** Moves the viewpoint to a different location using a transition animation that evokes powered flight and an optional transition duration and peak altitude. - + The transition animation seamlessly incorporates zooming and panning to help the user find his or her bearings even after traversing a great distance. - + @param camera The new viewpoint. @param duration The amount of time, measured in seconds, that the transition animation should take. Specify `0` to jump to the new viewpoint @@ -372,7 +372,7 @@ MGL_EXPORT IB_DESIGNABLE /** The geographic coordinate bounds visible in the receiver’s viewport. - + Changing the value of this property updates the receiver immediately. If you want to animate the change, use the `-setVisibleCoordinateBounds:animated:` method instead. @@ -382,7 +382,7 @@ MGL_EXPORT IB_DESIGNABLE /** Changes the receiver’s viewport to fit the given coordinate bounds, optionally animating the change. - + @param bounds The bounds that the viewport will show in its entirety. @param animated Specify `YES` to animate the change by smoothly scrolling and zooming or `NO` to immediately display the given bounds. @@ -392,7 +392,7 @@ MGL_EXPORT IB_DESIGNABLE /** Changes the receiver’s viewport to fit the given coordinate bounds and optionally some additional padding on each side. - + @param bounds The bounds that the viewport will show in its entirety. @param insets The minimum padding (in screen points) that will be visible around the given coordinate bounds. @@ -432,7 +432,7 @@ MGL_EXPORT IB_DESIGNABLE /** Returns the camera that best fits the given coordinate bounds. - + @param bounds The coordinate bounds to fit to the receiver’s viewport. @return A camera object centered on the same location as the coordinate bounds with zoom level as high (close to the ground) as possible while still @@ -444,7 +444,7 @@ MGL_EXPORT IB_DESIGNABLE /** Returns the camera that best fits the given coordinate bounds, optionally with some additional padding on each side. - + @param bounds The coordinate bounds to fit to the receiver’s viewport. @param insets The minimum padding (in screen points) that would be visible around the returned camera object if it were set as the receiver’s camera. @@ -458,13 +458,13 @@ MGL_EXPORT IB_DESIGNABLE /** A Boolean value indicating whether the receiver automatically adjusts its content insets. - + When the value of this property is `YES`, the map view automatically updates its `contentInsets` property to account for any overlapping title bar or toolbar. To overlap with the title bar or toolbar, the containing window’s style mask must have `NSFullSizeContentViewWindowMask` set, and the title bar must not be transparent. - + The default value of this property is `YES`. */ @property (nonatomic, assign) BOOL automaticallyAdjustsContentInsets; @@ -472,16 +472,16 @@ MGL_EXPORT IB_DESIGNABLE /** The distance from the edges of the map view’s frame to the edges of the map view’s logical viewport. - + When the value of this property is equal to `NSEdgeInsetsZero`, viewport properties such as `centerCoordinate` assume a viewport that matches the map view’s frame. Otherwise, those properties are inset, excluding part of the frame from the viewport. For instance, if the only the top edge is inset, the map center is effectively shifted downward. - + When the value of the `automaticallyAdjustsContentInsets` property is `YES`, the value of this property may be overridden at any time. - + Changing the value of this property updates the map view immediately. If you want to animate the change, use the `-setContentInsets:animated:` method instead. @@ -491,16 +491,16 @@ MGL_EXPORT IB_DESIGNABLE /** Sets the distance from the edges of the map view’s frame to the edges of the map view’s logical viewport, with an optional transition animation. - + When the value of this property is equal to `NSEdgeInsetsZero`, viewport properties such as `centerCoordinate` assume a viewport that matches the map view’s frame. Otherwise, those properties are inset, excluding part of the frame from the viewport. For instance, if the only the top edge is inset, the map center is effectively shifted downward. - + When the value of the `automaticallyAdjustsContentInsets` property is `YES`, the value of this property may be overridden at any time. - + @param contentInsets The new values to inset the content by. @param animated Specify `YES` if you want the map view to animate the change to the content insets or `NO` if you want the map to inset the content @@ -513,13 +513,13 @@ MGL_EXPORT IB_DESIGNABLE /** A Boolean value that determines whether the user may zoom the map in and out, changing the zoom level. - + When this property is set to `YES`, the default, the user may zoom the map in and out by pinching two fingers, by using a scroll wheel on a traditional mouse, or by dragging the mouse cursor up and down while holding down the Shift key. When the receiver has focus, the user may also zoom by pressing the up and down arrow keys while holding down the Option key. - + This property controls only user interactions with the map. If you set the value of this property to `NO`, you may still change the map zoom programmatically. @@ -529,11 +529,11 @@ MGL_EXPORT IB_DESIGNABLE /** A Boolean value that determines whether the user may scroll around the map, changing the center coordinate. - + When this property is set to `YES`, the default, the user may scroll the map by swiping with two fingers or dragging the mouse cursor. When the receiver has focus, the user may also scroll around the map by pressing the arrow keys. - + This property controls only user interactions with the map. If you set the value of this property to `NO`, you may still change the map location programmatically. @@ -543,13 +543,13 @@ MGL_EXPORT IB_DESIGNABLE /** A Boolean value that determines whether the user may rotate the map, changing the direction. - + When this property is set to `YES`, the default, the user may rotate the map by moving two fingers in a circular motion or by dragging the mouse cursor left and right while holding down the Option key. When the receiver has focus, the user may also zoom by pressing the left and right arrow keys while holding down the Option key. - + This property controls only user interactions with the map. If you set the value of this property to `NO`, you may still rotate the map programmatically. */ @@ -558,10 +558,10 @@ MGL_EXPORT IB_DESIGNABLE /** A Boolean value that determines whether the user may tilt of the map, changing the pitch. - + When this property is set to `YES`, the default, the user may rotate the map by dragging the mouse cursor up and down while holding down the Option key. - + This property controls only user interactions with the map. If you set the value of this property to `NO`, you may still change the pitch of the map programmatically. @@ -572,7 +572,7 @@ MGL_EXPORT IB_DESIGNABLE /** The complete list of annotations associated with the receiver. (read-only) - + The objects in this array must adopt the `MGLAnnotation` protocol. If no annotations are associated with the map view, the value of this property is `nil`. @@ -581,13 +581,13 @@ MGL_EXPORT IB_DESIGNABLE /** Adds an annotation to the map view. - + @note `MGLMultiPolyline`, `MGLMultiPolygon`, and `MGLShapeCollection` objects cannot be added to the map view at this time. Nor can `MGLMultiPoint` objects that are not instances of `MGLPolyline` or `MGLPolygon`. Any multipoint, multipolyline, multipolygon, or shape collection object that is specified is silently ignored. - + @param annotation The annotation object to add to the receiver. This object must conform to the `MGLAnnotation` protocol. The map view retains the annotation object. @@ -596,13 +596,13 @@ MGL_EXPORT IB_DESIGNABLE /** Adds an array of annotations to the map view. - + @note `MGLMultiPolyline`, `MGLMultiPolygon`, and `MGLShapeCollection` objects cannot be added to the map view at this time. Nor can `MGLMultiPoint` objects that are not instances of `MGLPolyline` or `MGLPolygon`. Any multipoint, multipolyline, multipolygon, or shape collection objects that are specified are silently ignored. - + @param annotations An array of annotation objects. Each object in the array must conform to the `MGLAnnotation` protocol. The map view retains each individual annotation object. @@ -612,7 +612,7 @@ MGL_EXPORT IB_DESIGNABLE /** The complete list of annotations associated with the receiver that are currently visible. - + The objects in this array must adopt the `MGLAnnotation` protocol. If no annotations are associated with the map view or if no annotations associated with the map view are currently visible, the value of this property is `nil`. @@ -621,11 +621,11 @@ MGL_EXPORT IB_DESIGNABLE /** Removes an annotation from the map view, deselecting it if it is selected. - + Removing an annotation object dissociates it from the map view entirely, preventing it from being displayed on the map. Thus you would typically call this method only when you want to hide or delete a given annotation. - + @param annotation The annotation object to remove. This object must conform to the `MGLAnnotation` protocol. */ @@ -634,11 +634,11 @@ MGL_EXPORT IB_DESIGNABLE /** Removes an array of annotations from the map view, deselecting any selected annotations in the array. - + Removing annotation objects dissociates them from the map view entirely, preventing them from being displayed on the map. Thus you would typically call this method only when you want to hide or delete the given annotations. - + @param annotations The array of annotation objects to remove. Objects in the array must conform to the `MGLAnnotation` protocol. */ @@ -646,11 +646,11 @@ MGL_EXPORT IB_DESIGNABLE /** Returns a reusable annotation image object associated with its identifier. - + For performance reasons, you should generally reuse `MGLAnnotationImage` objects for identical-looking annotations in your map views. Dequeueing saves time and memory during performance-critical operations such as scrolling. - + @param identifier A string identifying the annotation image to be reused. This string is the same one you specify when initially returning the annotation image object using the `-mapView:imageForAnnotation:` method. @@ -662,7 +662,7 @@ MGL_EXPORT IB_DESIGNABLE /** Returns the list of annotations associated with the receiver that intersect with the given rectangle. - + @param rect A rectangle expressed in the map view’s coordinate system. @return An array of objects that adopt the `MGLAnnotation` protocol or `nil` if no annotations associated with the map view are currently visible in the @@ -674,7 +674,7 @@ MGL_EXPORT IB_DESIGNABLE /** The currently selected annotations. - + Assigning a new array to this property selects only the first annotation in the array. */ @@ -682,30 +682,30 @@ MGL_EXPORT IB_DESIGNABLE /** Selects an annotation and displays a callout popover for it. - + If the given annotation is not visible within the current viewport, this method has no effect. - + @param annotation The annotation object to select. */ - (void)selectAnnotation:(id <MGLAnnotation>)annotation; /** Deselects an annotation and hides its callout popover. - + @param annotation The annotation object to deselect. */ - (void)deselectAnnotation:(nullable id <MGLAnnotation>)annotation; /** A common view controller for managing a callout popover’s content view. - + Like any instance of `NSPopover`, an annotation callout manages its contents with a view controller. The annotation object is the view controller’s represented object. This means that you can bind controls in the view controller’s content view to KVO-compliant properties of the annotation object, such as `title` and `subtitle`. - + This property defines a common view controller that is used for every annotation’s callout view. If you set this property to `nil`, a default view controller will be used that manages a simple title label and subtitle label. @@ -719,7 +719,7 @@ MGL_EXPORT IB_DESIGNABLE /** Returns a point annotation located at the given point. - + @param point A point in the view’s coordinate system. @return A point annotation whose annotation image coincides with the point. If multiple point annotations coincide with the point, the return value is the @@ -731,9 +731,9 @@ MGL_EXPORT IB_DESIGNABLE /** Adds a single overlay to the map. - + To remove an overlay from a map, use the `-removeOverlay:` method. - + @param overlay The overlay object to add. This object must conform to the `MGLOverlay` protocol. */ @@ -741,9 +741,9 @@ MGL_EXPORT IB_DESIGNABLE /** Adds an array of overlays to the map. - + To remove multiple overlays from a map, use the `-removeOverlays:` method. - + @param overlays An array of objects, each of which must conform to the `MGLOverlay` protocol. */ @@ -751,19 +751,19 @@ MGL_EXPORT IB_DESIGNABLE /** Removes a single overlay from the map. - + If the specified overlay is not currently associated with the map view, this method does nothing. - + @param overlay The overlay object to remove. */ - (void)removeOverlay:(id <MGLOverlay>)overlay; /** Removes an array of overlays from the map. - + If a given overlay object is not associated with the map view, it is ignored. - + @param overlays An array of objects, each of which conforms to the `MGLOverlay` protocol. */ @@ -773,12 +773,12 @@ MGL_EXPORT IB_DESIGNABLE /** Returns an array of rendered map features that intersect with a given point. - + This method may return features from any of the map’s style layers. To restrict the search to a particular layer or layers, use the `-visibleFeaturesAtPoint:inStyleLayersWithIdentifiers:` method. For more information about searching for map features, see that method’s documentation. - + @param point A point expressed in the map view’s coordinate system. @return An array of objects conforming to the `MGLFeature` protocol that represent features in the sources used by the current style. @@ -788,13 +788,13 @@ MGL_EXPORT IB_DESIGNABLE /** Returns an array of rendered map features that intersect with a given point, restricted to the given style layers. - + Each object in the returned array represents a feature rendered by the current style and provides access to attributes specified by the relevant <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources">tile sources</a>. The returned array includes features specified in vector and GeoJSON tile sources but does not include anything from raster, image, or video sources. - + Only visible features are returned. For example, suppose the current style uses the <a href="https://www.mapbox.com/vector-tiles/mapbox-streets/">Mapbox Streets source</a>, @@ -807,22 +807,22 @@ MGL_EXPORT IB_DESIGNABLE attributes). The dictionary contains only the attributes provided by the tile source; it does not include computed attribute values or rules about how the feature is rendered by the current style. - + The returned array is sorted by z-order, starting with the topmost rendered feature and ending with the bottommost rendered feature. A feature that is rendered multiple times due to wrapping across the antimeridian at low zoom levels is included only once, subject to the caveat that follows. - + Features come from tiled vector data or GeoJSON data that is converted to tiles internally, so feature geometries are clipped at tile boundaries and features may appear duplicated across tiles. For example, suppose the specified point lies along a road that spans the screen. The resulting array includes those parts of the road that lie within the map tile that contain the specified point, even if the road extends into other tiles. - + To find out the layer names in a particular style, view the style in <a href="https://www.mapbox.com/studio/">Mapbox Studio</a>. - + @note Layer identifiers are not guaranteed to exist across styles or different versions of the same style. Applications that use this API must first set the style URL to an explicitly versioned style using a convenience method like @@ -843,12 +843,12 @@ MGL_EXPORT IB_DESIGNABLE /** Returns an array of rendered map features that intersect with the given rectangle. - + This method may return features from any of the map’s style layers. To restrict the search to a particular layer or layers, use the `-visibleFeaturesAtPoint:inStyleLayersWithIdentifiers:` method. For more information about searching for map features, see that method’s documentation. - + @param rect A rectangle expressed in the map view’s coordinate system. @return An array of objects conforming to the `MGLFeature` protocol that represent features in the sources used by the current style. @@ -858,13 +858,13 @@ MGL_EXPORT IB_DESIGNABLE /** Returns an array of rendered map features that intersect with the given rectangle, restricted to the given style layers. - + Each object in the returned array represents a feature rendered by the current style and provides access to attributes specified by the relevant <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources">tile sources</a>. The returned array includes features specified in vector and GeoJSON tile sources but does not include anything from raster, image, or video sources. - + Only visible features are returned. For example, suppose the current style uses the <a href="https://www.mapbox.com/vector-tiles/mapbox-streets/">Mapbox Streets source</a>, @@ -877,12 +877,12 @@ MGL_EXPORT IB_DESIGNABLE contains only the attributes provided by the tile source; it does not include computed attribute values or rules about how the feature is rendered by the current style. - + The returned array is sorted by z-order, starting with the topmost rendered feature and ending with the bottommost rendered feature. A feature that is rendered multiple times due to wrapping across the antimeridian at low zoom levels is included only once, subject to the caveat that follows. - + Features come from tiled vector data or GeoJSON data that is converted to tiles internally, so feature geometries are clipped at tile boundaries and features may appear duplicated across tiles. For example, suppose the specified @@ -890,10 +890,10 @@ MGL_EXPORT IB_DESIGNABLE includes those parts of the road that lie within the map tiles covering the specified rectangle, even if the road extends into other tiles. The portion of the road within each map tile is included individually. - + To find out the layer names in a particular style, view the style in <a href="https://www.mapbox.com/studio/">Mapbox Studio</a>. - + @note Layer identifiers are not guaranteed to exist across styles or different versions of the same style. Applications that use this API must first set the style URL to an explicitly versioned style using a convenience method like @@ -916,7 +916,7 @@ MGL_EXPORT IB_DESIGNABLE /** Converts a geographic coordinate to a point in the given view’s coordinate system. - + @param coordinate The geographic coordinate to convert. @param view The view in whose coordinate system the returned point should be expressed. If this parameter is `nil`, the returned point is expressed in @@ -930,7 +930,7 @@ MGL_EXPORT IB_DESIGNABLE /** Converts a point in the given view’s coordinate system to a geographic coordinate. - + @param point The point to convert. @param view The view in whose coordinate system the point is expressed. @return The geographic coordinate at the given point. @@ -940,7 +940,7 @@ MGL_EXPORT IB_DESIGNABLE /** Converts a geographic bounding box to a rectangle in the given view’s coordinate system. - + @param bounds The geographic bounding box to convert. @param view The view in whose coordinate system the returned rectangle should be expressed. If this parameter is `nil`, the returned rectangle is @@ -952,7 +952,7 @@ MGL_EXPORT IB_DESIGNABLE /** Converts a rectangle in the given view’s coordinate system to a geographic bounding box. - + @param rect The rectangle to convert. @param view The view in whose coordinate system the rectangle is expressed. @return The geographic bounding box coextensive with the given rectangle. @@ -962,11 +962,11 @@ MGL_EXPORT IB_DESIGNABLE /** Returns the distance spanned by one point in the map view’s coordinate system at the given latitude and current zoom level. - + The distance between points decreases as the latitude approaches the poles. This relationship parallels the relationship between longitudinal coordinates at different latitudes. - + @param latitude The latitude of the geographic coordinate represented by the point. @return The distance in meters spanned by a single point. @@ -978,11 +978,11 @@ MGL_EXPORT IB_DESIGNABLE /** Opens one or more webpages in the default Web browser in which the user can provide feedback about the map data. - + You should add a menu item to the Help menu of your application that invokes this method. Title it “Improve This Map” or similar. Set its target to the first responder and its action to `giveFeedback:`. - + This map view searches the current style’s sources for webpages to open. Specifically, each source’s tile set has an `attribution` property containing HTML code; if an <code><a></code> tag (link) within that code has an @@ -996,7 +996,7 @@ MGL_EXPORT IB_DESIGNABLE /** The options that determine which debugging aids are shown on the map. - + These options are all disabled by default and should remain disabled in released software for performance and aesthetic reasons. */ diff --git a/platform/macos/src/MGLMapView.mm b/platform/macos/src/MGLMapView.mm index 6755c5de62..86d74d768d 100644 --- a/platform/macos/src/MGLMapView.mm +++ b/platform/macos/src/MGLMapView.mm @@ -436,7 +436,7 @@ public: } attributionView.subviews = @[]; [attributionView removeConstraints:attributionView.constraints]; - + // Make the whole string mini by default. // Force links to be black, because the default blue is distracting. CGFloat miniSize = [NSFont systemFontSizeForControlSize:NSMiniControlSize]; @@ -446,7 +446,7 @@ public: if (info.feedbackLink) { continue; } - + // For each attribution, add a borderless button that responds to clicks // and feels like a hyperlink. NSButton *button = [[MGLAttributionButton alloc] initWithAttributionInfo:info]; @@ -483,7 +483,7 @@ public: multiplier:1 constant:0]]; } - + if (attributionInfos.count) { [attributionView addConstraint: [NSLayoutConstraint constraintWithItem:attributionView @@ -615,7 +615,7 @@ public: if (_isTargetingInterfaceBuilder) { return; } - + // Default to Streets. if (!styleURL) { // An access token is required to load any default style, including @@ -1706,12 +1706,12 @@ public: { return nil; } - + std::vector<MGLAnnotationTag> annotationTags = [self annotationTagsInRect:rect]; if (annotationTags.size()) { NSMutableArray *annotations = [NSMutableArray arrayWithCapacity:annotationTags.size()]; - + for (auto const& annotationTag: annotationTags) { if (!_annotationContextsByAnnotationTag.count(annotationTag)) @@ -1721,10 +1721,10 @@ public: MGLAnnotationContext annotationContext = _annotationContextsByAnnotationTag.at(annotationTag); [annotations addObject:annotationContext.annotation]; } - + return [annotations copy]; } - + return nil; } diff --git a/platform/macos/src/MGLMapViewDelegate.h b/platform/macos/src/MGLMapViewDelegate.h index 1cf86263f3..534e28e3a8 100644 --- a/platform/macos/src/MGLMapViewDelegate.h +++ b/platform/macos/src/MGLMapViewDelegate.h @@ -26,10 +26,10 @@ NS_ASSUME_NONNULL_BEGIN /** Tells the delegate that the viewpoint depicted by the map view is about to change. - + This method is called whenever the currently displayed map camera will start changing for any reason. - + @param mapView The map view whose viewpoint will change. @param animated Whether the change will cause an animated effect on the map. */ @@ -37,14 +37,14 @@ NS_ASSUME_NONNULL_BEGIN /** Tells the delegate that the viewpoint depicted by the map view is changing. - + This method is called as the currently displayed map camera changes as part of an animation, whether due to a user gesture or due to a call to a method such as `-[MGLMapView setCamera:animated:]`. During the animation, this method may be called many times to report updates to the viewpoint. Therefore, your implementation of this method should be as lightweight as possible to avoid affecting performance. - + @param mapView The map view whose viewpoint is changing. */ - (void)mapViewCameraIsChanging:(MGLMapView *)mapView; @@ -52,10 +52,10 @@ NS_ASSUME_NONNULL_BEGIN /** Tells the delegate that the viewpoint depicted by the map view has finished changing. - + This method is called whenever the currently displayed map camera has finished changing, after any calls to `-mapViewRegionIsChanging:` due to animation. - + @param mapView The map view whose viewpoint has changed. @param animated Whether the change caused an animated effect on the map. */ @@ -65,20 +65,20 @@ NS_ASSUME_NONNULL_BEGIN /** Tells the delegate that the map view will begin to load. - + This method is called whenever the map view starts loading, including when a new style has been set and the map must reload. - + @param mapView The map view that is starting to load. */ - (void)mapViewWillStartLoadingMap:(MGLMapView *)mapView; /** Tells the delegate that the map view has finished loading. - + This method is called whenever the map view finishes loading, either after the initial load or after a style change has forced a reload. - + @param mapView The map view that has finished loading. */ - (void)mapViewDidFinishLoadingMap:(MGLMapView *)mapView; @@ -86,11 +86,11 @@ NS_ASSUME_NONNULL_BEGIN /** Tells the delegate that the map view was unable to load data needed for displaying the map. - + This method may be called for a variety of reasons, including a network connection failure or a failure to fetch the style from the server. You can use the given error message to notify the user that map data is unavailable. - + @param mapView The map view that is unable to load the data. @param error The reason the data could not be loaded. */ @@ -101,26 +101,26 @@ NS_ASSUME_NONNULL_BEGIN /** Tells the delegate that the map view is about to redraw. - + This method is called any time the map view needs to redraw due to a change in the viewpoint or style property transition. This method may be called very frequently, even moreso than `-mapViewRegionIsChanging:`. Therefore, your implementation of this method should be as lightweight as possible to avoid affecting performance. - + @param mapView The map view that is about to redraw. */ - (void)mapViewWillStartRenderingFrame:(MGLMapView *)mapView; /** Tells the delegate that the map view has just redrawn. - + This method is called any time the map view needs to redraw due to a change in the viewpoint or style property transition. This method may be called very frequently, even moreso than `-mapViewRegionIsChanging:`. Therefore, your implementation of this method should be as lightweight as possible to avoid affecting performance. - + @param mapView The map view that has just redrawn. */ - (void)mapViewDidFinishRenderingFrame:(MGLMapView *)mapView fullyRendered:(BOOL)fullyRendered; @@ -147,7 +147,7 @@ NS_ASSUME_NONNULL_BEGIN /** Returns an annotation image object to mark the given point annotation object on the map. - + @param mapView The map view that requested the annotation image. @param annotation The object representing the annotation that is about to be displayed. @@ -161,7 +161,7 @@ NS_ASSUME_NONNULL_BEGIN A value of 0.0 results in a completely transparent shape. A value of 1.0, the default, results in a completely opaque shape. - + This method sets the opacity of an entire shape, inclusive of its stroke and fill. To independently set the values for stroke or fill, specify an alpha component in the color returned by `-mapView:strokeColorForShapeAnnotation:` or @@ -175,13 +175,13 @@ NS_ASSUME_NONNULL_BEGIN /** Returns the color to use when rendering the outline of a shape annotation. - + The default stroke color is the selected menu item color. If a pattern color is specified, the result is undefined. - + Opacity may be set by specifying an alpha component. The default alpha value is `1.0` and results in a completely opaque stroke. - + @param mapView The map view rendering the shape annotation. @param annotation The annotation being rendered. @return A color to use for the shape outline. @@ -190,13 +190,13 @@ NS_ASSUME_NONNULL_BEGIN /** Returns the color to use when rendering the fill of a polygon annotation. - + The default fill color is the selected menu item color. If a pattern color is specified, the result is undefined. - + Opacity may be set by specifying an alpha component. The default alpha value is `1.0` and results in a completely opaque shape. - + @param mapView The map view rendering the polygon annotation. @param annotation The annotation being rendered. @return The polygon’s interior fill color. @@ -206,9 +206,9 @@ NS_ASSUME_NONNULL_BEGIN /** Returns the line width in points to use when rendering the outline of a polyline annotation. - + By default, the polyline is outlined with a line 3.0 points wide. - + @param mapView The map view rendering the polygon annotation. @param annotation The annotation being rendered. @return A line width for the polyline, measured in points. @@ -219,9 +219,9 @@ NS_ASSUME_NONNULL_BEGIN /** Tells the delegate that one of its annotations has been selected. - + You can use this method to track changes to the selection state of annotations. - + @param mapView The map view containing the annotation. @param annotation The annotation that was selected. */ @@ -229,9 +229,9 @@ NS_ASSUME_NONNULL_BEGIN /** Tells the delegate that one of its annotations has been deselected. - + You can use this method to track changes in the selection state of annotations. - + @param mapView The map view containing the annotation. @param annotation The annotation that was deselected. */ @@ -242,19 +242,19 @@ NS_ASSUME_NONNULL_BEGIN /** Returns a Boolean value indicating whether the annotation is able to display extra information in a callout popover. - + This method is called after an annotation is selected, before any callout is displayed for the annotation. - + If the return value is `YES`, a callout popover is shown when the user clicks on an annotation, selecting it. The default callout displays the annotation’s title and subtitle. You can customize the popover’s contents by implementing the `-mapView:calloutViewControllerForAnnotation:` method. - + If the return value is `NO`, or if this method is absent from the delegate, or if the annotation lacks a title, the annotation will not show a callout even when selected. - + @param mapView The map view that has selected the annotation. @param annotation The object representing the annotation. @return A Boolean value indicating whether the annotation should show a @@ -264,16 +264,16 @@ NS_ASSUME_NONNULL_BEGIN /** Returns a view controller to manage the callout popover’s content view. - + Like any instance of `NSPopover`, an annotation callout manages its contents with a view controller. The annotation object is the view controller’s represented object. This means that you can bind controls in the view controller’s content view to KVO-compliant properties of the annotation object, such as `title` and `subtitle`. - + If each annotation should have an identical callout, you can set the `MGLMapView.calloutViewController` property instead. - + @param mapView The map view that is requesting a callout view controller. @param annotation The object representing the annotation. @return A view controller for the given annotation. diff --git a/platform/macos/src/MGLOpenGLLayer.mm b/platform/macos/src/MGLOpenGLLayer.mm index 16b4042ce1..17ba9951c7 100644 --- a/platform/macos/src/MGLOpenGLLayer.mm +++ b/platform/macos/src/MGLOpenGLLayer.mm @@ -8,9 +8,9 @@ return (MGLMapView *)super.view; } -//- (BOOL)isAsynchronous { +// - (BOOL)isAsynchronous { // return YES; -//} +// } - (BOOL)needsDisplayOnBoundsChange { return YES; diff --git a/platform/macos/src/NSColor+MGLAdditions.mm b/platform/macos/src/NSColor+MGLAdditions.mm index 2a55af5cad..5288f2bc61 100644 --- a/platform/macos/src/NSColor+MGLAdditions.mm +++ b/platform/macos/src/NSColor+MGLAdditions.mm @@ -5,9 +5,9 @@ - (mbgl::Color)mgl_color { CGFloat r, g, b, a; - + [[self colorUsingColorSpaceName:NSCalibratedRGBColorSpace] getRed:&r green:&g blue:&b alpha:&a]; - + return { (float)r, (float)g, (float)b, (float)a }; } diff --git a/platform/macos/test/MGLAttributionButtonTests.m b/platform/macos/test/MGLAttributionButtonTests.m index f5c0aac856..b41de95317 100644 --- a/platform/macos/test/MGLAttributionButtonTests.m +++ b/platform/macos/test/MGLAttributionButtonTests.m @@ -16,12 +16,12 @@ }]; MGLAttributionInfo *info = [[MGLAttributionInfo alloc] initWithTitle:title URL:nil]; MGLAttributionButton *button = [[MGLAttributionButton alloc] initWithAttributionInfo:info]; - + NSRange symbolUnderlineRange; NSNumber *symbolUnderline = [button.attributedTitle attribute:NSUnderlineStyleAttributeName atIndex:0 effectiveRange:&symbolUnderlineRange]; XCTAssertNil(symbolUnderline); XCTAssertEqual(symbolUnderlineRange.length, 6); - + NSRange wordUnderlineRange; NSNumber *wordUnderline = [button.attributedTitle attribute:NSUnderlineStyleAttributeName atIndex:6 effectiveRange:&wordUnderlineRange]; XCTAssertEqualObjects(wordUnderline, @(NSUnderlineStyleSingle)); |