IOS在谷歌地图上绘制两个GMS标记之间的箭头线

IOS在谷歌地图上绘制两个GMS标记之间的箭头线,ios,google-maps,core-graphics,google-maps-sdk-ios,polyline,Ios,Google Maps,Core Graphics,Google Maps Sdk Ios,Polyline,我想用GMSPolyline实现这个类,它可以画箭头而不是直线来显示从一个谷歌地图标记到另一个谷歌地图标记的路径。目标C是否可以使用下面的组合继承两个类? 以下是我的训练: #import <MessageUI/MessageUI.h> #import <GoogleMaps/GoogleMaps.h> #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> @interface Cla

我想用GMSPolyline实现这个类,它可以画箭头而不是直线来显示从一个谷歌地图标记到另一个谷歌地图标记的路径。目标C是否可以使用下面的组合继承两个类? 以下是我的训练:

#import <MessageUI/MessageUI.h>
#import <GoogleMaps/GoogleMaps.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface ClassA : GMSPolyline {
}

-(void)methodA;

@end

@interface ClassB : UIView {
}

-(void)methodB;

@end

@interface MyPolyline : NSObject {
    ClassA *a;
    ClassB *b;
}

-(void)methodA;
-(void)methodB;

@end




- (void)addMarkers
{
    if([array count] > 0){

        [mapView_ clear];
        GMSMutablePath *path = [GMSMutablePath path];
        GMSMutablePath *currentPath = [GMSMutablePath path];

        for (int i = 0; i < [array count]; i++) {

            CheckPoints *cp = [array objectAtIndex:i];
            CLLocationCoordinate2D position = CLLocationCoordinate2DMake(cp.getLatitude , cp.getLongitude);
            GMSMarker *marker = [GMSMarker markerWithPosition:position];
            //  GMSMarker *marker = [[GMSMarker alloc] init];
            marker.position = position;
            NSLog( @"%d", cp.getState );
            NSLog( @"%f", cp.getLatitude);
            NSLog( @"%f", cp.getLongitude );
            NSLog( @"%@", cp.getDesp );
            marker.title = cp.getDesp;

            NSString *tmpLat = [[NSString alloc] initWithFormat:@"%f", position.latitude];
            NSString *tmpLong = [[NSString alloc] initWithFormat:@"%f", position.longitude];
            marker.snippet = [NSString stringWithFormat:@"%@ %@", tmpLat,tmpLong];
            UIColor *color;
            GMSPolyline *polyline ;
            if (cp.getState ==0) {
                color = [UIColor greenColor];
                [path addLatitude:cp.getLatitude longitude:cp.getLongitude];
            } else {
                color = [UIColor redColor];
            }
            if(i > [array indexOfObject:array.lastObject] -2){
                [currentPath addLatitude:cp.getLatitude longitude:cp.getLongitude];
            }
            polyline = [GMSPolyline polylineWithPath:path];
            polyline.geodesic = YES;
            polyline.strokeWidth = 5.f;
         // polyline.strokeColor = [UIColor redColor];
            GMSStrokeStyle *solidRed = [GMSStrokeStyle solidColor:[UIColor redColor]];
            GMSStrokeStyle *solidRGreen = [GMSStrokeStyle solidColor:[UIColor greenColor]];
            polyline.spans = @[[GMSStyleSpan spanWithStyle:solidRed segments:[array count]-1],
                               [GMSStyleSpan spanWithStyle:solidRGreen segments:2]];
            marker.icon = [GMSMarker markerImageWithColor:color];
            marker.map = mapView_;
            polyline.map = mapView_;
        }

    }
}
#导入
#进口
#进口
#进口
@接口类别A:GMSPolyline{
}
-(无效)方法A;
@结束
@接口ClassB:UIView{
}
-(b)方法b;
@结束
@接口MyPolyline:NSObject{
a类*a;
b类*b;
}
-(无效)方法A;
-(b)方法b;
@结束
-(无效)添加标记
{
如果([数组计数]>0){
[地图视图清除];
GMSMutablePath*path=[GMSMutablePath];
GMSMutablePath*currentPath=[GMSMutablePath];
对于(int i=0;i<[数组计数];i++){
检查点*cp=[array objectAtIndex:i];
CLLocationCoordinate2D位置=CLLocationCoordinate2DMake(cp.getLatitude,cp.getLength);
GMSMarker*marker=[GMSMarker marker with position:position];
//GMSMarker*标记=[[GMSMarker alloc]init];
marker.position=位置;
NSLog(@“%d”,cp.getState);
NSLog(@“%f”,cp.getLatitude);
NSLog(@“%f”,cp.getLongitude);
NSLog(@“%@”,cp.getDesp);
marker.title=cp.getDesp;
NSString*tmpLat=[[NSString alloc]initWithFormat:@“%f”,位置.纬度];
NSString*tmpLong=[[NSString alloc]initWithFormat:@“%f”,position.longitude];
marker.snippet=[NSString stringWithFormat:@“%@%@”,tmpLat,tmpLong];
UIColor*颜色;
GMSPolyline*多段线;
如果(cp.getState==0){
颜色=[UIColor greenColor];
[路径添加纬度:cp.getLatitude经度:cp.getLatitude];
}否则{
颜色=[UIColor redColor];
}
if(i>[array indexOfObject:array.lastObject]-2){
[currentPath addLatitude:cp.getLatitude经度:cp.getLatitude];
}
多段线=[GMSPolyline polylineWithPath:path];
polyline.geodesic=是;
折线.strokeWidth=5.f;
//polyline.strokeColor=[UIColor redColor];
GMSStrokeStyle*solidRed=[GMSStrokeStyle solidColor:[UIColor redColor]];
GMSStrokeStyle*solidRGreen=[GMSStrokeStyle SOLIDCLOR:[UIColor GREENCLOR]];
polyline.span=@[[GMSStyleSpan spanWithStyle:solidRed段:[数组计数]-1],
[GMSStyleSpan spanWithStyle:solidRGreen段:2]];
marker.icon=[GMSMarker markerImageWithColor:color];
marker.map=mapView;
polyline.map=mapView;
}
}
}

不知道您是否仍在寻找答案,但这里有一个选项:将带有自定义箭头图标的GMSMarker添加到相应的路径端点,根据给定线段的坡度(arctan dy/dx)设置其旋转,并确保将其设置为平面而不是布告牌(因此,它会随着用户旋转视图而自然旋转)。下面是一个屏幕截图:


请给出此屏幕截图的代码示例?