|
|
(未显示1个用户的11个中间版本) |
第1行: |
第1行: |
− | <div id="examples_center"> | + | <div id="examples_center"><!-- 页面标题 --><div class="title-hd">步行AR导航</div><!-- 标题下子标题及简介,可有多个 --><div class="title-mi">功能场景</div><div class="wrap-mi">在景区、出行app中,可以展示真实街景,并且通过虚拟路标,引导用户到达目的地。</div><!-- --></div><div class="demos_wrap"><div class="header"><div class="andiord-header active">Android</div><div class="ios-header hide">iOS</div></div><div class="andiord-wrap wrap"><div class="wrap-wp"><div class="wrap_left"><div class="left-video"><div class="img-bg-and"></div><div class="phone-android"><div class="video-wrap infor"><div class="video-control"></div><!-- 安卓视频位置 (不写协议)--><pre>//mapopen-website-wiki.bj.bcebos.com/demos/AndroidVideos/AR步行导航.mp4</pre> |
− | <!-- 页面标题 -->
| + | </div><div class="video-icon-and"><div class="play play-and"></div><div class="stop stop-and"></div></div></div><div class="progressWrap-hide-and"></div><div id="videoControls-and"><div id="progressWrap-and"><div id="playProgress-and"></div></div></div></div><div class="left-qrCode" style="display: none;"><!-- 安卓二维码位置 --><div class="qrCode-and">1590746640|</div><div>扫码体验</div></div></div><div class="wrap_right"><div class="wrap_right_nav"><div class="wrap_right_nav_l"><div>使用产品</div><div><!-- 安卓使用产品下选项,可有多个 --><div class="documentA">Android地图SDK|/index.php?title=androidsdk</div><!-- --><div>></div><div class="documentA">步行AR导航|/index.php?title=androidsdk/guide/navigation/walknavi</div></div></div></div><div style="font-size: 16px;color: #333333;margin-bottom: 18px;">使用流程</div><div style="font-size: 14px;">本示例展示效果是地图SDK高级服务,请填写<div class="documentA" style="display: inline;">工单|/apiconsole/fankui#?typeOne=产品需求&typeTwo=高级服务</div>申请试用。</div></div></div></div><div class="ios-wrap wrap" style="display: none;"><div class="wrap-wp"><div class="wrap_left"><div class="left-video"><div class="img-bg-ios-sh"></div><div class="phone-ios"><div class="video-wrap infor"><div class="video-control"></div><!-- ios视频位置 --><pre>//mapopen-website-wiki.bj.bcebos.com/demos/iosVideos/iOS平滑移动.mov</pre> |
− | <div class="title-hd">AR步行导航</div><!-- 标题下子标题及简介,可有多个 -->
| + | </div><div class="video-icon-ios"><div class="play play-ios"></div><div class="stop stop-ios"></div></div></div><div class="progressWrap-hide-ios"></div><div id="videoControls-ios"><div id="progressWrap-ios"><div id="playProgress-ios"></div></div></div></div><div class="left-qrCode"><!-- ios二维码位置 --><div class="qrCode-ios">//mapopen-website-wiki.bj.bcebos.com/demos/play.png</div><div>扫码手机观看</div></div></div><div class="wrap_right"><div class="wrap_right_nav"><div class="wrap_right_nav_l"><div>使用产品</div><div><!-- IOS使用产品下选项,可有多个 --><div class="documentA">iOS地图SDK|/index.php?title=iossdk</div><!-- --><div>></div><div class="documentA">步行导航|/index.php?title=iossdk/guide/navigation/walk</div></div></div><div class="wrap_right_nav_r">下载源码</div><!-- IOS源码地址 --><div class="github-url-ios">//mapopen-website-wiki.bj.bcebos.com/demos/iosVideos/iOS示例中心Demo.zip</div></div><div class="wrap_table"><div class="table_nav"><div class="left-icon"></div><div>核心接口</div></div></div></div></div></div></div> |
− | <div class="title-mi">功能场景</div>
| + | |
− | <div class="wrap-mi">在景区、出行app中,可以展示真实街景,并且通过虚拟路标,引导用户到达目的地。</div><!-- -->
| + | |
− | </div> | + | |
− | <div class="demos_wrap"> | + | |
− | <div class="header">
| + | |
− | <div class="andiord-header active">Android</div>
| + | |
− | <div class="ios-header hide">iOS</div>
| + | |
− | </div>
| + | |
− | <div class="andiord-wrap wrap">
| + | |
− | <div class="wrap-wp">
| + | |
− | <div class="wrap_left">
| + | |
− | <div class="left-video">
| + | |
− | <div class="img-bg-and"></div>
| + | |
− | <div class="phone-android">
| + | |
− | <div class="video-wrap infor">
| + | |
− | <div class="video-control"></div><!-- 安卓视频位置 (不写协议)-->
| + | |
− | <pre>//mapopen-website-wiki.bj.bcebos.com/demos/AndroidVideos/AR步行导航.mp4</pre>
| + | |
− | </div><div class="video-icon-and"><div class="play play-and"></div><div class="stop stop-and"></div></div></div><div class="progressWrap-hide-and"></div><div id="videoControls-and"><div id="progressWrap-and"><div id="playProgress-and"></div></div></div></div><div class="left-qrCode"><!-- 安卓二维码位置 --><div class="qrCode-and">1590746640|</div><div>扫码体验</div></div></div><div class="wrap_right"><div class="wrap_right_nav"><div class="wrap_right_nav_l"><div>使用产品</div><div><!-- 安卓使用产品下选项,可有多个 --><!-- 产品1|/index.php?title=test --><div class="documentA">Android地图SDK|/index.php?title=androidsdk</div><!-- --><div>></div><div class="documentA">步行导航|/index.php?title=androidsdk/guide/navigation/walknavi</div></div></div><div class="wrap_right_nav_r">下载源码</div><!-- 安卓源码地址 --><div class="github-url-and">//mapopen-website-wiki.bj.bcebos.com/demos/iosVideos/iOS示例中心Demo.zip</div></div><div class="wrap_table"><div class="table_nav"><div class="left-icon"></div><div>核心接口</div></div><div class="table_wrap"><div class="table_wrap_title"><div>类</div><div>接口</div><div>描述</div></div><!-- 表格接口,可有多个 --><div class="table_wrap_con"><div class="table_wrap_w"><div><div class="table-wrap-className">RoutePlanSearch</div></div><div><div>newInstance()</div></div><div><div>创建路线规划检索实例</div></div></div><!-- --><div class="table_wrap_w"><div><div class="table-wrap-className">RoutePlanSearch</div></div><div><div>setOnGetRoutePlanResultListener()</div></div><div><div>设置路线规划检索监听器</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">RoutePlanSearch</div></div><div><div>bikingSearch()</div></div><div><div>发起骑行路线规划检索请求</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">RoutePlanSearch</div></div><div><div>destory()</div></div><div><div>释放路线规划检索实例</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">OnGetRoutePlanResultListener</div></div><div><div>onGetBikingRouteResult()</div></div><div><div>骑行路线规划的结果回调函数</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">PlanNode</div></div><div><div>withCityNameAndPlaceName()</div></div><div><div>路线规划起终点参数</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">BikingRoutePlanOption</div></div><div><div>from()</div></div><div><div>设置路线规划起点参数</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">BikingRoutePlanOption</div></div><div><div>to()</div></div><div><div>设置路线规划终点参数</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">BikingRoutePlanOption</div></div><div><div>ridingType()</div></div><div><div>设置骑行路线规划类型</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">BikingRouteOverlay</div></div><div><div>setData()</div></div><div><div>设置骑行路线规划结果数据</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">BikingRouteOverlay</div></div><div><div>addToMap()</div></div><div><div>添加骑行路线添加到地图上</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">BikingRouteOverlay</div></div><div><div>zoomToSpanPaddingBounds()</div></div><div><div>将骑行路线调整到地图显示的最佳视野范围内</div></div></div></div></div></div></div></div><div class="pre-nav"><div class="left-icon"></div><div>核心代码</div></div><div class="pre-nav"><div>1.骑行路线规划结果解析</div></div><div class="pre-wrap"><div class="pre-wrap-nav"><div>JAVA</div></div><!-- 安卓示例代码位置 --><div class="pre-wrap-w pre-wrap-w-and"><pre class="prettyprint prettyprinted pre-and">/**
| + | |
− | * 设置路线数据。
| + | |
− | *
| + | |
− | * @param line 路线数据
| + | |
− | */
| + | |
− | public void setData(BikingRouteLine line) {
| + | |
− | mRouteLine = line;
| + | |
− | }
| + | |
− | | + | |
− | @Override
| + | |
− | public final List<OverlayOptions> getOverlayOptions() {
| + | |
− | if (mRouteLine == null) {
| + | |
− | return null;
| + | |
− | }
| + | |
− | | + | |
− | List<OverlayOptions> overlayList = new ArrayList<OverlayOptions>();
| + | |
− | if (mRouteLine.getAllStep() != null
| + | |
− | && mRouteLine.getAllStep().size() > 0) {
| + | |
− | for (BikingRouteLine.BikingStep step : mRouteLine.getAllStep()) {
| + | |
− | Bundle b = new Bundle();
| + | |
− | b.putInt("index", mRouteLine.getAllStep().indexOf(step));
| + | |
− | if (step.getEntrance() != null) {
| + | |
− | overlayList.add((new MarkerOptions()).position(step.getEntrance().getLocation())
| + | |
− | .rotate((360 - step.getDirection())).zIndex(10).anchor(0.5f, 0.5f)
| + | |
− | .extraInfo(b)
| + | |
− | .icon(BitmapDescriptorFactory.fromAssetWithDpi("Icon_line_node.png")));
| + | |
− | }
| + | |
− | | + | |
− | // 最后路段绘制出口点
| + | |
− | if (mRouteLine.getAllStep().indexOf(step) == (mRouteLine
| + | |
− | .getAllStep().size() - 1)
| + | |
− | && step.getExit() != null) {
| + | |
− | overlayList.add((new MarkerOptions()).position(step.getExit().getLocation())
| + | |
− | .anchor(0.5f, 0.5f).zIndex(10)
| + | |
− | .icon(BitmapDescriptorFactory.fromAssetWithDpi("Icon_line_node.png")));
| + | |
− | | + | |
− | }
| + | |
− | }
| + | |
− | }
| + | |
− | // starting
| + | |
− | if (mRouteLine.getStarting() != null) {
| + | |
− | overlayList.add((new MarkerOptions()).position(mRouteLine.getStarting().getLocation())
| + | |
− | .icon(getStartMarker() != null ? getStartMarker()
| + | |
− | : BitmapDescriptorFactory.fromAssetWithDpi("Icon_start.png"))
| + | |
− | .zIndex(10));
| + | |
− | }
| + | |
− | // terminal
| + | |
− | if (mRouteLine.getTerminal() != null) {
| + | |
− | overlayList.add((new MarkerOptions()).position(mRouteLine.getTerminal().getLocation())
| + | |
− | .icon(getTerminalMarker() != null ? getTerminalMarker()
| + | |
− | : BitmapDescriptorFactory.fromAssetWithDpi("Icon_end.png"))
| + | |
− | .zIndex(10));
| + | |
− | }
| + | |
− | | + | |
− | // poly line list
| + | |
− | if (mRouteLine.getAllStep() != null
| + | |
− | && mRouteLine.getAllStep().size() > 0) {
| + | |
− | LatLng lastStepLastPoint = null;
| + | |
− | for (BikingRouteLine.BikingStep step : mRouteLine.getAllStep()) {
| + | |
− | List<LatLng> watPoints = step.getWayPoints();
| + | |
− | if (watPoints != null) {
| + | |
− | List<LatLng> points = new ArrayList<LatLng>();
| + | |
− | if (lastStepLastPoint != null) {
| + | |
− | points.add(lastStepLastPoint);
| + | |
− | }
| + | |
− | points.addAll(watPoints);
| + | |
− | overlayList.add(new PolylineOptions().points(points).width(18).dottedLine(true)
| + | |
− | .customTexture(getBikeRoadCustomTexture()).zIndex(0));
| + | |
− | lastStepLastPoint = watPoints.get(watPoints.size() - 1);
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | }
| + | |
− | | + | |
− | return overlayList;
| + | |
− | }
| + | |
− | | + | |
− | | + | |
− | public BitmapDescriptor getBikeRoadCustomTexture() {
| + | |
− | return BitmapDescriptorFactory.fromAsset("Icon_road_blue_arrow.png");
| + | |
− | }
| + | |
− |
| + | |
− | </pre>
| + | |
− | <div class="pre-btn">
| + | |
− | <div class="pre-btn-copy-and">复制</div>
| + | |
− | <div class="pre-btn-cb-and">深色</div>
| + | |
− | </div>
| + | |
− | <div class="success">复制成功</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="pre-nav">
| + | |
− | <div>2.将骑行路线添加到地图上</div>
| + | |
− | </div>
| + | |
− | <div class="pre-wrap">
| + | |
− | <div class="pre-wrap-nav">
| + | |
− | <div>JAVA</div>
| + | |
− | </div><!-- 安卓示例代码位置 -->
| + | |
− | <div class="pre-wrap-w pre-wrap-w-and">
| + | |
− | <pre class="prettyprint prettyprinted pre-and">/**
| + | |
− | * 将骑行路线添加到地图上
| + | |
− | */
| + | |
− | public final void addToMap() {
| + | |
− | if (mBaiduMap == null) {
| + | |
− | return;
| + | |
− | }
| + | |
− | | + | |
− | List<OverlayOptions> overlayOptions = getOverlayOptions();
| + | |
− | if (overlayOptions != null) {
| + | |
− | mOverlayOptionList.addAll(getOverlayOptions());
| + | |
− | }
| + | |
− | | + | |
− | for (OverlayOptions option : mOverlayOptionList) {
| + | |
− | mBaiduMap.addOverlay(option)
| + | |
− | }
| + | |
− | }
| + | |
− | </pre>
| + | |
− | <div class="pre-btn">
| + | |
− | <div class="pre-btn-copy-and">复制</div>
| + | |
− | <div class="pre-btn-cb-and">深色</div>
| + | |
− | </div>
| + | |
− | <div class="success">复制成功</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="pre-nav">
| + | |
− | <div>3.将骑行路线调整到地图显示的最佳视野范围内</div>
| + | |
− | </div>
| + | |
− | <div class="pre-wrap">
| + | |
− | <div class="pre-wrap-nav">
| + | |
− | <div>JAVA</div>
| + | |
− | </div><!-- 安卓示例代码位置 -->
| + | |
− | <div class="pre-wrap-w pre-wrap-w-and">
| + | |
− | <pre class="prettyprint prettyprinted pre-and">/**
| + | |
− | * 将骑行路线调整到地图显示的最佳视野范围内
| + | |
− | */
| + | |
− | public void zoomToSpanPaddingBounds(int paddingLeft, int paddingTop, int paddingRight,
| + | |
− | int paddingBottom) {
| + | |
− | if (mBaiduMap == null) {
| + | |
− | return;
| + | |
− | }
| + | |
− | if (mOverlayList.size() > 0) {
| + | |
− | LatLngBounds.Builder builder = new LatLngBounds.Builder();
| + | |
− | for (Overlay overlay : mOverlayList) {
| + | |
− | // polyline 中的点可能太多,只按marker 缩放
| + | |
− | if (overlay instanceof Marker) {
| + | |
− | builder.include(((Marker) overlay).getPosition());
| + | |
− | }
| + | |
− | }
| + | |
− | mBaiduMap.setMapStatus(MapStatusUpdateFactory
| + | |
− | .newLatLngBounds(builder.build(), paddingLeft, paddingTop, paddingRight,
| + | |
− | paddingBottom));
| + | |
− | }
| + | |
− | }
| + | |
− |
| + | |
− |
| + | |
− | </pre>
| + | |
− | <div class="pre-btn">
| + | |
− | <div class="pre-btn-copy-and">复制</div>
| + | |
− | <div class="pre-btn-cb-and">深色</div>
| + | |
− | </div>
| + | |
− | <div class="success">复制成功</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="more-nav">
| + | |
− | <div class="left-icon"></div>
| + | |
− | <div>更多功能</div>
| + | |
− | </div>
| + | |
− | <div class="more-wrap">
| + | |
− | <!-- 安卓更多功能下选项 -->
| + | |
− | <!-- 点标记动画|/index.php?title=test -->
| + | |
− | <div>
| + | |
− | <div class="point"></div>
| + | |
− | <div class="documentA">步行导航|/index.php?title=androidsdk/guide/navigation/walknavi</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="ios-wrap wrap" style="display: none;">
| + | |
− | <div class="wrap-wp">
| + | |
− | <div class="wrap_left">
| + | |
− | <div class="left-video">
| + | |
− | <div class="img-bg-ios-sh"></div>
| + | |
− | <div class="phone-ios">
| + | |
− | <div class="video-wrap infor">
| + | |
− | <div class="video-control"></div><!-- ios视频位置 -->
| + | |
− | <pre>//mapopen-website-wiki.bj.bcebos.com/demos/iosVideos/iOS平滑移动.mov</pre>
| + | |
− | </div>
| + | |
− | <div class="video-icon-ios">
| + | |
− | <div class="play play-ios"></div>
| + | |
− | <div class="stop stop-ios"></div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="progressWrap-hide-ios"></div>
| + | |
− | <div id="videoControls-ios">
| + | |
− | <div id="progressWrap-ios">
| + | |
− | <div id="playProgress-ios"></div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="left-qrCode">
| + | |
− | <!-- ios二维码位置 -->
| + | |
− | <div class="qrCode-ios">//mapopen-website-wiki.bj.bcebos.com/demos/play.png</div>
| + | |
− | <div>扫码手机观看</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="wrap_right">
| + | |
− | <div class="wrap_right_nav">
| + | |
− | <div class="wrap_right_nav_l">
| + | |
− | <div>使用产品</div>
| + | |
− | <div>
| + | |
− | <!-- IOS使用产品下选项,可有多个 -->
| + | |
− | <!-- 产品1|/index.php?title=test -->
| + | |
− | <div class="documentA">IOS地图SDK|/index.php?title=iossdk</div><!-- -->
| + | |
− | <div>></div>
| + | |
− | <div class="documentA">步行导航|/index.php?title=iossdk/guide/navigation/walk</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="wrap_right_nav_r">下载源码</div><!-- IOS源码地址 -->
| + | |
− | <div class="github-url-ios">
| + | |
− | //mapopen-website-wiki.bj.bcebos.com/demos/iosVideos/iOS示例中心Demo.zip</div>
| + | |
− | </div>
| + | |
− | <div class="wrap_table">
| + | |
− | <div class="table_nav">
| + | |
− | <div class="left-icon"></div>
| + | |
− | <div>核心接口</div>
| + | |
− | </div>
| + | |
− | <div class="table_wrap">
| + | |
− | <div class="table_wrap_title">
| + | |
− | <div>类</div>
| + | |
− | <div>接口</div>
| + | |
− | <div>描述</div>
| + | |
− | </div><!-- ios表格接口内容,可有多个 -->
| + | |
− | <!-- 表格接口,可有多个 -->
| + | |
− | <div class="table_wrap_con">
| + | |
− | <div class="table_wrap_w">
| + | |
− | <div>
| + | |
− | <div class="table-wrap-className">BMKRouteSearch</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>- (instancetype)init;</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>创建路线规划检索实例</div>
| + | |
− | </div>
| + | |
− | </div><!-- -->
| + | |
− | <div class="table_wrap_w">
| + | |
− | <div>
| + | |
− | <div class="table-wrap-className">BMKRouteSearch</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>id<BMKRouteSearchDelegate> delegate;</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>设置路线规划检索监听器</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="table_wrap_w">
| + | |
− | <div>
| + | |
− | <div class="table-wrap-className">BMKRouteSearch</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>- (BOOL)ridingSearch:(BMKRidingRoutePlanOption
| + | |
− | *)ridingRoutePlanOption;</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>发起骑行路线规划检索请求</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="table_wrap_w">
| + | |
− | <div>
| + | |
− | <div class="table-wrap-className">BMKRouteSearchDelegate</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>- (void)onGetRidingRouteResult:(BMKRouteSearch *)searcher
| + | |
− | result:(BMKRidingRouteResult *)result
| + | |
− | errorCode:(BMKSearchErrorCode)error;</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>骑行路线规划的结果回调函数</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="table_wrap_w">
| + | |
− | <div>
| + | |
− | <div class="table-wrap-className">BMKPlanNode</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>NSString *cityName;</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>路线规划起终点城市参数</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="table_wrap_w">
| + | |
− | <div>
| + | |
− | <div class="table-wrap-className">BMKPlanNode</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>NSString *name;</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>路线规划起终点名称参数</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="table_wrap_w">
| + | |
− | <div>
| + | |
− | <div class="table-wrap-className">BMKWalkingRoutePlanOption</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>BMKPlanNode *from;</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>设置路线规划起点参数</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="table_wrap_w">
| + | |
− | <div>
| + | |
− | <div class="table-wrap-className">BMKWalkingRoutePlanOption</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>BMKPlanNode *to;</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>设置路线规划终点参数</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="table_wrap_w">
| + | |
− | <div>
| + | |
− | <div class="table-wrap-className">BMKRidingRoutePlanOption</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>NSInteger ridingType;</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>设置骑行类型(0:普通骑行,1:电动车骑行),默认是普通骑行</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="table_wrap_w">
| + | |
− | <div>
| + | |
− | <div class="table-wrap-className">BMKPolyline</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>+ (BMKPolyline *)polylineWithPoints:(BMKMapPoint *)points
| + | |
− | count:(NSUInteger)count;</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>设置骑行路线规划点数据</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="table_wrap_w">
| + | |
− | <div>
| + | |
− | <div class="table-wrap-className">BMKMapView</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>- (void)addOverlay:(id <BMKOverlay>)overlay;</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>添加骑行路线添加到地图上</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="table_wrap_w">
| + | |
− | <div>
| + | |
− | <div class="table-wrap-className">BMKBikeRoutePlanViewController</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>- (void)mapViewFitPolyline:(BMKPolyline *)polyline;</div>
| + | |
− | </div>
| + | |
− | <div>
| + | |
− | <div>将骑行路线调整到地图显示的最佳视野范围内</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="pre-nav">
| + | |
− | <div class="left-icon"></div>
| + | |
− | <div>核心代码</div>
| + | |
− | </div>
| + | |
− | <div class="pre-nav">
| + | |
− | <div>1.骑行路线规划结果解析</div>
| + | |
− | </div>
| + | |
− | <div class="pre-wrap">
| + | |
− | <div class="pre-wrap-nav">
| + | |
− | <div>Objective-C</div>
| + | |
− | </div>
| + | |
− | <div class="pre-wrap-w pre-wrap-w-ios code_container">
| + | |
− | <!-- ios示例代码位置 -->
| + | |
− | <pre class="prettyprint prettyprinted pre-ios">NSMutableArray *tempArray = [NSMutableArray array];
| + | |
− | //+polylineWithPoints: count:坐标点的个数
| + | |
− | __block NSUInteger pointCount = 0;
| + | |
− | //获取所有骑行路线中第一条路线
| + | |
− | BMKRidingRouteLine *routeline = (BMKRidingRouteLine *)result.routes.firstObject;
| + | |
− | _routeLine = routeline;
| + | |
− | //遍历骑行路线中的所有路段
| + | |
− | [routeline.steps enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
| + | |
− | //获取骑行路线中的每条路段
| + | |
− | BMKRidingStep *step = routeline.steps[idx];
| + | |
− | BMKBikeRouteDetailModel *model = [[BMKBikeRouteDetailModel alloc] init];
| + | |
− | model.instruction = step.instruction;
| + | |
− | NSString *instruction = step.instruction;
| + | |
− | NSDictionary *attrs = @{NSFontAttributeName : [UIFont fontWithName:@"PingFangSC-Regular" size:16 * widthScale]};
| + | |
− | CGSize size = CGSizeMake(KScreenWidth - 86 * widthScale, MAXFLOAT);
| + | |
− | CGSize actualsize = [instruction boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
| + | |
− | model.cellHeight = actualsize.height + 48 * widthScale;
| + | |
− | [tempArray addObject:model];
| + | |
− | //统计路段所经过的地理坐标集合内点的个数
| + | |
− | pointCount += step.pointsCount;
| + | |
− | }];
| + | |
− | _detailModels = [tempArray copy];
| + | |
− | //+polylineWithPoints: count:指定的直角坐标点数组
| + | |
− | BMKMapPoint *points = new BMKMapPoint[pointCount];
| + | |
− | __block NSUInteger j = 0;
| + | |
− | //遍历骑行路线中的所有路段
| + | |
− | [routeline.steps enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
| + | |
− | //获取骑行路线中的每条路段
| + | |
− | BMKRidingStep *step = routeline.steps[idx];
| + | |
− | for (NSUInteger i = 0; i < step.pointsCount; i ++) {
| + | |
− | //将每条路段所经过的地理坐标点赋值给points
| + | |
− | points[j].x = step.points[i].x;
| + | |
− | points[j].y = step.points[i].y;
| + | |
− | j ++;
| + | |
− | }
| + | |
− | }];
| + | |
− | </pre>
| + | |
− | <div class="pre-btn">
| + | |
− | <div class="pre-btn-copy-ios">复制</div>
| + | |
− | <div class="pre-btn-cb-ios">深色</div>
| + | |
− | </div>
| + | |
− | <div class="success">复制成功</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="pre-nav">
| + | |
− | <div>2.将骑行路线和起终点添加到地图上</div>
| + | |
− | </div>
| + | |
− | <div class="pre-wrap">
| + | |
− | <div class="pre-wrap-nav">
| + | |
− | <div>Objective-C</div>
| + | |
− | </div>
| + | |
− | <div class="pre-wrap-w pre-wrap-w-ios code_container">
| + | |
− | <!-- ios示例代码位置 -->
| + | |
− | <pre class="prettyprint prettyprinted pre-ios">//设置起点
| + | |
− | CLLocationCoordinate2D start = BMKCoordinateForMapPoint(points[0]);
| + | |
− | _startAnnotation = [[BMKPointAnnotation alloc] init];
| + | |
− | _startAnnotation.coordinate = start;
| + | |
− | [self.mapView addAnnotation:_startAnnotation];
| + | |
− | //设置终点
| + | |
− | CLLocationCoordinate2D end = BMKCoordinateForMapPoint(points[pointCount - 1]);
| + | |
− | _endAnnotation = [[BMKPointAnnotation alloc] init];
| + | |
− | _endAnnotation.coordinate = end;
| + | |
− | [self.mapView addAnnotation:_endAnnotation];
| + | |
− | //根据指定直角坐标点生成一段折线
| + | |
− | BMKPolyline *polyline = [BMKPolyline polylineWithPoints:points count:pointCount];
| + | |
− | /**
| + | |
− | 向地图View添加Overlay,需要实现BMKMapViewDelegate的-mapView:viewForOverlay:方法
| + | |
− | 来生成标注对应的View
| + | |
− |
| + | |
− | @param overlay 要添加的overlay
| + | |
− | */
| + | |
− | [_mapView addOverlay:polyline];
| + | |
− |
| + | |
− | </pre>
| + | |
− | <div class="pre-btn">
| + | |
− | <div class="pre-btn-copy-ios">复制</div>
| + | |
− | <div class="pre-btn-cb-ios">深色</div>
| + | |
− | </div>
| + | |
− | <div class="success">复制成功</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="pre-nav">
| + | |
− | <div>3.将骑行路线调整到地图显示的最佳视野范围内</div>
| + | |
− | </div>
| + | |
− | <div class="pre-wrap">
| + | |
− | <div class="pre-wrap-nav">
| + | |
− | <div>Objective-C</div>
| + | |
− | </div>
| + | |
− | <div class="pre-wrap-w pre-wrap-w-ios code_container">
| + | |
− | <!-- ios示例代码位置 -->
| + | |
− | <pre class="prettyprint prettyprinted pre-ios">//根据polyline设置地图范围
| + | |
− | - (void)mapViewFitPolyline:(BMKPolyline *)polyline {
| + | |
− | double leftTop_x, leftTop_y, rightBottom_x, rightBottom_y;
| + | |
− | if (polyline.pointCount < 1) {
| + | |
− | return;
| + | |
− | }
| + | |
− | BMKMapPoint pt = polyline.points[0];
| + | |
− | leftTop_x = pt.x;
| + | |
− | leftTop_y = pt.y;
| + | |
− | //左上方的点lefttop坐标(leftTop_x,leftTop_y)
| + | |
− | rightBottom_x = pt.x;
| + | |
− | rightBottom_y = pt.y;
| + | |
− | //右底部的点rightbottom坐标(rightBottom_x,rightBottom_y)
| + | |
− | for (int i = 1; i < polyline.pointCount; i++) {
| + | |
− | BMKMapPoint point = polyline.points[i];
| + | |
− | if (point.x < leftTop_x) {
| + | |
− | leftTop_x = point.x;
| + | |
− | }
| + | |
− | if (point.x > rightBottom_x) {
| + | |
− | rightBottom_x = point.x;
| + | |
− | }
| + | |
− | if (point.y < leftTop_y) {
| + | |
− | leftTop_y = point.y;
| + | |
− | }
| + | |
− | if (point.y > rightBottom_y) {
| + | |
− | rightBottom_y = point.y;
| + | |
− | }
| + | |
− | }
| + | |
− | BMKMapRect rect;
| + | |
− | rect.origin = BMKMapPointMake(leftTop_x, leftTop_y);
| + | |
− | rect.size = BMKMapSizeMake(rightBottom_x - leftTop_x, rightBottom_y - leftTop_y);
| + | |
− | UIEdgeInsets padding = UIEdgeInsetsMake(KStatuesBarHeight + 170 * widthScale, 20 * widthScale, KStatuesBarHeight + 170 * widthScale, 20 * widthScale);
| + | |
− | [_mapView fitVisibleMapRect:rect edgePadding:padding withAnimated:YES];
| + | |
− | | + | |
− | </pre>
| + | |
− | <div class="pre-btn">
| + | |
− | <div class="pre-btn-copy-ios">复制</div>
| + | |
− | <div class="pre-btn-cb-ios">深色</div>
| + | |
− | </div>
| + | |
− | <div class="success">复制成功</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | <div class="more-nav">
| + | |
− | <div class="left-icon"></div>
| + | |
− | <div>更多功能</div>
| + | |
− | </div>
| + | |
− | <div class="more-wrap">
| + | |
− | <!-- IOS更多功能下选项 -->
| + | |
− | <!-- 点标记动画|/index.php?title=test -->
| + | |
− | <div>
| + | |
− | <div class="point"></div>
| + | |
− | <div class="documentA">步行导航|/index.php?title=iossdk/guide/navigation/walk</div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | </div>
| + | |
− | </div>
| + | |