-
Notifications
You must be signed in to change notification settings - Fork 0
/
MapImageOverlay.m
36 lines (26 loc) · 893 Bytes
/
MapImageOverlay.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#import "MapImageOverlay.h"
@implementation MapImageOverlay
@synthesize coordinate;
@synthesize image;
- (id)initWithImage:(UIImage *) _image withLowerRightCoordinate:(CLLocationCoordinate2D)lowerRight withUpperLeftCoordinate:(CLLocationCoordinate2D)upperLeft;
{
self = [super init];
if (self != nil) {
image = _image;
MKMapPoint upperLeftPoint = MKMapPointForCoordinate(upperLeft);
MKMapPoint lowerRightPoint = MKMapPointForCoordinate(lowerRight);
double width = lowerRightPoint.x - upperLeftPoint.x;
double height = lowerRightPoint.y - upperLeftPoint.y;
mapRect = MKMapRectMake(upperLeftPoint.x, upperLeftPoint.y, width, height);
}
return self;
}
- (CLLocationCoordinate2D)coordinate
{
return MKCoordinateForMapPoint(MKMapPointMake(MKMapRectGetMidX(mapRect), MKMapRectGetMidY(mapRect)));
}
- (MKMapRect)boundingMapRect
{
return mapRect;
}
@end