Skip to content

Commit 49a82e0

Browse files
author
Denis Bogatyrev
committed
Merge branch 'release/1.0.1'
2 parents 9516254 + 34643a7 commit 49a82e0

File tree

8 files changed

+139
-162
lines changed

8 files changed

+139
-162
lines changed

DBMapSelectorViewController.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'DBMapSelectorViewController'
3-
s.version = '1.0.0'
3+
s.version = '1.0.1'
44
s.authors = { 'Denis Bogatyrev' => 'denis.bogatyrev@gmail.com' }
55
s.summary = 'This component allows you to select circular map region from the MKMapView'
66
s.homepage = 'https://github.com/d0ping/DBMapSelectorViewController'

Example/Classes/ViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#import "DBMapSelectorViewController.h"
1010

11-
@interface ViewController : DBMapSelectorViewController <UITextFieldDelegate>
11+
@interface ViewController : DBMapSelectorViewController <DBMapSelectorViewControllerDelegate>
1212

1313
@property (nonatomic, weak) IBOutlet UISwitch *hiddenSwitch;
1414

Example/Classes/ViewController.m

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ @implementation ViewController
2323

2424
#pragma mark - Source
2525

26-
- (void)loadView {
27-
[super loadView];
26+
- (void)viewDidLoad {
27+
[super viewDidLoad];
2828

29+
self.delegate = self;
2930
_mapView.showsUserLocation = YES;
3031

3132
// Set Begin Settings
32-
self.selectorCoordinate = CLLocationCoordinate2DMake(55.75399400, 37.62209300);
33-
self.selectorRadius = 3000;
34-
self.selectorRadiusMax = 25000;
33+
self.circleCoordinate = CLLocationCoordinate2DMake(55.75399400, 37.62209300);
34+
self.circleRadius = 3000;
35+
self.circleRadiusMax = 25000;
36+
[self updateMapRegionForMapSelector];
3537

3638
_fillColorDict = @{@"Orange": [UIColor orangeColor], @"Green": [UIColor greenColor], @"Pure": [UIColor purpleColor], @"Cyan": [UIColor cyanColor], @"Yellow": [UIColor yellowColor], @"Magenta": [UIColor magentaColor]};
3739
_strokeColorDict = @{@"Dark Gray": [UIColor darkGrayColor], @"Black": [UIColor blackColor], @"Brown": [UIColor brownColor], @"Red": [UIColor redColor], @"Blue": [UIColor blueColor]};
@@ -40,27 +42,19 @@ - (void)loadView {
4042
_fillColorPickerView.delegate = self;
4143
_fillColorPickerView.dataSource = self;
4244
_fillColorPickerView.showsSelectionIndicator = YES;
43-
45+
4446
_strokeColorPickerView = [[UIPickerView alloc] init];
4547
_strokeColorPickerView.delegate = self;
4648
_strokeColorPickerView.dataSource = self;
4749
_strokeColorPickerView.showsSelectionIndicator = YES;
4850

4951
NSString *fillColorKey = @"Orange";
5052
_fillColorTextField.text = fillColorKey;
51-
self.selectorFillColor = _fillColorDict[fillColorKey];
53+
self.fillColor = _fillColorDict[fillColorKey];
5254

5355
NSString *strokeColorKey = @"Dark Gray";
5456
_strokeColorTextField.text = strokeColorKey;
55-
self.selectorStrokeColor = _strokeColorDict[strokeColorKey];
56-
57-
58-
[self didChangeCoordinate:self.selectorCoordinate];
59-
[self didChangeRadius:self.selectorRadius];
60-
}
61-
62-
- (void)viewDidLoad {
63-
[super viewDidLoad];
57+
self.strokeColor = _strokeColorDict[strokeColorKey];
6458

6559
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(inputAccessoryViewDidFinish)];
6660
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0,0, 320, 44)];
@@ -71,6 +65,7 @@ - (void)viewDidLoad {
7165

7266
_strokeColorTextField.inputView = _strokeColorPickerView;
7367
_strokeColorTextField.inputAccessoryView = toolbar;
68+
7469
}
7570

7671
- (void)inputAccessoryViewDidFinish {
@@ -81,20 +76,20 @@ - (void)inputAccessoryViewDidFinish {
8176
#pragma mark - Actions
8277

8378
- (IBAction)editingTypeSegmentedControlValueDidChange:(UISegmentedControl *)sender {
84-
self.selectorEditingType = sender.selectedSegmentIndex;
79+
self.editingType = sender.selectedSegmentIndex;
8580
}
8681

8782
- (IBAction)hiddenSwitchValueDidChange:(UISwitch *)sender {
88-
self.selectorHidden = !sender.on;
83+
self.hidden = !sender.on;
8984
}
9085

91-
#pragma mark - DBMapSelectorViewController Protocol
86+
#pragma mark - DBMapSelectorViewController Delegate
9287

93-
- (void)didChangeCoordinate:(CLLocationCoordinate2D)coordinate {
88+
- (void)mapSelectorViewController:(DBMapSelectorViewController *)mapSelectorViewController didChangeCoordinate:(CLLocationCoordinate2D)coordinate {
9489
_coordinateLabel.text = [NSString stringWithFormat:@"Coordinate = {%.5f, %.5f}", coordinate.latitude, coordinate.longitude];
9590
}
9691

97-
- (void)didChangeRadius:(CLLocationDistance)radius {
92+
- (void)mapSelectorViewController:(DBMapSelectorViewController *)mapSelectorViewController didChangeRadius:(CLLocationDistance)radius {
9893
NSString *radiusStr = (radius >= 1000) ? [NSString stringWithFormat:@"%.1f km", radius * .001f] : [NSString stringWithFormat:@"%.0f m", radius];
9994
_radiusLabel.text = [@"Radius = " stringByAppendingString:radiusStr];
10095
}
@@ -120,24 +115,11 @@ - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComp
120115
NSString *colorKey = dict.allKeys[row];
121116
if ([pickerView isEqual:_fillColorPickerView]) {
122117
self.fillColorTextField.text = colorKey;
123-
self.selectorFillColor = _fillColorDict[colorKey];
118+
self.fillColor = _fillColorDict[colorKey];
124119
} else if ([pickerView isEqual:_strokeColorPickerView]) {
125120
self.strokeColorTextField.text = colorKey;
126-
self.selectorStrokeColor = _strokeColorDict[colorKey];
121+
self.strokeColor = _strokeColorDict[colorKey];
127122
}
128123
}
129124

130-
//#pragma mark - UITextField Delegate
131-
//
132-
//- (BOOL) textFieldShouldBeginEditing:(UITextView *)textView {
133-
// _fillColorPickerView.frame = CGRectMake(0, 500, _fillColorPickerView.frame.size.width, _fillColorPickerView.frame.size.height);
134-
// [UIView beginAnimations:nil context:NULL];
135-
// [UIView setAnimationDuration:.3f];
136-
// [UIView setAnimationDelegate:self];
137-
// _fillColorPickerView.frame = CGRectMake(0, 200, _fillColorPickerView.frame.size.width, _fillColorPickerView.frame.size.height);
138-
// [self.view addSubview:_fillColorPickerView];
139-
// [UIView commitAnimations];
140-
// return NO;
141-
//}
142-
143125
@end

Example/DBMapSelectorViewControllerExample/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0.0</string>
18+
<string>1.0.1</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

Example/Resources/Screenshot.jpg

1.81 KB
Loading

README.md

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This component allows you to select circular map region from the MKMapView.
44

5-
![Screenshot of Example](https://github.com/d0ping/DBMapSelectorViewController/blob/develop/Example/Resources/Screenshot.jpg)
5+
![Screenshot of Example](https://github.com/d0ping/DBMapSelectorViewController/blob/master/Example/Resources/Screenshot.jpg)
66

77
## Adding to your project
88

@@ -33,59 +33,64 @@ To use DBMapSelectorViewController in your project you should perform the follow
3333

3434
### Setting
3535

36-
To customize the selector you should set selector properties in the loadView method of your `MyViewController`. Selector properties must be set after execute `[super loadView];`. For example, how it can be implemented:
36+
To customize the selector you should set selector properties in the `viewDidLoad` method of your `MyViewController`. Selector properties must be set after execute `[super viewDidLoad];`.
37+
38+
After you have set the `circleCoordinate` and `circleRadius` parameters manually you must execute `updateMapRegionForMapSelector` method.
39+
40+
For example, how it can be implemented:
3741

3842
```objc
39-
- (void)loadView {
40-
[super loadView];
43+
- (void)viewDidLoad {
44+
[super viewDidLoad];
4145

42-
self.selectorCoordinate = CLLocationCoordinate2DMake(55.75399400, 37.62209300);
43-
self.selectorRadius = 2500;
44-
self.selectorRadiusMin = 500;
45-
self.selectorRadiusMax = 25000;
46+
self.circleCoordinate = CLLocationCoordinate2DMake(55.75399400, 37.62209300);
47+
self.circleRadius = 2500;
48+
self.circleRadiusMin = 500;
49+
self.circleRadiusMax = 25000;
50+
[self updateMapRegionForMapSelector];
4651

47-
self.selectorFillColor = [UIColor purpleColor];
48-
self.selectorStrokeColor = [UIColor darkGrayColor];
52+
self.fillColor = [UIColor purpleColor];
53+
self.strokeColor = [UIColor darkGrayColor];
4954
}
5055
```
5156

5257
### Property list selector
5358

54-
- `DBMapSelectorEditingType selectorEditingType` - Used to specify the selector editing type. Property can equal one of four values:
59+
- `DBMapSelectorEditingType editingType` - Used to specify the selector editing type. Property can equal one of four values:
5560
- `DBMapSelectorEditingTypeFull` allows to edit coordinate and radius,
5661
- `DBMapSelectorEditingTypeCoordinateOnly` allows to edit cooordinate only,
5762
- `DBMapSelectorEditingTypeRadiusOnly` allows to edit radius only,
5863
- `DBMapSelectorEditingTypeNone` read only mode;
59-
- `CLLocationCoordinate2D selectorCoordinate` - Used to specify the selector coordinate;
60-
- `CLLocationDistance selectorRadius` - Used to specify the selector radius. Default is equal 1000 meter;
61-
- `CLLocationDistance selectorRadiusMin` - Used to specify the minimum selector radius. Default is equal 100 meter;
62-
- `CLLocationDistance selectorRadiusMax` - Used to specify the maximum selector radius. Default is equal 10000 meter;
63-
- `BOOL selectorHidden` - Used to hide or show selector. Default is NO;
64-
- `UIColor *selectorFillColor` - Used to specify the selector fill color. Color is used to fill the circular map region;
65-
- `UIColor *selectorStrokeColor` - Used to specify the selector stroke color. Color is used to delimit the circular map region.
64+
- `CLLocationCoordinate2D circleCoordinate` - Used to specify the selector coordinate;
65+
- `CLLocationDistance circleRadius` - Used to specify the selector radius. Default is equal 1000 meter;
66+
- `CLLocationDistance circleRadiusMin` - Used to specify the minimum selector radius. Default is equal 100 meter;
67+
- `CLLocationDistance circleRadiusMax` - Used to specify the maximum selector radius. Default is equal 10000 meter;
68+
- `BOOL hidden` - Used to hide or show selector. Default is NO;
69+
- `UIColor *fillColor` - Used to specify the selector fill color. Color is used to fill the circular map region;
70+
- `UIColor *strokeColor` - Used to specify the selector stroke color. Color is used to delimit the circular map region.
6671

67-
### DBMapSelectorViewControllerProtocol
72+
### DBMapSelectorViewControllerDelegate
6873

69-
Inside the `DBMapSelectorViewController` class is implemented `DBMapSelectorViewControllerProtocol`. It's allows to receive messages when the main properties (coordinate and radius) of the selector will be changed.
74+
To be able to react when the main properties (coordinate and radius) of the selector will be changed you must become delegate DBMapSelectorViewController. DBMapSelectorViewControllerDelegate protocol you can see here:
7075

7176
```objc
72-
@protocol DBMapSelectorViewControllerProtocol <NSObject>
77+
@protocol DBMapSelectorViewControllerDelegate <NSObject>
7378

7479
@optional
75-
- (void)didChangeCoordinate:(CLLocationCoordinate2D)coordinate;
76-
- (void)didChangeRadius:(CLLocationDistance)radius;
80+
- (void)mapSelectorViewController:(DBMapSelectorViewController *)mapSelectorViewController didChangeCoordinate:(CLLocationCoordinate2D)coordinate;
81+
- (void)mapSelectorViewController:(DBMapSelectorViewController *)mapSelectorViewController didChangeRadius:(CLLocationDistance)radius;
7782

7883
@end
7984
```
8085
8186
You can implement these methods in your `MyViewController` class in order to respond to these changes. For example, how it can be implemented in your class:
8287
8388
```objc
84-
- (void)didChangeCoordinate:(CLLocationCoordinate2D)coordinate {
89+
- (void)mapSelectorViewController:(DBMapSelectorViewController *)mapSelectorViewController didChangeCoordinate:(CLLocationCoordinate2D)coordinate {
8590
_coordinateLabel.text = [NSString stringWithFormat:@"Coordinate = {%.5f, %.5f}", coordinate.latitude, coordinate.longitude];
8691
}
8792
88-
- (void)didChangeRadius:(CLLocationDistance)radius {
93+
- (void)mapSelectorViewController:(DBMapSelectorViewController *)mapSelectorViewController didChangeRadius:(CLLocationDistance)radius {
8994
NSString *radiusStr = (radius >= 1000) ? [NSString stringWithFormat:@"%.1f km", radius * .001f] : [NSString stringWithFormat:@"%.0f m", radius];
9095
_radiusLabel.text = [@"Radius = " stringByAppendingString:radiusStr];
9196
}

Source/DBMapSelectorViewController.h

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,19 @@ typedef NS_ENUM(NSInteger, DBMapSelectorEditingType) {
1717
DBMapSelectorEditingTypeNone,
1818
};
1919

20-
@protocol DBMapSelectorViewControllerProtocol <NSObject>
20+
@class DBMapSelectorViewController;
21+
@protocol DBMapSelectorViewControllerDelegate <NSObject>
2122

2223
@optional
23-
- (void)didChangeCoordinate:(CLLocationCoordinate2D)coordinate;
24-
- (void)didChangeRadius:(CLLocationDistance)radius;
24+
- (void)mapSelectorViewController:(DBMapSelectorViewController *)mapSelectorViewController didChangeCoordinate:(CLLocationCoordinate2D)coordinate;
25+
- (void)mapSelectorViewController:(DBMapSelectorViewController *)mapSelectorViewController didChangeRadius:(CLLocationDistance)radius;
2526

2627
@end
2728

2829
@class DBMapSelectorOverlay;
29-
@interface DBMapSelectorViewController : UIViewController <MKMapViewDelegate, DBMapSelectorViewControllerProtocol>
30+
@interface DBMapSelectorViewController : UIViewController <MKMapViewDelegate>
3031

32+
@property (nonatomic, weak) id<DBMapSelectorViewControllerDelegate> delegate;
3133
@property (nonatomic, weak) IBOutlet MKMapView *mapView;
3234

3335
/*!
@@ -38,33 +40,35 @@ typedef NS_ENUM(NSInteger, DBMapSelectorEditingType) {
3840
DBMapSelectorEditingTypeRadiusOnly allows to edit radius only,
3941
DBMapSelectorEditingTypeNone read only mode.
4042
*/
41-
@property (nonatomic, assign) DBMapSelectorEditingType selectorEditingType;
43+
@property (nonatomic, assign) DBMapSelectorEditingType editingType;
4244

4345
/*! @brief Used to specify the selector coordinate */
44-
@property (nonatomic, assign) CLLocationCoordinate2D selectorCoordinate;
46+
@property (nonatomic, assign) CLLocationCoordinate2D circleCoordinate;
4547

4648
/*! @brief Used to specify the selector radius */
47-
@property (nonatomic, assign) CLLocationDistance selectorRadius; // default is equal 1000 meter
49+
@property (nonatomic, assign) CLLocationDistance circleRadius; // default is equal 1000 meter
4850

4951
/*! @brief Used to specify the minimum selector radius */
50-
@property (nonatomic, assign) CLLocationDistance selectorRadiusMin; // default is equal 100 meter
52+
@property (nonatomic, assign) CLLocationDistance circleRadiusMin; // default is equal 100 meter
5153

5254
/*! @brief Used to specify the maximum selector radius */
53-
@property (nonatomic, assign) CLLocationDistance selectorRadiusMax; // default is equal 10000 meter
55+
@property (nonatomic, assign) CLLocationDistance circleRadiusMax; // default is equal 10000 meter
5456

5557
/*! @brief Used to hide or show selector */
56-
@property (nonatomic, getter=isHidden) BOOL selectorHidden; // default is NO
58+
@property (nonatomic, getter=isHidden) BOOL hidden; // default is NO
5759

5860
/*!
5961
@brief Used to specify the selector fill color
6062
@discussion Color is used to fill the circular map region
6163
*/
62-
@property (nonatomic, strong) UIColor *selectorFillColor;
64+
@property (nonatomic, strong) UIColor *fillColor;
6365

6466
/*!
6567
@brief Used to specify the selector stroke color
6668
@discussion Color is used to delimit the circular map region
6769
*/
68-
@property (nonatomic, strong) UIColor *selectorStrokeColor;
70+
@property (nonatomic, strong) UIColor *strokeColor;
71+
72+
- (void)updateMapRegionForMapSelector;
6973

7074
@end

0 commit comments

Comments
 (0)