【问题标题】:iOS mapview multiple address using searchbariOS mapview 使用搜索栏的多个地址
【发布时间】:2013-01-09 13:42:48
【问题描述】:

我是 iOS MapView 的新手,我刚刚创建了 mapviewuisearchbar outlets,如果我在搜索栏中输入一个词,PIN 会显示我的确切位置已经这样做了,

- (void) searchBarSearchButtonClicked:(UISearchBar *)theSearchBar 
{
    NSMutableString *urlString = [NSMutableString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@?output=json",inAddress];

    [urlString setString:[urlString stringByReplacingOccurrencesOfString:@" " withString:@"+"]];

    NSURL *url = [NSURL URLWithString:urlString];

    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
    NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request  delegate:self];

}

最后是缩放我的地图的功能,现在这应该是一件小事。

- (void) zoomMapAndCenterAtLatitude:(double) latitude andLongitude:(double) longitude
{
    MKCoordinateRegion region;
    region.center.latitude  = latitude;
    region.center.longitude = longitude;

    MKCoordinateSpan span;
    span.latitudeDelta  = .005;
    span.longitudeDelta = .005;
    region.span = span;

    [mapView setRegion:region animated:YES];
}

但如果有多个地点与搜索栏关键字匹配,则必须显示多个 PIN.. 示例:如果我输入 HOSPITALS in Washington,则必须显示华盛顿附近的医院 这里可以吗..?请帮帮我。

【问题讨论】:

    标签: objective-c xcode mkmapview


    【解决方案1】:

    您在地图的哪个位置添加图钉/注释? 您可以使用 MKMapView 的 addAnnotations: 方法在地图视图上添加多个注释。

    http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-30
    • 2017-02-18
    • 1970-01-01
    相关资源
    最近更新 更多