Ios 如何将plist的地址更新到Mapview?
我遵循下面的代码,输出可以打印到控制台,但是如何在MapView上更新呢Ios 如何将plist的地址更新到Mapview?,ios,cocoa-touch,mkmapview,Ios,Cocoa Touch,Mkmapview,我遵循下面的代码,输出可以打印到控制台,但是如何在MapView上更新呢 - (void)viewDidLoad { [super viewDidLoad]; /* We have our address */ NSString *oreillyAddress = @"1005 Gravenstein Highway North, Sebastopol, CA 95472, USA"; /* We will later insert the address an
- (void)viewDidLoad {
[super viewDidLoad];
/* We have our address */
NSString *oreillyAddress = @"1005 Gravenstein Highway North, Sebastopol, CA 95472, USA";
/* We will later insert the address and the format that we want our output in, into this API's URL */
NSString *geocodingURL = @"http://maps.google.com/maps/geo?q=%@&output=%@";
/* Insert the address and the output format into the URL */
NSString *finalURL = [NSString stringWithFormat:geocodingURL, oreillyAddress, GOOGLE_OUTPUT_FORMAT_CSV];
/* Now escape the URL using appropriate percentage marks */
finalURL = [finalURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
/* Create our URL */
NSURL *urlToCall = [NSURL URLWithString:finalURL];
/* And a request for the connection using the URL */
NSURLRequest *request = [NSURLRequest requestWithURL:urlToCall];
/* We will put all the connection's received data into this instance of the NSMutableData class */
NSMutableData *newMutableData = [[NSMutableData alloc] init];
self.connectionData = newMutableData;
[newMutableData release];
NSURLConnection *newConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
/* Create the connection and start the downloading of geocoding results */
self.myConnection = newConnection;
[newConnection release];
}
- (void) viewDidUnload{
[super viewDidUnload];
[self.myConnection cancel];
self.myConnection = nil;
self.connectionData = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation {
/* Support all orientations */
return YES;
}
- (void)dealloc {
[myConnection cancel];
[myConnection release];
[connectionData release];
[super dealloc];
}
@end
您必须获得该位置的lat long信息。您必须创建一个采用该协议的类,并使用addAnnotation:方法添加一个实例,该实例存储您到达MKMapView对象的位置。如果位置在地图的显示区域内,则地图视图对象将调用委托方法mapView:viewForAnnotation:以获取要为该注释显示的视图。因此,您必须通过采用MKMapViewDelegate协议成为代理。实现mapView:viewForAnnotation:method以返回MKPinAnnotationView实例或您自己的MKAnnotationView子类
如果该位置不在显示区域内,则使用setRegion:animated:method移动到该位置。@Gere Tan是否有此帮助?你需要进一步的帮助吗?