Commit f468c060 authored by Qiu Xiang's avatar Qiu Xiang

优化代码

parent 059ce10b
...@@ -163,6 +163,6 @@ import MapView from 'react-native-amap3d' ...@@ -163,6 +163,6 @@ import MapView from 'react-native-amap3d'
- [x] 自定义图标 - [x] 自定义图标
- [x] 折线绘制(Polyline) - [x] 折线绘制(Polyline)
- [x] 多边形绘制(Polygon) - [x] 多边形绘制(Polygon)
- [ ] 圆形绘制(Circle)🚀 - [x] 圆形绘制(Circle)
- [ ] POI 检索 - [ ] POI 检索 🚀
- [ ] 地理编码转换 - [ ] 地理编码转换
...@@ -16,14 +16,7 @@ ...@@ -16,14 +16,7 @@
for (NSUInteger i = 0; i < coordinates.count; i++) { for (NSUInteger i = 0; i < coordinates.count; i++) {
coords[i] = coordinates[i].coordinate; coords[i] = coordinates[i].coordinate;
} }
if (_strokeColor == nil) {
_strokeColor = UIColor.blackColor;
}
_polygon = [MAPolygon polygonWithCoordinates:coords count:coordinates.count]; _polygon = [MAPolygon polygonWithCoordinates:coords count:coordinates.count];
_renderer = [[MAPolygonRenderer alloc] initWithPolygon:_polygon];
_renderer.lineWidth = _strokeWidth;
_renderer.strokeColor = _strokeColor;
_renderer.fillColor = _fillColor;
} }
- (void)setStrokeWidth:(CGFloat)strokeWidth { - (void)setStrokeWidth:(CGFloat)strokeWidth {
...@@ -50,6 +43,13 @@ ...@@ -50,6 +43,13 @@
} }
- (MAOverlayRenderer *)renderer { - (MAOverlayRenderer *)renderer {
if (_strokeColor == nil) {
_strokeColor = UIColor.blackColor;
}
_renderer = [[MAPolygonRenderer alloc] initWithPolygon:_polygon];
_renderer.lineWidth = _strokeWidth;
_renderer.strokeColor = _strokeColor;
_renderer.fillColor = _fillColor;
return _renderer; return _renderer;
} }
......
...@@ -16,14 +16,7 @@ ...@@ -16,14 +16,7 @@
for (NSUInteger i = 0; i < coordinates.count; i++) { for (NSUInteger i = 0; i < coordinates.count; i++) {
coords[i] = coordinates[i].coordinate; coords[i] = coordinates[i].coordinate;
} }
if (_color == nil) {
_color = UIColor.blackColor;
}
_polyline = [MAPolyline polylineWithCoordinates:coords count:coordinates.count]; _polyline = [MAPolyline polylineWithCoordinates:coords count:coordinates.count];
_renderer = [[MAPolylineRenderer alloc] initWithPolyline:_polyline];
_renderer.lineWidth = _width;
_renderer.strokeColor = _color;
_renderer.lineDash = _dashed;
} }
- (void)setWidth:(CGFloat)width { - (void)setWidth:(CGFloat)width {
...@@ -50,6 +43,13 @@ ...@@ -50,6 +43,13 @@
} }
- (MAOverlayRenderer *)renderer { - (MAOverlayRenderer *)renderer {
if (_color == nil) {
_color = UIColor.blackColor;
}
_renderer = [[MAPolylineRenderer alloc] initWithPolyline:_polyline];
_renderer.lineWidth = _width;
_renderer.strokeColor = _color;
_renderer.lineDash = _dashed;
return _renderer; return _renderer;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment