2009-10-14 4 views
4

내 iPhone 응용 프로그램에서 Google지도를 실행하려고합니다.iPhone 응용 프로그램에서 Google지도 앱을 실행합니다.

시작 부분은 잘 작동하지만 iPhone 3.1 업데이트 (이번에는 주변에 있었던 것 같음) 이후로 현재 위치를 확대하지 않고 미국과 캐나다의지도를 축소합니다. 모든 것이 원래 정상적으로 작동했지만 업데이트가 제대로 작동하지 않는 경우가 있습니다.

다음은 내가 사용해온 문자열입니다. 이것은 iOS 3.0 및 iOS 2.2.1을 사용하는 파트너의 휴대 전화에서 작동하지만 iOS 3.1이 설치된 휴대 전화에서는 캐나다와 미국의지도가 축소되어 표시됩니다.

NSString *name = @"clothing"; 
NSString *latlong = [[NSString alloc] initWithFormat:@"%@,%@", latitudeString, longitudeString]; 

NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?q=%@&mrt=yp&ll=%@", 
         [name stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], 
         [latlong stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];  
[latlong release]; 

모든 도움을 주시면 감사하겠습니다.

미리 감사드립니다.

+0

latitudeString 및 longitudeString에 무엇이 있습니까? 표시된 코드에서 알 수 없습니다. 또한 latlong 변수가 필요하지 않으며 latlong 문자열에 stringByAddingPercentEscapesUsingEncoding이 필요하다고 생각하지 않습니다. 부동 소수점 숫자 여야합니다. – progrmr

+0

다음은 내가 시도한 마지막 문자열입니다. NSURL * aURL = [NSURL URLWithString : @ "http://maps.google.com/maps?q=clothes&ll=45.505,-122.63&radius=30 &z=8"]; 은 또한 다음과 같은 문자열을 시도했습니다 NSURL * aURL. = [NSURL URLWithString : @ "http://maps.google.com/maps?q=liquor&z=13&sll=30.290525,-97.745706"]; NSURL * aURL = [NSURL URLWithString : @ "http : // maps. google.com/maps?q=liquor&ll=45.505,-122.63&mrt=yp&z=13 "]; 감사합니다. – jmurphy

답변

3

이것은 one of my apps에서 사용하는 코드이며 3.1과 잘 작동합니다. Google지도의 매개 변수는 documented here입니다.

CLLocationCoordinate2D stationLocation = ... 

NSString *urlString = [[NSString alloc] 
    initWithFormat:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f&dirflg=d", 
     curLocation.latitude, 
     curLocation.longitude, 
     stationLocation.latitude, 
     stationLocation.longitude]; 

NSURL *aURL = [NSURL URLWithString:urlString]; 
[urlString release]; 
[[UIApplication sharedApplication] openURL:aURL]; 
+0

이것은 내가 필요한 것을 제공하지 못합니다. 한 위치에서 다른 위치로 길 찾기를하는 데 사용되는 것 같습니다. 주어진 위도와 경도에 대한 검색어를 찾고 있는데요 웹 브라우저에서 다음 URL을 사용하면 동물원이 생깁니다. 내 위치 및 검색 결과지도에 표시되지만 내 iPhone 앱에서 동일한 URL을 사용하면 10 개의 검색 결과가있는 미국 및 캐나다의지도가 축소됩니다. \t NSURL * aURL = [NSURL URLWithString : @ "http://maps.google.com/maps?q=clothes&ll=45.505,-122.63"]; \t [urlString release]; \t [[UIApplication sharedApplication] openURL : aURL]; 아이디어가 있으십니까? – jmurphy

+0

나는 모든 검색 결과를 표시하기 위해 Google지도가 축소되어 있다고 생각합니다. & z =를 사용하여지도 확대/축소 수준을 설정하고 & radius =를 사용하여 검색 반경을 설정할 수 있습니다. 이렇게 : http://maps.google.com/maps?q=clothes&ll=45.505,-122.63&radius=30&z=8 – progrmr

+0

불행히도 이것은 작동하지 않았습니다. 3.0과 내 파트너 폰에서 잘 작동하기 때문에 3.1 vs 3.0 문제인 것처럼 보입니다. – jmurphy

관련 문제