2013-07-03 2 views
0

iPhone 용 앱을 개발 중이며 Google 정적지도 API V2와 내가 가지고있는 CLLocations 배열을 사용하여 폴리 라인으로 Google 정적지도 이미지를 생성하고 싶습니다. 지금은이 코드 조각을 사용하고 있습니다 :Google Static Map API의 인코딩 경로?

NSArray *points = self.pathModel.pathPoints; 
NSString *urlString = @"http://maps.google.com/maps/api/staticmap?path=color:0x80008080%7Cweight:5%7C"; 
for (int i=0; i<points.count; i++) { 
    float latitude = [(CLLocation *)points[i] coordinate].latitude; 
    float longitude = [(CLLocation *)points[i] coordinate].longitude; 
    if (i<points.count-1) { 
     urlString = [urlString stringByAppendingFormat:@"%f,%f%%7C", latitude, longitude]; 
    } else { 
     urlString = [urlString stringByAppendingFormat:@"%f,%f", latitude, longitude]; 
    } 
} 

urlString = [urlString stringByAppendingString:@"&size=640x480&scale=2&sensor=true&key=AIzaSyDjU3Ly8X1TasKvUWgEF8v8uTE5PEU8ci8"]; 

문제는 내가 설명 here로 인코딩 된 경로를 제공하지 않는 한 나는 URL 형식에 포함시킬 수있는 점의 수에 제한이 있다는 것입니다. Google Static Maps API의 위치 정보를 인코딩하는 Objective-C API가 있습니까? 또는 urlString을 직접 인코딩 할 수있는 방법이 있습니까?

Objective-C 유형 솔루션을 찾고 있습니다. 나는 모른다.

답변

0

경로의 인코딩과 디코딩은 이제 google.maps.geometry.encoding 정적 메서드 encodePathdecodePath으로 처리됩니다.

+0

죄송합니다. 명확하지 않지만 Objective-C 솔루션을 찾고 있습니다. 나는 새로운 개발자이고 C 또는 Java를 모른다. – Armin

0

인코딩 목표 - C의 경로 하려면 Google Maps SDK for iOSGMSPath-encodedPath 방법을 사용할 수 있습니다 :

GMSMutablePath* path = [GMSMutablePath path]; 
for(int i=0; i<points.count; i++) 
{ 
    CLLocation* location = points[i]; 
    const CLLocationDegrees latitude = location.coordinate.latitude; 
    const CLLocationDegrees longitude = location.coordinate.longitude; 
    [path addLatitude:latitude longitude:longitude]; 
} 

NSString* encodedPath = [path encodedPath]; 

디코드하려면 동일한 클래스의 +pathFromEncodedPath: 방법을 사용할 수 있습니다.