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

浏览器版本低!无法浏览完整内容,建议升级或更换浏览器。
距离计算
下载开发文档
两点距离计算

根据用户指定的两个坐标点,计算这两个点的实际地理距离。核心代码如下:

//导入工具功能包baidumapapi_utils.framework
#import<baidumapapi_utils/bmkutilscomponent.h>
bmkmappoint point1 =bmkmappointforcoordinate(cllocationcoordinate2dmake(39.915,116.404));bmkmappoint point2 =bmkmappointforcoordinate(cllocationcoordinate2dmake(38.915,115.404));cllocationdistance distance =bmkmetersbetweenmappoints(point1,point2);
点与圆、多边形的位置关系

sdk支持判断点与圆或多边形的位置关系,判断点是否在圆内,或者是否在多边形内。

判断点与圆位置关系的示例代码如下:

//导入工具功能包baidumapapi_utils.framework
#import<baidumapapi_utils/bmkutilscomponent.h>
bool ptincircle =bmkcirclecontainscoordinate(cllocationcoordinate2dmake(39.918,116.408),cllocationcoordinate2dmake(39.915,116.404),1000);

判断点与多边形位置关系的示例代码如下:

//导入工具功能包baidumapapi_utils.framework
#import<baidumapapi_utils/bmkutilscomponent.h>
cllocationcoordinate2d coords[5]={0};
coords[0].latitude=39.965;
coords[0].longitude=116.604;
coords[1].latitude=39.865;
coords[1].longitude=116.604;
coords[2].latitude=39.865;
coords[2].longitude=116.704;
coords[3].latitude=39.905;
coords[3].longitude=116.654;
coords[4].latitude=39.965;
coords[4].longitude=116.704;
bool ptinpolygon =bmkpolygoncontainscoordinate(cllocationcoordinate2dmake(39.918,116.408),coords,5);
点与折线的位置关系

sdk还提供获取折线上与折线外指定位置最近点的方法。核心代码如下:

//导入工具功能包baidumapapi_utils.framework
#import<baidumapapi_utils/bmkutilscomponent.h>
bmkmappoint*polylinepoints =newbmkmappoint[4];
polylinepoints[0]=bmkmappointforcoordinate(cllocationcoordinate2dmake(39.915,116.404));
polylinepoints[1]=bmkmappointforcoordinate(cllocationcoordinate2dmake(39.915,116.454));;
polylinepoints[2]=bmkmappointforcoordinate(cllocationcoordinate2dmake(39.975,116.524));;
polylinepoints[3]=bmkmappointforcoordinate(cllocationcoordinate2dmake(39.855,116.554));
bmkmappoint point =bmkmappointforcoordinate(cllocationcoordinate2dmake(39.815,116.504));
bmkmappoint nearestpoint =bmkgetnearestmappointfrompolyline(point, polylinepoints,4);

上一篇

坐标转换

下一篇

收藏夹

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

网站地图