diff --git a/.gitignore b/.gitignore index c964cd8..7b26fb7 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,4 @@ DerivedData # you should judge for yourself, the pros and cons are mentioned at: # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control # -#Pods/ +Pods/ diff --git a/Example/Classes/ViewController.m b/Example/Classes/ViewController.m index 7b05a6b..b602018 100644 --- a/Example/Classes/ViewController.m +++ b/Example/Classes/ViewController.m @@ -9,7 +9,7 @@ #import "ViewController.h" #import "DBMapSelectorManager.h" -@interface ViewController () { +@interface ViewController () { NSDictionary *_fillColorDict; NSDictionary *_strokeColorDict; UIPickerView *_fillColorPickerView; @@ -26,6 +26,7 @@ - (DBMapSelectorManager *)mapSelectorManager { if (nil == _mapSelectorManager) { _mapSelectorManager = [[DBMapSelectorManager alloc] initWithMapView:self.mapView]; _mapSelectorManager.delegate = self; + _mapSelectorManager.dataSource = self; } return _mapSelectorManager; } @@ -39,9 +40,7 @@ - (void)viewDidLoad { // Set map selector settings self.mapSelectorManager.circleCoordinate = CLLocationCoordinate2DMake(55.75399400, 37.62209300); - self.mapSelectorManager.circleRadius = 3000; - self.mapSelectorManager.circleRadiusMax = 25000; - [self.mapSelectorManager applySelectorSettings]; + self.mapSelectorManager.circleRadiusFillOutside = 1000; _fillColorDict = @{@"Orange": [UIColor orangeColor], @"Green": [UIColor greenColor], @"Pure": [UIColor purpleColor], @"Cyan": [UIColor cyanColor], @"Yellow": [UIColor yellowColor], @"Magenta": [UIColor magentaColor]}; _strokeColorDict = @{@"Dark Gray": [UIColor darkGrayColor], @"Black": [UIColor blackColor], @"Brown": [UIColor brownColor], @"Red": [UIColor redColor], @"Blue": [UIColor blueColor]}; @@ -99,11 +98,24 @@ - (IBAction)hiddenSwitchValueDidChange:(UISwitch *)sender { - (void)mapSelectorManager:(DBMapSelectorManager *)mapSelectorManager didChangeCoordinate:(CLLocationCoordinate2D)coordinate { _coordinateLabel.text = [NSString stringWithFormat:@"Coordinate = {%.5f, %.5f}", coordinate.latitude, coordinate.longitude]; + self.mapSelectorManager.title = _coordinateLabel.text; + [self.mapSelectorManager applySelectorSettings]; } - (void)mapSelectorManager:(DBMapSelectorManager *)mapSelectorManager didChangeRadius:(CLLocationDistance)radius { NSString *radiusStr = (radius >= 1000) ? [NSString stringWithFormat:@"%.1f km", radius * .001f] : [NSString stringWithFormat:@"%.0f m", radius]; _radiusLabel.text = [@"Radius = " stringByAppendingString:radiusStr]; + self.mapSelectorManager.subtitle = _radiusLabel.text; + [self.mapSelectorManager applySelectorSettings]; +} + +#pragma mark - DBMapSelectorManager DataSource + +- (UIView *)mapSelectorManagerRightCalloutAccessoryView { + UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; + [button setTitle:@"Button" forState:UIControlStateNormal]; + [button setFrame:CGRectMake(0, 0, 62, 31)]; + return button; } #pragma mark - UIPickerView Delegate && DataSource diff --git a/Example/DBMapSelectorViewControllerExample.xcodeproj/project.pbxproj b/Example/DBMapSelectorViewControllerExample.xcodeproj/project.pbxproj index 57a3323..b52e93d 100644 --- a/Example/DBMapSelectorViewControllerExample.xcodeproj/project.pbxproj +++ b/Example/DBMapSelectorViewControllerExample.xcodeproj/project.pbxproj @@ -7,7 +7,7 @@ objects = { /* Begin PBXBuildFile section */ - A40D268C1AE2967B00A511E0 /* DBMapSelectorAnnotation.m in Sources */ = {isa = PBXBuildFile; fileRef = A40D268B1AE2967B00A511E0 /* DBMapSelectorAnnotation.m */; }; + 74DC3DEAB0FEBADD196F2096 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A29981AD0EE6FDD0623D148 /* libPods.a */; }; C3FDCD671AC57B350053FDC7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C3FDCD661AC57B350053FDC7 /* main.m */; }; C3FDCD6A1AC57B350053FDC7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = C3FDCD691AC57B350053FDC7 /* AppDelegate.m */; }; C3FDCD701AC57B350053FDC7 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C3FDCD6E1AC57B350053FDC7 /* Main.storyboard */; }; @@ -15,16 +15,13 @@ C3FDCD8F1AC57C2B0053FDC7 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C3FDCD8C1AC57C2B0053FDC7 /* ViewController.m */; }; C3FDCD901AC57C2B0053FDC7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C3FDCD8E1AC57C2B0053FDC7 /* Images.xcassets */; }; C3FDCD921AC57C710053FDC7 /* MapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3FDCD911AC57C710053FDC7 /* MapKit.framework */; }; - C3FDCDA11AC581DE0053FDC7 /* DBMapSelectorOverlay.m in Sources */ = {isa = PBXBuildFile; fileRef = C3FDCDA01AC581DE0053FDC7 /* DBMapSelectorOverlay.m */; }; - C3FDCDA41AC5830E0053FDC7 /* DBMapSelectorOverlayRenderer.m in Sources */ = {isa = PBXBuildFile; fileRef = C3FDCDA31AC5830E0053FDC7 /* DBMapSelectorOverlayRenderer.m */; }; C3FDCDA91AC6A2060053FDC7 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3FDCDA81AC6A2060053FDC7 /* CoreLocation.framework */; }; - C3FDCDAC1AC6EF450053FDC7 /* DBMapSelectorGestureRecognizer.m in Sources */ = {isa = PBXBuildFile; fileRef = C3FDCDAB1AC6EF450053FDC7 /* DBMapSelectorGestureRecognizer.m */; }; - F7DDE3211AD7AE0D00A67502 /* DBMapSelectorManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F7DDE3201AD7AE0D00A67502 /* DBMapSelectorManager.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - A40D268A1AE2967B00A511E0 /* DBMapSelectorAnnotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBMapSelectorAnnotation.h; sourceTree = ""; }; - A40D268B1AE2967B00A511E0 /* DBMapSelectorAnnotation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBMapSelectorAnnotation.m; sourceTree = ""; }; + 161088D68893F60CE0097D3E /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; + 4A29981AD0EE6FDD0623D148 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 9178E1D3B6FBEE2040B6FD31 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; C3FDCD611AC57B350053FDC7 /* DBMapSelectorViewControllerExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DBMapSelectorViewControllerExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; C3FDCD651AC57B350053FDC7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; C3FDCD661AC57B350053FDC7 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; @@ -36,15 +33,7 @@ C3FDCD8C1AC57C2B0053FDC7 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; C3FDCD8E1AC57C2B0053FDC7 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; C3FDCD911AC57C710053FDC7 /* MapKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MapKit.framework; path = System/Library/Frameworks/MapKit.framework; sourceTree = SDKROOT; }; - C3FDCD9F1AC581DE0053FDC7 /* DBMapSelectorOverlay.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBMapSelectorOverlay.h; sourceTree = ""; }; - C3FDCDA01AC581DE0053FDC7 /* DBMapSelectorOverlay.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBMapSelectorOverlay.m; sourceTree = ""; }; - C3FDCDA21AC5830E0053FDC7 /* DBMapSelectorOverlayRenderer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DBMapSelectorOverlayRenderer.h; sourceTree = ""; }; - C3FDCDA31AC5830E0053FDC7 /* DBMapSelectorOverlayRenderer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DBMapSelectorOverlayRenderer.m; sourceTree = ""; }; C3FDCDA81AC6A2060053FDC7 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; }; - C3FDCDAA1AC6EF450053FDC7 /* DBMapSelectorGestureRecognizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DBMapSelectorGestureRecognizer.h; path = ../../Source/DBMapSelectorGestureRecognizer.h; sourceTree = ""; }; - C3FDCDAB1AC6EF450053FDC7 /* DBMapSelectorGestureRecognizer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DBMapSelectorGestureRecognizer.m; path = ../../Source/DBMapSelectorGestureRecognizer.m; sourceTree = ""; }; - F7DDE31F1AD7AE0D00A67502 /* DBMapSelectorManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DBMapSelectorManager.h; path = ../../Source/DBMapSelectorManager.h; sourceTree = ""; }; - F7DDE3201AD7AE0D00A67502 /* DBMapSelectorManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = DBMapSelectorManager.m; path = ../../Source/DBMapSelectorManager.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -54,20 +43,28 @@ files = ( C3FDCDA91AC6A2060053FDC7 /* CoreLocation.framework in Frameworks */, C3FDCD921AC57C710053FDC7 /* MapKit.framework in Frameworks */, + 74DC3DEAB0FEBADD196F2096 /* libPods.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - A40D26891AE2967B00A511E0 /* MapSelectorAnnotation */ = { + 01AE93ED703B3F7355EAE1C9 /* Pods */ = { isa = PBXGroup; children = ( - A40D268A1AE2967B00A511E0 /* DBMapSelectorAnnotation.h */, - A40D268B1AE2967B00A511E0 /* DBMapSelectorAnnotation.m */, + 161088D68893F60CE0097D3E /* Pods.debug.xcconfig */, + 9178E1D3B6FBEE2040B6FD31 /* Pods.release.xcconfig */, ); - name = MapSelectorAnnotation; - path = ../../Source/MapSelectorAnnotation; + name = Pods; + sourceTree = ""; + }; + 357987647ED8BC61E3B4445C /* Frameworks */ = { + isa = PBXGroup; + children = ( + 4A29981AD0EE6FDD0623D148 /* libPods.a */, + ); + name = Frameworks; sourceTree = ""; }; C3FDCD581AC57B350053FDC7 = { @@ -79,6 +76,8 @@ C3FDCD8A1AC57C2B0053FDC7 /* Classes */, C3FDCD8D1AC57C2B0053FDC7 /* Resources */, C3FDCD621AC57B350053FDC7 /* Products */, + 01AE93ED703B3F7355EAE1C9 /* Pods */, + 357987647ED8BC61E3B4445C /* Frameworks */, ); sourceTree = ""; }; @@ -113,7 +112,6 @@ C3FDCD8A1AC57C2B0053FDC7 /* Classes */ = { isa = PBXGroup; children = ( - C3FDCD931AC57C860053FDC7 /* DBMapSelectorViewController */, C3FDCD6E1AC57B350053FDC7 /* Main.storyboard */, C3FDCD8B1AC57C2B0053FDC7 /* ViewController.h */, C3FDCD8C1AC57C2B0053FDC7 /* ViewController.m */, @@ -129,31 +127,6 @@ path = Resources; sourceTree = ""; }; - C3FDCD931AC57C860053FDC7 /* DBMapSelectorViewController */ = { - isa = PBXGroup; - children = ( - F7DDE31F1AD7AE0D00A67502 /* DBMapSelectorManager.h */, - F7DDE3201AD7AE0D00A67502 /* DBMapSelectorManager.m */, - C3FDCDAA1AC6EF450053FDC7 /* DBMapSelectorGestureRecognizer.h */, - C3FDCDAB1AC6EF450053FDC7 /* DBMapSelectorGestureRecognizer.m */, - A40D26891AE2967B00A511E0 /* MapSelectorAnnotation */, - C3FDCD9B1AC5805B0053FDC7 /* MapSelectorOverlay */, - ); - name = DBMapSelectorViewController; - sourceTree = ""; - }; - C3FDCD9B1AC5805B0053FDC7 /* MapSelectorOverlay */ = { - isa = PBXGroup; - children = ( - C3FDCD9F1AC581DE0053FDC7 /* DBMapSelectorOverlay.h */, - C3FDCDA01AC581DE0053FDC7 /* DBMapSelectorOverlay.m */, - C3FDCDA21AC5830E0053FDC7 /* DBMapSelectorOverlayRenderer.h */, - C3FDCDA31AC5830E0053FDC7 /* DBMapSelectorOverlayRenderer.m */, - ); - name = MapSelectorOverlay; - path = ../../Source/MapSelectorOverlay; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -161,9 +134,11 @@ isa = PBXNativeTarget; buildConfigurationList = C3FDCD841AC57B350053FDC7 /* Build configuration list for PBXNativeTarget "DBMapSelectorViewControllerExample" */; buildPhases = ( + 4FCCA57F166099BBE44DD436 /* Check Pods Manifest.lock */, C3FDCD5D1AC57B350053FDC7 /* Sources */, C3FDCD5E1AC57B350053FDC7 /* Frameworks */, C3FDCD5F1AC57B350053FDC7 /* Resources */, + 59994EE9BAFA4F27F2DB8C93 /* Copy Pods Resources */, ); buildRules = ( ); @@ -219,18 +194,46 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 4FCCA57F166099BBE44DD436 /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; + 59994EE9BAFA4F27F2DB8C93 /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ C3FDCD5D1AC57B350053FDC7 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - F7DDE3211AD7AE0D00A67502 /* DBMapSelectorManager.m in Sources */, C3FDCD8F1AC57C2B0053FDC7 /* ViewController.m in Sources */, - C3FDCDA41AC5830E0053FDC7 /* DBMapSelectorOverlayRenderer.m in Sources */, - C3FDCDA11AC581DE0053FDC7 /* DBMapSelectorOverlay.m in Sources */, - A40D268C1AE2967B00A511E0 /* DBMapSelectorAnnotation.m in Sources */, C3FDCD6A1AC57B350053FDC7 /* AppDelegate.m in Sources */, - C3FDCDAC1AC6EF450053FDC7 /* DBMapSelectorGestureRecognizer.m in Sources */, C3FDCD671AC57B350053FDC7 /* main.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -338,6 +341,7 @@ }; C3FDCD851AC57B350053FDC7 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 161088D68893F60CE0097D3E /* Pods.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; @@ -349,6 +353,7 @@ }; C3FDCD861AC57B350053FDC7 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 9178E1D3B6FBEE2040B6FD31 /* Pods.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; diff --git a/Example/DBMapSelectorViewControllerExample.xcworkspace/contents.xcworkspacedata b/Example/DBMapSelectorViewControllerExample.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..0d26076 --- /dev/null +++ b/Example/DBMapSelectorViewControllerExample.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Example/Podfile b/Example/Podfile new file mode 100644 index 0000000..d33de5f --- /dev/null +++ b/Example/Podfile @@ -0,0 +1,4 @@ +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '6.0' + +pod 'DBMapSelectorViewController', path: '../' \ No newline at end of file diff --git a/Example/Podfile.lock b/Example/Podfile.lock new file mode 100644 index 0000000..7d4fcb5 --- /dev/null +++ b/Example/Podfile.lock @@ -0,0 +1,14 @@ +PODS: + - DBMapSelectorViewController (1.2.1) + +DEPENDENCIES: + - DBMapSelectorViewController (from `../`) + +EXTERNAL SOURCES: + DBMapSelectorViewController: + :path: "../" + +SPEC CHECKSUMS: + DBMapSelectorViewController: b4b38dcd1ed10eba7b8b7a94d4376dd35bdbfce6 + +COCOAPODS: 0.37.2 diff --git a/Source/DBMapSelectorManager.h b/Source/DBMapSelectorManager.h index 8c5641d..c774dd7 100644 --- a/Source/DBMapSelectorManager.h +++ b/Source/DBMapSelectorManager.h @@ -28,10 +28,20 @@ typedef NS_ENUM(NSInteger, DBMapSelectorEditingType) { @end +@protocol DBMapSelectorManagerDataSource + +@optional +- (UIView *)mapSelectorManagerLeftCalloutAccessoryView; +- (UIView *)mapSelectorManagerRightCalloutAccessoryView; + +@end + + @class DBMapSelectorOverlay; @interface DBMapSelectorManager : NSObject @property (nonatomic, weak) id delegate; +@property (nonatomic, weak) id dataSource; @property (nonatomic, strong, readonly) MKMapView *mapView; /*! @@ -56,6 +66,24 @@ typedef NS_ENUM(NSInteger, DBMapSelectorEditingType) { /*! @brief Used to specify the maximum selector radius */ @property (nonatomic, assign) CLLocationDistance circleRadiusMax; // default is equal 10000 meter +/*! + @brief Used to specify outer Radis for fill outside + @discussion Total outer radius will be circleRadius plus this + */ +@property (nonatomic, assign) CLLocationDistance circleRadiusFillOutside; + +/*! + @brief Used to show a callout + @discussion title shown in the callout + */ +@property (nonatomic, strong) NSString *title; + +/*! + @brief Used to show a callout + @discussion subtitle shown in the callout + */ +@property (nonatomic, strong) NSString *subtitle; + /*! @brief Used to hide or show selector */ @property (nonatomic, getter=isHidden) BOOL hidden; // default is NO @@ -74,6 +102,12 @@ typedef NS_ENUM(NSInteger, DBMapSelectorEditingType) { */ @property (nonatomic, strong) UIColor *strokeColor; +/*! + @brief PinColor + @discussion Color of the dropped Pin + */ +@property (nonatomic) MKPinAnnotationColor pinColor; + /*! @brief The magnification factor maps region after changing the selector settings @discussion It is recommended to set a value greater than 1.f diff --git a/Source/DBMapSelectorManager.m b/Source/DBMapSelectorManager.m index 42a21a9..cfac835 100644 --- a/Source/DBMapSelectorManager.m +++ b/Source/DBMapSelectorManager.m @@ -13,7 +13,6 @@ #import "DBMapSelectorOverlayRenderer.h" #import "DBMapSelectorManager.h" - NSInteger const defaultRadius = 1000; NSInteger const defaultMinDistance = 100; NSInteger const defaultMaxDistance = 10000; @@ -42,6 +41,7 @@ - (instancetype)initWithMapView:(MKMapView *)mapView { if (self) { _isFirstTimeApplySelectorSettings = YES; _mapView = mapView; + _pinColor = MKPinAnnotationColorGreen; [self prepareForFirstUse]; } return self; @@ -51,14 +51,14 @@ - (void)prepareForFirstUse { [self selectorSetDefaults]; _selectorOverlay = [[DBMapSelectorOverlay alloc] initWithCenterCoordinate:_circleCoordinate radius:_circleRadius]; - + #ifdef DEBUG _radiusTouchView = [[UIView alloc] initWithFrame:CGRectZero]; _radiusTouchView.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:.5f]; _radiusTouchView.userInteractionEnabled = NO; -// [self.mapView addSubview:_radiusTouchView]; + //[self.mapView addSubview:_radiusTouchView]; #endif - + _longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressGestureRecognizer:)]; _mapViewGestureEnabled = YES; @@ -102,7 +102,7 @@ - (DBMapSelectorGestureRecognizer *)selectorGestureRecognizer { selectorGestureRecognizer.touchesBeganCallback = ^(NSSet * touches, UIEvent * event) { UITouch *touch = [touches anyObject]; CGPoint touchPoint = [touch locationInView:weakSelf.mapView]; -// NSLog(@"---- %@", CGRectContainsPoint(_selectorRadiusRect, p) ? @"Y" : @"N"); + //NSLog(@"---- %@", CGRectContainsPoint(_selectorRadiusRect, p) ? @"Y" : @"N"); CLLocationCoordinate2D coord = [weakSelf.mapView convertPoint:touchPoint toCoordinateFromView:weakSelf.mapView]; MKMapPoint mapPoint = MKMapPointForCoordinate(coord); @@ -140,12 +140,12 @@ - (DBMapSelectorGestureRecognizer *)selectorGestureRecognizer { selectorGestureRecognizer.touchesEndedCallback = ^(NSSet * touches, UIEvent * event) { weakSelf.mapView.scrollEnabled = YES; weakSelf.mapView.userInteractionEnabled = YES; - + if (_prevRadius != weakSelf.circleRadius) { [weakSelf recalculateRadiusTouchRect]; -// if (((_prevRadius / weakSelf.circleRadius) >= 1.25f) || ((_prevRadius / weakSelf.circleRadius) <= .75f)) { - [weakSelf updateMapRegionForMapSelector]; -// } + //if (((_prevRadius / weakSelf.circleRadius) >= 1.25f) || ((_prevRadius / weakSelf.circleRadius) <= .75f)) { + [weakSelf updateMapRegionForMapSelector]; + //} } if(!_mapViewGestureEnabled) { if (_delegate && [_delegate respondsToSelector:@selector(mapSelectorManagerDidHandleUserInteraction:)]) { @@ -211,6 +211,11 @@ - (void)setCircleRadiusMin:(CLLocationDistance)circleRadiusMin { } } +- (void)setCircleRadiusFillOutside:(CLLocationDistance)circleRadiusFillOutside { + _circleRadiusFillOutside = circleRadiusFillOutside; + _selectorOverlay.radiusFillOutside = _circleRadiusFillOutside; +} + - (void)setCircleCoordinate:(CLLocationCoordinate2D)circleCoordinate { if ((_circleCoordinate.latitude != circleCoordinate.latitude) || (_circleCoordinate.longitude != circleCoordinate.longitude)) { _circleCoordinate = circleCoordinate; @@ -319,7 +324,7 @@ - (void)displaySelectorAnnotationIfNeeded { } if (_hidden == NO && ((_editingType == DBMapSelectorEditingTypeFull) || (_editingType == DBMapSelectorEditingTypeCoordinateOnly))) { - DBMapSelectorAnnotation *selectorAnnotation = [[DBMapSelectorAnnotation alloc] init]; + DBMapSelectorAnnotation *selectorAnnotation = [[DBMapSelectorAnnotation alloc] initWithTitle:_title andSubTitle:_subtitle]; selectorAnnotation.coordinate = _circleCoordinate; [self.mapView addAnnotation:selectorAnnotation]; } @@ -334,10 +339,19 @@ - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id0); selectorAnnotationView.selected = YES; return selectorAnnotationView; } else { diff --git a/Source/MapSelectorAnnotation/DBMapSelectorAnnotation.h b/Source/MapSelectorAnnotation/DBMapSelectorAnnotation.h index 150b68d..36039fd 100644 --- a/Source/MapSelectorAnnotation/DBMapSelectorAnnotation.h +++ b/Source/MapSelectorAnnotation/DBMapSelectorAnnotation.h @@ -11,4 +11,6 @@ @interface DBMapSelectorAnnotation : NSObject +- (id)initWithTitle:(NSString *)title andSubTitle:(NSString *)subtitle; + @end diff --git a/Source/MapSelectorAnnotation/DBMapSelectorAnnotation.m b/Source/MapSelectorAnnotation/DBMapSelectorAnnotation.m index 0037b3e..d7a1d22 100644 --- a/Source/MapSelectorAnnotation/DBMapSelectorAnnotation.m +++ b/Source/MapSelectorAnnotation/DBMapSelectorAnnotation.m @@ -11,6 +11,17 @@ @implementation DBMapSelectorAnnotation @synthesize coordinate = _coordinate; +@synthesize title = _title; +@synthesize subtitle = _subtitle; + +- (id)initWithTitle:(NSString *)title andSubTitle:(NSString *)subtitle { + self = [self init]; + if (self) { + _title = title; + _subtitle = subtitle; + } + return self; +} - (void)setCoordinate:(CLLocationCoordinate2D)coordinate { _coordinate = coordinate; diff --git a/Source/MapSelectorOverlay/DBMapSelectorOverlay.h b/Source/MapSelectorOverlay/DBMapSelectorOverlay.h index 41e7c2f..0f0a679 100644 --- a/Source/MapSelectorOverlay/DBMapSelectorOverlay.h +++ b/Source/MapSelectorOverlay/DBMapSelectorOverlay.h @@ -13,6 +13,7 @@ @property (nonatomic, assign) CLLocationCoordinate2D coordinate; @property (nonatomic, assign) CLLocationDistance radius; +@property (nonatomic, assign) CLLocationDistance radiusFillOutside; @property (nonatomic, assign) BOOL editingCoordinate; @property (nonatomic, assign) BOOL editingRadius; @property (nonatomic, assign) BOOL fillInside; diff --git a/Source/MapSelectorOverlay/DBMapSelectorOverlayRenderer.m b/Source/MapSelectorOverlay/DBMapSelectorOverlayRenderer.m index 55aa968..e59eea5 100644 --- a/Source/MapSelectorOverlay/DBMapSelectorOverlayRenderer.m +++ b/Source/MapSelectorOverlay/DBMapSelectorOverlayRenderer.m @@ -83,14 +83,18 @@ - (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContex CGContextSetShouldAntialias(context, YES); if (NO == _selectorOverlay.fillInside) { - - CGRect rect = [self rectForMapRect:mapRect]; - CGContextSaveGState(context); - CGContextAddRect(context, rect); - CGContextSetFillColorWithColor(context, [self.fillColor colorWithAlphaComponent:.2f].CGColor); - CGContextFillRect(context, rect); - CGContextRestoreGState(context); - + if (_selectorOverlay.radiusFillOutside) { + CGContextSetFillColorWithColor(context, [self.fillColor colorWithAlphaComponent:.2f].CGColor); + CGContextAddArc(context, overlayRect.origin.x, overlayRect.origin.y, radiusAtLatitude + (_selectorOverlay.radiusFillOutside * MKMapPointsPerMeterAtLatitude([[self overlay] coordinate].latitude)), 0, 2 * M_PI, true); + CGContextDrawPath(context, kCGPathFillStroke); + } else { + CGRect rect = [self rectForMapRect:mapRect]; + CGContextSaveGState(context); + CGContextAddRect(context, rect); + CGContextSetFillColorWithColor(context, [self.fillColor colorWithAlphaComponent:.2f].CGColor); + CGContextFillRect(context, rect); + CGContextRestoreGState(context); + } CGContextSaveGState(context); CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor); CGContextSetBlendMode(context, kCGBlendModeClear);