AMapPolygon.m
1.4 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#import "AMapPolygon.h"
#import "Coordinate.h"
#pragma ide diagnostic ignored "OCUnusedMethodInspection"
@implementation AMapPolygon {
MAPolygon *_polygon;
MAPolygonRenderer *_renderer;
CGFloat _strokeWidth;
UIColor *_strokeColor;
UIColor *_fillColor;
}
- (void)setCoordinates:(NSArray<Coordinate *> *)coordinates {
CLLocationCoordinate2D coords[coordinates.count];
for (NSUInteger i = 0; i < coordinates.count; i++) {
coords[i] = coordinates[i].coordinate;
}
_polygon = [MAPolygon polygonWithCoordinates:coords count:coordinates.count];
}
- (void)setStrokeWidth:(CGFloat)strokeWidth {
_strokeWidth = strokeWidth;
_renderer.lineWidth = strokeWidth;
}
- (void)setStrokeColor:(UIColor *)strokeColor {
_strokeColor = strokeColor;
_renderer.strokeColor = strokeColor;
}
- (void)setFillColor:(UIColor *)fillColor {
_fillColor = fillColor;
_renderer.fillColor = fillColor;
}
- (CLLocationCoordinate2D)coordinate {
return _polygon.coordinate;
}
- (MAMapRect)boundingMapRect {
return _polygon.boundingMapRect;
}
- (MAOverlayRenderer *)renderer {
if (_strokeColor == nil) {
_strokeColor = UIColor.blackColor;
}
if (_renderer == nil) {
_renderer = [[MAPolygonRenderer alloc] initWithPolygon:_polygon];
_renderer.lineWidth = _strokeWidth;
_renderer.strokeColor = _strokeColor;
_renderer.fillColor = _fillColor;
}
return _renderer;
}
@end