Commit c7ab4f9f authored by 放牛的园子's avatar 放牛的园子

完成路径贴图功能,贴图图片需要放入images.xcassets

parent cea0c23e
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
#pragma ide diagnostic ignored "OCUnusedMethodInspection" #pragma ide diagnostic ignored "OCUnusedMethodInspection"
@implementation AMapPathPolyline { @implementation AMapPathPolyline {
MAMultiPolyline *_polyline; MAPolyline *_polyline;
MAMultiTexturePolylineRenderer *_renderer; MAPolylineRenderer *_renderer;
NSArray _images; UIImage *_image;
CGFloat _width; CGFloat _width;
UIColor *_color; UIColor *_color;
NSArray *_colors; NSArray *_colors;
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
- (instancetype)init { - (instancetype)init {
if (self = [super init]) { if (self = [super init]) {
_polyline = [MAMultiPolyline polylineWithCoordinates:nil count:0 drawStyleIndexes:nil]; _polyline = [MAPolyline polylineWithCoordinates:nil count:0];
} }
return self; return self;
...@@ -37,14 +37,9 @@ ...@@ -37,14 +37,9 @@
_renderer.lineWidth = width; _renderer.lineWidth = width;
} }
- (void)setDashed:(BOOL)dashed { - (void)setColor:(UIColor *)color {
_dashed = dashed; _color = color;
_renderer.lineDash = dashed; _renderer.strokeColor = color;
}
- (void)setGradient:(BOOL)gradient {
_gradient = gradient;
_renderer.gradient = gradient;
} }
- (CLLocationCoordinate2D)coordinate { - (CLLocationCoordinate2D)coordinate {
...@@ -55,12 +50,12 @@ ...@@ -55,12 +50,12 @@
return _polyline.boundingMapRect; return _polyline.boundingMapRect;
} }
- (void)setImages:(NSArray<NSString *> *)names { - (void)setImage:(NSString *)name {
NSMutableArray *images = [[NSMutableArray alloc] init];
for (NSUInteger index = 0;index < names.count;index ++) { _image = [UIImage imageNamed:name];
[images addObject:[UIImage imageNamed:names[index]]]; //UIImage *temp = [UIImage imageNamed:@"path8"];
} //_renderer.strokeTextureImages = _images;
_images = images; //[_polyline setDrawStyleIndexes:@[@(1),@(2)]];
} }
- (MAOverlayRenderer *)renderer { - (MAOverlayRenderer *)renderer {
...@@ -68,11 +63,14 @@ ...@@ -68,11 +63,14 @@
_color = UIColor.blackColor; _color = UIColor.blackColor;
} }
if (_renderer == nil) { if (_renderer == nil) {
_renderer = [[MAMultiTexturePolylineRenderer alloc] initWithMultiPolyline:_polyline]; _renderer = [[MAPolylineRenderer alloc] initWithPolyline:_polyline];
_renderer.lineWidth = _width; _renderer.lineWidth = _width;
//_renderer.lineDash = _dashed; _renderer.strokeColor = _color;
//_renderer.gradient = _gradient; //[_renderer loadTexture:[UIImage imageNamed:@"path8"]];
[_renderer loadStrokeTextureImages:_images]; if(_image != nil){
[_renderer loadStrokeTextureImage:_image];
}
//_renderer.strokeTextureImages = _images;
} }
return _renderer; return _renderer;
} }
......
...@@ -20,6 +20,6 @@ RCT_EXPORT_VIEW_PROPERTY(coordinates, CoordinateArray) ...@@ -20,6 +20,6 @@ RCT_EXPORT_VIEW_PROPERTY(coordinates, CoordinateArray)
RCT_EXPORT_VIEW_PROPERTY(width, CGFloat) RCT_EXPORT_VIEW_PROPERTY(width, CGFloat)
RCT_EXPORT_VIEW_PROPERTY(dashed, BOOL) RCT_EXPORT_VIEW_PROPERTY(dashed, BOOL)
RCT_EXPORT_VIEW_PROPERTY(gradient, BOOL) RCT_EXPORT_VIEW_PROPERTY(gradient, BOOL)
RCT_EXPORT_VIEW_PROPERTY(images, NSArray) RCT_EXPORT_VIEW_PROPERTY(image, NSString)
@end @end
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