I need to draw a polyline on google maps on ios , I have latitudes and longitudes in seperated arrays and I want to collect them in one array of CLLocationCoordinate2D, so plz help me to write the code that make this collection
Asked
Active
Viewed 218 times
1
-
You have C arrays or `NSArray`s? And what type you expect at the end? – Tricertops Feb 07 '13 at 20:58
1 Answers
1
CLLocationCoordinate2D *coords = malloc(coordinateCount * sizeof(CLLocationCoordinate2D));
for(size_t i = 0; i < coordinateCount; ++i)
{
coords[i].latitude = latitudes[i];
coords[i].longitude = longitudes[i];
}
// ... Use the array ...
free(coords);

warrenm
- 31,094
- 6
- 92
- 116
-
Can you edit your question to include your implementation or at least provide the exception message, because I just ran this code and it worked fine. – warrenm Feb 07 '13 at 18:01
-
-
If the intent is to draw a polyline with MapKit, the end result should be a C array of `CLLocationCoordinate2D`, as that's what the API calls for. Hopefully we'll get clarification from the asker on the type of the original arrays. – warrenm Feb 07 '13 at 21:42