Last active
December 30, 2015 06:49
-
-
Save raae/7791557 to your computer and use it in GitHub Desktop.
A simple utility class creating MKCoordinateRegions containg Norway
This file contains 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
#import <MapKit/MapKit.h> | |
@interface NorwayMapUtility : NSObject | |
+ (MKCoordinateRegion) regionContainingTheKingdomOfNorway; | |
+ (MKCoordinateRegion) regionContainingMainlandNorway; | |
+ (MKCoordinateRegion) regionContainingMainlandNorwayWithIslands; | |
@end |
This file contains 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
#import "NorwayMapUtility.h" | |
@implementation NorwayMapUtility | |
+ (MKCoordinateRegion) regionContainingTheKingdomOfNorway | |
{ | |
// Includes Svalbard and coastal islands. | |
CLLocationCoordinate2D northPoint = CLLocationCoordinate2DMake(80.829003, 20.342303); | |
CLLocationCoordinate2D westPoint = CLLocationCoordinate2DMake(70.863625, -9.077461); | |
CLLocationCoordinate2D southPoint = CLLocationCoordinate2DMake(57.958511, 7.564528); | |
CLLocationCoordinate2D eastPoint = CLLocationCoordinate2DMake(80.229244, 33.516317); | |
CLLocationCoordinate2D locations[] = { northPoint, westPoint, southPoint, eastPoint }; | |
return [self regionContainingLocations:locations count:4]; | |
} | |
+ (MKCoordinateRegion) regionContainingMainlandNorway | |
{ | |
// Only mainland Norway, without Svalbard and coastal islands. | |
CLLocationCoordinate2D northPoint = CLLocationCoordinate2DMake(71.134022, 27.653785); | |
CLLocationCoordinate2D westPoint = CLLocationCoordinate2DMake(60.81016, 4.94538); | |
CLLocationCoordinate2D southPoint = CLLocationCoordinate2DMake(57.979522, 7.055329); | |
CLLocationCoordinate2D eastPoint = CLLocationCoordinate2DMake(70.289156, 31.064319); | |
CLLocationCoordinate2D locations[] = { northPoint, westPoint, southPoint, eastPoint }; | |
return [self regionContainingLocations:locations count:4]; | |
} | |
+ (MKCoordinateRegion) regionContainingMainlandNorwayWithIslands | |
{ | |
// Mainland Norway plus costal islands, probably the one you want. Does not include Svalbard. | |
CLLocationCoordinate2D northPoint = CLLocationCoordinate2DMake(71.185713, 25.675221); | |
CLLocationCoordinate2D westPoint = CLLocationCoordinate2DMake(61.073354, 4.499171); | |
CLLocationCoordinate2D southPoint = CLLocationCoordinate2DMake(57.95851, 7.564528); | |
CLLocationCoordinate2D eastPoint = CLLocationCoordinate2DMake(70.386844, 31.168594); | |
CLLocationCoordinate2D locations[] = { northPoint, westPoint, southPoint, eastPoint }; | |
return [self regionContainingLocations:locations count:4]; | |
} | |
+ (CLLocationCoordinate2D) center | |
{ | |
CLLocationCoordinate2D center = CLLocationCoordinate2DMake(63.990556, 12.307778); | |
return center; | |
} | |
+ (MKCoordinateRegion) regionContainingLocations: (CLLocationCoordinate2D *) locations count: (NSInteger) count | |
{ | |
MKMapPoint points[count]; | |
for (int i = 0; i < count; i++) { | |
points[i] = MKMapPointForCoordinate(locations[i]); | |
} | |
MKMapRect mapRect = [[MKPolygon polygonWithPoints:points count:4] boundingMapRect]; | |
return MKCoordinateRegionForMapRect(mapRect); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The coordinates are form this wikipedia article: http://no.wikipedia.org/wiki/Liste_over_norske_geografiske_ytterpunkter