ios地图sdk | 百度地图api sdk-凯发k8官方旗舰厅

浏览器版本低!无法浏览完整内容,建议升级或更换浏览器。
绘制3d棱柱
下载开发文档
绘制3d棱柱简介

since6.4.0起ios地图sdk支持3d棱柱(bmkprismoverlay)绘制。提供一组多边形有序序列的点,根据序列点和高度生成3d棱柱。

3d棱柱绘制
1. 添加3d棱柱覆盖物数据
nsstring*filepath =[[nsbundle mainbundle] pathforresource:@"haidian"oftype:@"txt"];
nsstring*pointsstring =[nsstring stringwithcontentsoffile:filepath encoding:nsutf8stringencoding error:nil];
nsarray<nsstring*>*pointsarray =[pointsstring componentsseparatedbystring:@"\n"];
bmkmappoint points[pointsarray.count];
for(nsuinteger i =0; i < pointsarray.count;i){
if([pointsarray[i] rangeofstring:@","].location !=nsnotfound){
nsarray<nsstring*>*tmppoints =[pointsarray[i] componentsseparatedbystring:@","];
points[i]=bmkmappointmake([tmppoints.firstobject doublevalue],[tmppoints.lastobject doublevalue]);
}
}
bmkprismoverlay*_prism =[bmkprismoverlay prismoverlaywithpoints:points count:pointsarray.count];
_prism.height=1000.f;
[_mapview addoverlay:_prism];
2. 实现代理方法生成对应的view(bmkprismoverlayview)
-(bmkoverlayview*)mapview:(bmkmapview*)mapview viewforoverlay:(id<bmkoverlay>)overlay {
if([overlay iskindofclass:[bmkprismoverlayclass]]){
bmkprismoverlayview*prismoverlayview =[[bmkprismoverlayview alloc] initwithprismoverlay:(bmkprismoverlay*)overlay];
if([overlay isequal:_prismoverlay]){
prismoverlayview.sidefacecolor=[uicolor colorwithred:0green:0blue:0.5alpha:1.0];
prismoverlayview.topfacecolor=[uicolor colorwithred:0.0green:0blue:0.5alpha:0.4];
return prismoverlayview;
}
return nil;
}
return nil;
}
3. 运行程序

效果如下:

上一篇

opengl绘制

下一篇

绘制3d建筑物

本篇文章对您是否有帮助?

网站地图