IOS将2个GMSMarkers之间的箭头线绘制到谷歌地图中
<p><p>我想用 GMSPolyline 来实现这个类,它可以绘制箭头而不是直线来显示从一个谷歌地图标记到另一个的方向的路径。 Objective C 是否可以使用如下组合继承两个类?
以下是我的锻炼:</p>
<pre><code>#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( > 0){
;
GMSMutablePath *path = ;
GMSMutablePath *currentPath = ;
for (int i = 0; i < ; i++) {
CheckPoints *cp = ;
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(cp.getLatitude , cp.getLongitude);
GMSMarker *marker = ;
//GMSMarker *marker = [ 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 = [ initWithFormat:@"%f", position.latitude];
NSString *tmpLong = [ initWithFormat:@"%f", position.longitude];
marker.snippet = ;
UIColor *color;
GMSPolyline *polyline ;
if (cp.getState ==0) {
color = ;
;
} else {
color = ;
}
if(i > -2){
;
}
polyline = ;
polyline.geodesic = YES;
polyline.strokeWidth = 5.f;
// polyline.strokeColor = ;
GMSStrokeStyle *solidRed = ];
GMSStrokeStyle *solidRGreen = ];
polyline.spans = @[-1],
];
marker.icon = ;
marker.map = mapView_;
polyline.map = mapView_;
}
}
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>不知道您是否仍在寻找答案,但这里有一个选项:将带有自定义箭头图标的 GMSMarker 添加到适当的路径端点,根据给定线段的斜率设置其旋转(arctan dy/dx),并确保将其设置为平面而不是广告牌(因此当用户旋转 View 时它会自然旋转)。截图如下:</p>
<p> <img src="/image/1xQ7C.png" alt="directed GMSPolyline"/> </p></p>
<p style="font-size: 20px;">关于IOS将2个GMSMarkers之间的箭头线绘制到谷歌地图中,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/24235945/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/24235945/
</a>
</p>
页:
[1]