网页不显示图片-什么是双核处理器
2023年4月2日发(作者:斐讯)
IOS-OC-⾼德地图根据两个坐标点绘制路线
因为做发车项⽬⽤到⾼德地图,不过两个项⽬⾼德地图百度地图都⽤到过,基本流程都⼀样。
1.导⼊需要的SDK配置。。。
2.
//代理
AMapNaviDriveViewDelegate>
//属性
//地图相关
@property(strong,nonatomic)MAMapView*mapView;
@property(strong,nonatomic)AMapLocationManager*locationManager;
@property(strong,nonatomic)MAPointAnnotation*annotation;//地图标注
@property(nonatomic,strong)AMapRoute*route;//路线规划
//导航
@property(nonatomic,strong)AMapNaviDriveManager*driveManager;
@property(nonatomic,strong)AMapNaviPoint*startPoint;
@property(nonatomic,strong)AMapNaviPoint*endPoint;
//设置代理
anager=[[AMapNaviDriveManageralloc]init];
[anagersetDelegate:self];
//设置起始点坐标
oint=[AMapNaviPointlocationWithLatitude:startLatlongitude:startLon];
nt=[AMapNaviPointlocationWithLatitude:endLatlongitude:endLon];
//进⾏路线规划
[anagercalculateDriveRouteWithStartPoints:@[oint]
endPoints:@[nt]
wayPoints:nil
drivingStrategy:AMapNaviDrivingStrategySingleDefault];
#pragmamark-AMapNaviDriveManagerDelegate路线规划回调
-(void)driveManagerOnCalculateRouteSuccess:(AMapNaviDriveManager*)driveManager
{
NSLog(@"onCalculateRouteSuccess");
//算路成功后显⽰路径
[selfshowNaviRoutes];
}
//绘制路线
-(void)showNaviRoutes
{
if([utescount]<=0)
{
return;
}
[wremoveOverlays:ys];
//将路径显⽰到地图上
for(NSNumber*aRouteIDin[utesallKeys])
{
AMapNaviRoute*aRoute=[[anagernaviRoutes]objectForKey:aRouteID];
intcount=(int)[[aRouterouteCoordinates]count];
//添加路径Polyline
CLLocationCoordinate2Dcoords[count];
for(inti=0;i
{
AMapNaviPoint*coordinate=[[aRouterouteCoordinates]objectAtIndex:i];
coords[i].latitude=[coordinatelatitude];
coords[i].longitude=[coordinatelongitude];
}
MAPolyline*polyline=[MAPolylinepolylineWithCoordinates:coordscount:count];
[waddOverlay:polyline];
}
[wshowAnnotations:tionsanimated:NO];
}
//设置路线颜⾊
-(MAOverlayRenderer*)mapView:(MAMapView*)mapViewrendererForOverlay:(id
{
if([overlayisKindOfClass:[MAPolylineclass]])
{
MAPolylineRenderer*polylineRenderer=[[MAPolylineRendereralloc]initWithPolyline:overlay];
Color=[UIColorblueColor];
dth=5.f;
returnpolylineRenderer;
}
returnnil;
}
更多推荐
高德地图标注
发布评论