2つの場所の間にルートを描画しようとしています。そのために私は2つ持っていCLLocation
(startPoint ,endPoint)
ます。MKReverseGeocoder
この2つの場所の後、私はこのように出ました。
- (void)findAddress{
geoCoder1 = [[MKReverseGeocoder alloc] initWithCoordinate:startPoint.coordinate];
geoCoder1.delegate = self;
[geoCoder1 start];
geoCoder2 = [[MKReverseGeocoder alloc] initWithCoordinate:endPoint.coordinate];
geoCoder2.delegate = self;
[geoCoder2 start];
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
if(geocoder==geoCoder1){
NSMutableDictionary *cplace1=[[[NSMutableDictionary alloc]initWithDictionary:[placemark addressDictionary]] autorelease];
NSLog(@"The MKReverseGeocoder Start Point Address %@", cplace1 );
}else{
NSMutableDictionary *cplace2=[[[NSMutableDictionary alloc]initWithDictionary:[placemark addressDictionary]] autorelease];
NSLog(@"The MKReverseGeocoder End Point Address %@", cplace2 );
}
}
出力:-
The MKReverseGeocoder Start Point Address {
City = Bangalore;
Country = India;
CountryCode = IN;
FormattedAddressLines = (
"Grant Rd, Sampangi Rama Nagar",
"Bangalore, Karnataka",
India
);
State = Karnataka;
Street = "Grant Rd";
SubAdministrativeArea = "Bengaluru Rural";
SubLocality = "Sampangi Rama Nagar";
Thoroughfare = "Grant Rd";
}
The MKReverseGeocoder End Point Address {
Country = India;
CountryCode = IN;
FormattedAddressLines = (
"NH47 Bi - Rd",
"Ernakulam, Kerala",
India
);
State = Kerala;
Street = "NH47 Bi - Rd";
SubAdministrativeArea = Ernakulam;
Thoroughfare = "NH47 Bi - Rd";
}
ここで、この2つの場所の間のルートポイントを取得したいと思います。そのために、このように送信NSURLRequest
しました。
- (void)updateRoute {
NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:
@"http://maps.googleapis.com/maps/api/directions/json?origin=%@&destination=%@&mode=%@&sensor=false", startLocation,endLocation,routeMode] ]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
}
問題は、私が合格startLocation
したいということでしendLocation
たNSURLRequest
。では、どの値を割り当てる必要がstartLocation
ありendLocation
、MKReverseGeocoder
デリゲートreturn(cplace1およびcplace2)からですか?