如何获取 当前屏幕上的坐标对应的经纬度

来源:互联网 发布:java方法重载和重写 编辑:程序博客网 时间:2024/05/22 10:52
- (void)locateDataFromServer{    if (self.canLoad) {        self.canLoad = !self.canLoad;        //[self.mapView removeAnnotations:self.mapView.annotations];        //取出当前位置的坐标        CGPoint point = CGPointMake(0, self.view.bounds.size.height-49.0);        CGPoint point1 = CGPointMake(self.view.bounds.size.width, 64.0);        CLLocationCoordinate2D cll = [self.mapView convertPoint:point toCoordinateFromView:self.view];        CLLocationCoordinate2D cll1 = [self.mapView convertPoint:point1 toCoordinateFromView:self.view];        NSLog(@"%f___%f___%f___%f",cll.longitude,cll.latitude,cll1.longitude,cll1.latitude);        NSString *swlng = [NSString stringWithFormat:@"%f",cll.longitude];        NSString *swlat = [NSString stringWithFormat:@"%f",cll.latitude];        NSString *nelng = [NSString stringWithFormat:@"%f",cll1.longitude];        NSString *nelat = [NSString stringWithFormat:@"%f",cll1.latitude];        AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];        NSMutableDictionary *param = [[NSMutableDictionary alloc]init];        [param setObject:@"10" forKey:@"num"];        [param setObject:@"1" forKey:@"page"];        [param setObject:swlng forKey:@"swlng"];        [param setObject:swlat forKey:@"swlat"];        [param setObject:nelng forKey:@"nelng"];        [param setObject:nelat forKey:@"nelat"];        NSString *urlStr = @"你们后台给的关于 地图返回数据的接口";        [manager GET:urlStr parameters:param success:^(AFHTTPRequestOperation *operation, id responseObject) {             NSLog(@"%@",responseObject);            self.canLoad = !self.canLoad;            if ([[responseObject objectForKey:@"code"]isEqualToString:@"101"]) {                NSArray *detailArr = [responseObject objectForKey:@"data"];                for (NSMutableDictionary *dic in detailArr) {                    [self.dataArray addObject:[EGHospitalDetailModel modelWithDictionary:dic]];                }                [self addAnnotationsOnTheMap :nil];            }        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {            self.canLoad = !self.canLoad;        }];    }}
1 0