我对 iOS 完全陌生MapView
,我刚刚创建了mapview
outlets uisearchbar
,如果我在搜索栏中输入一个词,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 码。示例:如果我在华盛顿输入医院,则必须显示华盛顿附近的医院。请帮我。