2012-10-26 4 views
0

현재 iPhone 응용 프로그램에서 UIWebview를 사용하여 "America"와 같은 주소를로드 한 다음 응용 프로그램을 실행하면 화면에지도가 표시되지 않습니다. 사용자 입력란에서 입력 한 위치를 표시하고 싶습니다. 어떻게이 iuissue를 고칠 수 있습니까?iPhone에서 webview에서 주소를로드하는 방법은 무엇입니까?

webView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 40, 320,376)]; 
    webView.delegate=self; 
    webView.scalesPageToFit=YES; 
    NSString *mapurl = @"http://maps.google.com/maps?q="; 
    NSString *urlString1 = [mapurl stringByAppendingFormat:@"America"];  
    NSString *OmitSpace = [urlString1 stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; 

    NSURL *url=[NSURL URLWithString:OmitSpace]; 
    NSURLRequest *requestObj=[NSURLRequest requestWithURL:url]; 
    [webView loadRequest:requestObj]; 

스크린 샷 :이 내용은 공백을 생략합니다 enter image description here

답변

1

또 다른 해결책은 .. API의 JSON 응답에 위도와 경도를 발견하고 그 특정 지역을 표시 MKMapView에서 사용하는 googleapis 년대를 사용하는 것입니다

예 ..

http://maps.googleapis.com/maps/api/geocode/json?address=america&sensor=true

결과는 JSON 출력으로, 위도와 경도를 가져 와서 MKMapView

,

또는 iOS 5 및 사용 CLGeocoderMKMapView는 동일한 출력에게 답장을 보내

CLGeocoder *geocoder = [[CLGeocoder alloc] init]; 
    [geocoder geocodeAddressString:@"America" completionHandler:^(NSArray *placemarks, NSError *error) { 
     //Error checking 

     CLPlacemark *placemark = [placemarks objectAtIndex:0]; 
     MKCoordinateRegion region; 
     region.center.latitude = placemark.region.center.latitude; 
     region.center.longitude = placemark.region.center.longitude; 
     MKCoordinateSpan span; 
     double radius = placemark.region.radius/1000; // convert to km 

     NSLog(@"Radius is %f", radius); 
     span.latitudeDelta = radius/112.0; 

     region.span = span; 

     [mapView setRegion:region animated:YES]; 
    }]; 
+0

답장을 보내 주셔서 감사합니다. – SampathKumar

+0

의심스러운 점이 있으시면 – SampathKumar

+0

http://maps.googleapis.com/maps/api/geocode/json?address=america&sensor=true 위도와 경도는 위도와 경도가이 링크에 4 개 있습니다. 가져. – SampathKumar

0
NSString *OmitSpace = [urlString1 stringByReplacingOccurrencesOfString:@" " withString:@"%20"]; 

사전

나에게

감사를 도와주세요 나는이 시도. 다른 이스케이프 문자는 변환하지 않습니다. 그래서 위의 줄을 이것으로 대체하십시오.

NSString *OmitSpace = [urlString1 stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] 
+0

감사를 얻을 수 있습니다. – SampathKumar

+0

시도했지만 sme – SampathKumar

+0

로그 OmitSpace 및 브라우저에서로드하십시오. 올바르게 장착되었는지 확인하십시오. –

관련 문제