1

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

1 Answers1

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
  • Maybe he would prefer object approach using `NSArray`. – Tricertops Feb 07 '13 at 20:57
  • 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