Created
July 9, 2014 10:28
-
-
Save gilserrap/5988b982c3ae7f2ae081 to your computer and use it in GitHub Desktop.
Getting coordinates for a MKPolyline
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)testThis:(MKPolyline *)stepPolyline | |
| { | |
| //route is the MKRoute in this example | |
| //but the polyline can be any MKPolyline | |
| NSUInteger pointCount = stepPolyline.pointCount; | |
| //allocate a C array to hold this many points/coordinates... | |
| CLLocationCoordinate2D *routeCoordinates | |
| = malloc(pointCount * sizeof(CLLocationCoordinate2D)); | |
| //get the coordinates (all of them)... | |
| [stepPolyline getCoordinates:routeCoordinates | |
| range:NSMakeRange(0, pointCount)]; | |
| //this part just shows how to use the results... | |
| NSLog(@"route pointCount = %ld", pointCount); | |
| for (int c=0; c < pointCount; c++) | |
| { | |
| NSLog(@"routeCoordinates[%d] = %f, %f", | |
| c, routeCoordinates[c].latitude, routeCoordinates[c].longitude); | |
| } | |
| //free the memory used by the C array when done with it... | |
| free(routeCoordinates); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment