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?