Google Maps Path Encoding

匿名 (未验证) 提交于 2019-12-03 10:24:21

问题:

I'm trying to highlight an area between two polylines like this:

I have calculated the left and right polylines. To highlight the inside I am using a polygon that has points of the left side plus the right side in reverse (to properly close the polygon). The GMSMutablePath has no function to reverse the array so I did this:

       for (NSUInteger i1 = 0; i1 < [reversedRight count]/2; i1 ++)     { NSUInteger i2 = [reversedRight count]-i1;         CLLocationCoordinate2D coord1 = [reversedRight coordinateAtIndex:i1];         CLLocationCoordinate2D coord2 = [reversedRight coordinateAtIndex:i2];         [reversedRight replaceCoordinateAtIndex:i1 withCoordinate:coord2];         [reversedRight replaceCoordinateAtIndex:i2 withCoordinate:coord1];} 

Neither is there anyway to combine the GMSMutable Arrays. So I converted them to an encoded String and the concatenated them:

    NSString *pathLeftSt = pathLeft.encodedPath;     NSString *pathRighSt = reversedRight.encodedPath;      NSString *spaceASCII = @"32";       NSString *combinedPaths = [NSString stringWithFormat:@"%@%@%@", pathLeftSt , spaceASCII, pathRighSt];     fullRectangle = [GMSMutablePath pathFromEncodedPath:combinedPaths]; 

My path generated looks like this (the left and right paths are correct, but the highlighting is way off:

I'm fairly certain my encoding is off. I place "32" between the encoded strings for an ASCII space. The instructions for the encoding algorithm are here: https://developers.google.com/maps/documentation/utilities/polylinealgorithm

Do I need to add something else to properly combine these two strings and place them back into a GMSMutablePath?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!