0

I'm trying to create an MKPolygon that will cover the entire earth, but can't find the right coordinates.

my code looks like this:

CLLocationCoordinate2D pathCoords[5]={
    CLLocationCoordinate2DMake(0,-90),
    CLLocationCoordinate2DMake(0,90),
    CLLocationCoordinate2DMake(-180,90),
    CLLocationCoordinate2DMake(180,-90),
    CLLocationCoordinate2DMake(0,-90),
};

MKPolygon *result = [MKPolygon polygonWithCoordinates:pathCoords count:5];

I've found this article that can help: http://www-01.ibm.com/support/knowledgecenter/SSEPGG_9.5.0/com.ibm.db2.luw.spatial.topics.doc/doc/geodnew1039296.html

But using those coordinated yields totaly different results in mapKit.

Can anyone help?

  • 1
    CLLocationCoordinate2DMake parameters are latitude, longitude so (-180,90) is invalid (latitude range is -90 to +90). See http://stackoverflow.com/a/8683569/467105 for an example. The comment from @SaltyNuts on that answer has the right coordinate array for iOS 7+. –  Feb 25 '15 at 16:49
  • possible duplicate of [Showing Specific Region Using MapKit](http://stackoverflow.com/questions/8679499/showing-specific-region-using-mapkit) – holex Feb 26 '15 at 09:28

1 Answers1

0

For anyone interested, Anna was right, the code that solves the problem:

CLLocationCoordinate2D worldCoords[6] = { {90, 0}, {90, 180}, {-90,180}, {-90,0}, {-90,-180}, {90,-180} };

(by SaltyNuts)

Community
  • 1
  • 1