diff options
author | Jason Wray <friedbunny@users.noreply.github.com> | 2016-07-21 16:35:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-21 16:35:59 -0400 |
commit | 4dd734f040540e7feac6a335d2afec188d67fe77 (patch) | |
tree | 7831d85a75bcf2db94c7e168c3efb37530c3fad4 /platform/macos/app | |
parent | e686d329220767a498f110963acb8dd2e60b1b0d (diff) | |
download | qtlocation-mapboxgl-4dd734f040540e7feac6a335d2afec188d67fe77.tar.gz |
[macos] Add `showAnnotations:` methods (#5749)
SDK
- Ported `showAnnotations:animated:` and `showAnnotations:edgePadding:animated:` from the iOS SDK.
Demo App
- Added "Show All Annotations" debug menu item with ⇧⌘A shortcut key.
- Disabled "Add Animated Annotation" debug menu item when the annotation already shown.
Diffstat (limited to 'platform/macos/app')
-rw-r--r-- | platform/macos/app/Base.lproj/MainMenu.xib | 10 | ||||
-rw-r--r-- | platform/macos/app/MapDocument.m | 18 |
2 files changed, 21 insertions, 7 deletions
diff --git a/platform/macos/app/Base.lproj/MainMenu.xib b/platform/macos/app/Base.lproj/MainMenu.xib index 6b636eb8ad..4d81289314 100644 --- a/platform/macos/app/Base.lproj/MainMenu.xib +++ b/platform/macos/app/Base.lproj/MainMenu.xib @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11163.2" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="15G26a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct"> <dependencies> - <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11163.2"/> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/> </dependencies> <objects> <customObject id="-2" userLabel="File's Owner" customClass="NSApplication"> @@ -505,6 +505,12 @@ <action selector="drawAnimatedAnnotation:" target="-1" id="CYM-WB-s97"/> </connections> </menuItem> + <menuItem title="Show All Annnotations" keyEquivalent="A" id="yMj-uM-8SN"> + <modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/> + <connections> + <action selector="showAllAnnotations:" target="-1" id="ahr-OR-Em2"/> + </connections> + </menuItem> <menuItem title="Remove All Annotations" id="6rC-68-vk0"> <string key="keyEquivalent" base64-UTF8="YES"> CA diff --git a/platform/macos/app/MapDocument.m b/platform/macos/app/MapDocument.m index f30b83274a..81fd85e156 100644 --- a/platform/macos/app/MapDocument.m +++ b/platform/macos/app/MapDocument.m @@ -65,6 +65,7 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio BOOL _randomizesCursorsOnDroppedPins; BOOL _isTouringWorld; BOOL _isShowingPolygonAndPolylineAnnotations; + BOOL _isShowingAnimatedAnnotation; } #pragma mark Lifecycle @@ -329,9 +330,14 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio } } +- (IBAction)showAllAnnotations:(id)sender { + [self.mapView showAnnotations:self.mapView.annotations animated:YES]; +} + - (IBAction)removeAllAnnotations:(id)sender { [self.mapView removeAnnotations:self.mapView.annotations]; _isShowingPolygonAndPolylineAnnotations = NO; + _isShowingAnimatedAnnotation = NO; } - (IBAction)startWorldTour:(id)sender { @@ -409,6 +415,8 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio DroppedPinAnnotation *annotation = [[DroppedPinAnnotation alloc] init]; [self.mapView addAnnotation:annotation]; + _isShowingAnimatedAnnotation = YES; + [NSTimer scheduledTimerWithTimeInterval:1.0/60.0 target:self selector:@selector(updateAnimatedAnnotation:) @@ -632,10 +640,13 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio if (menuItem.action == @selector(dropManyPins:)) { return YES; } + if (menuItem.action == @selector(drawPolygonAndPolyLineAnnotations:)) { + return !_isShowingPolygonAndPolylineAnnotations; + } if (menuItem.action == @selector(drawAnimatedAnnotation:)) { - return YES; + return !_isShowingAnimatedAnnotation; } - if (menuItem.action == @selector(removeAllAnnotations:)) { + if (menuItem.action == @selector(showAllAnnotations:) || menuItem.action == @selector(removeAllAnnotations:)) { return self.mapView.annotations.count > 0; } if (menuItem.action == @selector(startWorldTour:)) { @@ -644,9 +655,6 @@ NS_ARRAY_OF(id <MGLAnnotation>) *MBXFlattenedShapes(NS_ARRAY_OF(id <MGLAnnotatio if (menuItem.action == @selector(stopWorldTour:)) { return _isTouringWorld; } - if (menuItem.action == @selector(drawPolygonAndPolyLineAnnotations:)) { - return !_isShowingPolygonAndPolylineAnnotations; - } if (menuItem.action == @selector(addOfflinePack:)) { NSURL *styleURL = self.mapView.styleURL; return !styleURL.isFileURL; |