在iPhone中使用核心位置查找准确位置时出现问题

在iPhone中使用核心位置查找准确位置时出现问题,iphone,core-location,Iphone,Core Location,我正在为iPhone使用Mapkit框架。我有城市名单和它的著名的地方,旅馆和餐馆。它正在地图上寻找城市和著名的地方。但不是酒店和餐馆 这是我的密码: - (CLLocationCoordinate2D) addressLocation { NSString *strRequest; double latitude = 0, longitude = 0; CLLocationCoordinate2D center; NSString *strAddress = [search

我正在为iPhone使用Mapkit框架。我有城市名单和它的著名的地方,旅馆和餐馆。它正在地图上寻找城市和著名的地方。但不是酒店和餐馆

这是我的密码:

- (CLLocationCoordinate2D) addressLocation {
NSString *strRequest; double latitude = 0, longitude = 0;

    CLLocationCoordinate2D center;

    NSString *strAddress = [searchLocationField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    NSLog(@"Search String:%@",searchLocationField.text);

    strRequest = [NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv", strAddress];

    NSString *strNewResult = [NSString stringWithContentsOfURL:[NSURL URLWithString:strRequest] encoding:NSUTF8StringEncoding error:NULL];

    NSLog(@"StrRequest :- '%@'",strNewResult);

    NSArray *listItems = [strNewResult componentsSeparatedByString:@","];

    if([listItems count] == 4)
    {
        latitude = [[listItems objectAtIndex:2] doubleValue];
        longitude = [[listItems objectAtIndex:3] doubleValue];
    }
    else
    {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Warning"
                                                        message:@"Could Not Find Address"
                                                       delegate:nil
                                              cancelButtonTitle:@"ok"
                                              otherButtonTitles:nil];
        [alert show];
        [alert release];
        }

    center.latitude = latitude;
    center.longitude = longitude;

    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(center, 1000, 1000);
    MKCoordinateRegion adjustRegion = [mapView regionThatFits:region];
    [mapView setRegion:adjustRegion animated:YES];
    return center;
}

是否有任何方法可以找到准确的位置???

您需要在-didUpdateToLocation中监视准确的位置更改。只要[locationManager startUpdatingForLocation]正在运行,就会不断更新您的当前位置


当您使用区域监视时,您只会得到2个事件,-didEnterRegion和-diDextRegion。根据您正在执行的操作,区域监视可能不是此应用程序的最佳工具。

您需要在-didUpdateToLocation中监视确切的位置更改。只要[locationManager startUpdatingForLocation]正在运行,就会不断更新您的当前位置


当您使用区域监视时,您只会得到2个事件,-didEnterRegion和-diDextRegion。根据您所做的工作,区域监控可能不是此应用程序的最佳工具。

不,这不是我想要的。。我找不到当前位置。我通过在地图视图中搜索任何酒店的名称来查找其位置不,这不是我想要的。。我找不到当前位置。我通过在地图视图中搜索任何酒店的名称来查找其位置。您对服务的请求是否对列表中的任何餐厅和酒店作出响应。您对服务的请求是否对列表中的任何餐厅和酒店作出响应。