Commit 3802d2db authored by lmj_521aiau@163.com's avatar lmj_521aiau@163.com

no message

parent 93f52b23
No preview for this file type
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#import "ZJCustomAnnotation.h" #import "ZJCustomAnnotation.h"
#import "ZJMapPinchGestureRecognizer.h" #import "ZJMapPinchGestureRecognizer.h"
@interface ZJLocationRemindSelectController ()<SJSliderDelegate, MKMapViewDelegate, UIGestureRecognizerDelegate>{ @interface ZJLocationRemindSelectController ()<CLLocationManagerDelegate, SJSliderDelegate, MKMapViewDelegate, UIGestureRecognizerDelegate>{
BOOL sliderDrag; BOOL sliderDrag;
} }
...@@ -47,9 +47,6 @@ ...@@ -47,9 +47,6 @@
[super viewDidLoad]; [super viewDidLoad];
[self setupMapViewAndUI]; [self setupMapViewAndUI];
// [self setUpSearchApi];
[self getCurrentLocation]; [self getCurrentLocation];
} }
...@@ -83,10 +80,7 @@ ...@@ -83,10 +80,7 @@
///把地图添加至view ///把地图添加至view
[self.view addSubview: _mapView]; [self.view addSubview: _mapView];
[self.view sendSubviewToBack:_mapView]; [self.view sendSubviewToBack:_mapView];
self.circle = [MKCircle circleWithCenterCoordinate:self.mapView.userLocation.location.coordinate radius:_radius];
[self.mapView addOverlay:self.circle];
SJSlider *slider = ({ SJSlider *slider = ({
SJSlider *slider = [SJSlider new]; SJSlider *slider = [SJSlider new];
[self.view addSubview:slider]; [self.view addSubview:slider];
...@@ -111,10 +105,7 @@ ...@@ -111,10 +105,7 @@
self.remarkString = _editModel.remark; self.remarkString = _editModel.remark;
self.addressMainTitleLabel.text = _editModel.address; self.addressMainTitleLabel.text = _editModel.address;
self.addressSubTitleLabel.text = _editModel.addressName; self.addressSubTitleLabel.text = _editModel.addressName;
CLLocationCoordinate2D centerLocationCoordinate = [self.mapView convertPoint:self.mapView.center toCoordinateFromView:self.mapView];
[self.mapView setRegion:MKCoordinateRegionMakeWithDistance( self.mapView.userLocation.location.coordinate, _radius*3, _radius*3) animated:false];
// [self.mapView addGestureRecognizer:[[ZJMapPinchGestureRecognizer alloc] initWithMapView:self.mapView]]; // [self.mapView addGestureRecognizer:[[ZJMapPinchGestureRecognizer alloc] initWithMapView:self.mapView]];
// //
// UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didRecognizePan)]; // UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didRecognizePan)];
...@@ -131,18 +122,18 @@ ...@@ -131,18 +122,18 @@
} }
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{ - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated{
// [self.mapView removeAnnotations:self.mapView.annotations]; [self.mapView removeAnnotations:self.mapView.annotations];
// [self.mapView removeOverlays:self.mapView.overlays]; [self.mapView removeOverlays:self.mapView.overlays];
//
// _centerAnnotation = [[ZJCustomAnnotation alloc] init]; _centerAnnotation = [[ZJCustomAnnotation alloc] init];
// _centerAnnotation.coordinate = self.mapView.centerCoordinate; _centerAnnotation.coordinate = self.mapView.centerCoordinate;
// [self.mapView addAnnotation:_centerAnnotation]; [self.mapView addAnnotation:_centerAnnotation];
//
// self.circle = [MKCircle circleWithCenterCoordinate:self.mapView.centerCoordinate radius:_radius]; self.circle = [MKCircle circleWithCenterCoordinate:self.mapView.centerCoordinate radius:_radius];
// [self.mapView addOverlay:self.circle]; [self.mapView addOverlay:self.circle];
//
// self.location = [[CLLocation alloc] initWithLatitude:mapView.centerCoordinate.latitude longitude:mapView.centerCoordinate.longitude]; self.location = [[CLLocation alloc] initWithLatitude:mapView.centerCoordinate.latitude longitude:mapView.centerCoordinate.longitude];
// [self centerLocation:self.location]; [self centerLocation:self.location];
} }
- (void)centerLocation:(CLLocation *)location { - (void)centerLocation:(CLLocation *)location {
...@@ -174,6 +165,40 @@ ...@@ -174,6 +165,40 @@
}]; }];
} }
-(void)getCurrentLocation {
if (_editModel) {
CLLocationCoordinate2D centerLocationCoordinate = CLLocationCoordinate2DMake(_editModel.lat, _editModel.lon);
[self.mapView setRegion:MKCoordinateRegionMakeWithDistance(centerLocationCoordinate, _radius*3, _radius*3) animated:false];
}else{
self.locationManager = [[CLLocationManager alloc] init];
// 带逆地理信息的一次定位(返回坐标和地址信息)
[self.locationManager setDesiredAccuracy:kCLLocationAccuracyHundredMeters];
self.locationManager.delegate = self;
self.locationManager.distanceFilter = 200;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[self.locationManager startUpdatingLocation];
}
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray<CLLocation *> *)locations API_AVAILABLE(ios(6.0), macos(10.9)){
if ([locations firstObject]) {
[self centerLocation:[locations firstObject]];
self.circle = [MKCircle circleWithCenterCoordinate:[locations firstObject].coordinate radius:_radius];
[self.mapView addOverlay:self.circle];
[self.mapView setRegion:MKCoordinateRegionMakeWithDistance( [locations firstObject].coordinate, _radius*3, _radius*3) animated:false];
[manager stopUpdatingLocation];
}
}
- (IBAction)searchAction:(UIButton *)sender { - (IBAction)searchAction:(UIButton *)sender {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment