0
Google지도를로드하는 방법 - 특정 지역 맵 - UItextField에서 사용자가 지정한 주소?Google지도를 iPhone의 지정된 주소로 직접로드하십시오.
Google지도를로드하는 방법 - 특정 지역 맵 - UItextField에서 사용자가 지정한 주소?Google지도를 iPhone의 지정된 주소로 직접로드하십시오.
확인. 나는 해결책을 찾았다. r & d.
다음 코드를 참조하십시오.
-(IBAction)showAddress // after adding the Address into textField - button pressed{
[addressField resignFirstResponder];
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta=0.05;
span.longitudeDelta=0.05;
CLLocationCoordinate2D location = [self addressLocation];
region.span=span;
region.center=location;
if(addAnnotation != nil)
{
[mapView removeAnnotation:addAnnotation];
[addAnnotation release];
addAnnotation=nil;
}
addAnnotation = [ [AddressAnnotation alloc] initWithCoordinate:location];
[mapView setRegion:region animated:TRUE];
[mapView regionThatFits:region];
[mapView addAnnotation:addAnnotation];
}
-(CLLocationCoordinate2D) addressLocation {
// NSString *urlString = [[NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv",[addressField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *urlString=[NSString stringWithFormat:@"http://maps.google.com/maps/geo?q=%@&output=csv",[addressField.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *locationString = [NSString stringWithContentsOfURL:[NSURL URLWithString:urlString]];
NSArray *listItems = [locationString componentsSeparatedByString:@","];
double latitude=0.0;
double longitude=0.0;
if([listItems count] >=4 && [ [listItems objectAtIndex:0] isEqualToString:@"200"])
{
latitude = [ [listItems objectAtIndex:2] doubleValue];
longitude = [ [listItems objectAtIndex:3] doubleValue];
}
else
{
NSLog(@"Error");
}
CLLocationCoordinate2D location;
location.latitude=latitude;
location.longitude=longitude;
return location;
}