0

I found a lot of example but still I could not success to show a dynamically created MKPolygon on the MKMapView. I have a SQLite db which has coordinates for polygons. I want to read coordinates from db and then create a polygon. It should not be difficult.

First I'm reading the row then I calculate the number of coordinate in record (dbCount) then I'm creating an array like this :

CLLocationCoordinate2D *dbCoord = (CLLocationCoordinate2D *) malloc(sizeof(CLLocationCoordinate2D) * dbCount);

then in a for loop I'm filling coordinates into dbCoord array like this :

  for (something) {
    CLLocationCoordinate2D latLon; 
    latLon.latitude = latFromDb;
    latLon.longitude = lonFromDb;
    dbCoord[recCounter] = latLon;
    recCounter++
  }

but dbCoord array didn't contain all coordinates. recCounter is increasing each loop but there is only one item in this array.

Ufuk Ugur
  • 186
  • 1
  • 17
  • In the `for` loop, `latFromDb` and `lonFromDb` are not changing. Where are they set? It would be better to show the real code instead of what looks like psuedocode. From this vague description, the reasons it's not working are too many. You'll need to do some debugging to narrow the problem down and then post the real code where you've found it's not doing what you think it should be doing. –  Jul 26 '14 at 13:02

1 Answers1

0

finally I found it! the reason is definition of dbCoord

I've added

@property (nonatomic, readonly) CLLocationCoordinate2D *dbCoord;

line into .h file and my code is working now

Ufuk Ugur
  • 186
  • 1
  • 17