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

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

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