第1行: | 第1行: | ||
− | <div id="examples_center"> | + | <div id="examples_center"><!-- 页面标题 --><div class="title-hd">多模式定位</div><!-- 标题下子标题及简介,可有多个 --><div class="title-mi">功能场景</div><div class="wrap-mi">本示例展示了如何通过配置不同定位模式、坐标系获取精准定位结果及丰富定位信息。</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/多方式定位.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|//mapopen-website-wiki.bj.bcebos.com/demos/newqrcodes/多方式定位.png</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=android-locsdk</div></div></div><div class="wrap_right_nav_r">下载源码</div><!-- 安卓源码地址 --><div class="github-url-and">//mapopen-website-wiki.bj.bcebos.com/demos/location/ConfigParametersLocation.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">LocationClientOption</div></div><div><div>setLocationMode(LocationClientOption.LocationMode mode)</div></div><div><div>设置定位模式</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">LocationClientOption</div></div><div><div>setIsNeedLocationDescribe(boolean isNeedLocationDescribe)</div></div><div><div>设置是否需要返回位置语义化信息,可以在BDLocation.getLocationDescribe()中得到数据</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">LocationClientOption</div></div><div><div>setIsNeedAddress(boolean isNeed)</div></div><div><div>设置是否需要地址信息,默认为无地址。 在设备获取gps位置的时候,对应的地址信息不会马上返回,因为gps是直接在本地产生,但地址信息需要从云端获取,是个异步过程,开发者在接收定位返回数据的时候,建议不要立即stop定位sdk以等待数据回调</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">LocationClientOption</div></div><div><div>setIsNeedLocationPoiList(boolean isNeedLocationPoiList)</div></div><div><div>设置是否需要返回位置POI信息,可以在BDLocation.getPoiList()中得到数据</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">LocationClientOption</div></div><div><div>setCoorType(java.lang.String coorType)</div></div><div><div>设置坐标类型</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">LocationClient</div></div><div><div>start()</div></div><div><div>启动定位sdk</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">LocationClient</div></div><div><div>setLocOption(LocationClientOption locOption)</div></div><div><div>给定位客户端设置参数</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">BDAbstractLocationListener</div></div><div><div>BDAbstractLocationListener</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">/** | |
− | + | ||
− | + | ||
− | + | ||
− | </div> | + | |
− | <div class="demos_wrap"> | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | /** | + | |
* 初始化定位 | * 初始化定位 | ||
*/ | */ | ||
第209行: | 第38行: | ||
} | } | ||
</pre> | </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">/** | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | /** | + | |
* 定位信息回调 | * 定位信息回调 | ||
*/ | */ | ||
第236行: | 第48行: | ||
} | } | ||
</pre> | </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><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"></div><div class="phone-ios"><div class="video-wrap infor"><div class="video-control"></div><!-- ios视频位置 --><pre>//mapopen-website-wiki.bj.bcebos.com/demos/iostest.MP4</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使用产品下选项,可有多个 --><div class="documentA">产品1|/index.php?title=test</div><!-- --><div>></div><div class="documentA">产品2|/index.php?title=test</div></div></div><div class="wrap_right_nav_r">下载源码</div><!-- IOS源码地址 --><div class="github-url-ios">//mapopen-website-wiki.bj.bcebos.com/demos/xs%20max.png</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></div><!-- ios表格接口内容,可有多个 --><!-- 表格接口,可有多个 --><div class="table_wrap_con"><div class="table_wrap_w"><div><div class="table-wrap-className">BMKClusterManager</div></div><div><div>- (void)clearClusterItems;</div></div><div><div>清除标注集群items</div></div><div><div>V4.0.0起</div></div></div><!-- --><div class="table_wrap_w"><div><div class="table-wrap-className">BMKClusterManager</div></div><div><div>- (NSArray<BMKCluster *> *)getClusters:(CGFloat)zoomLevel;</div></div><div><div>根据地图缩放级别获取标注集群</div></div><div><div>V4.0.0起</div></div></div> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | </div></div></div></div></div><div class="pre-nav"><div class="left-icon"></div><div>核心代码</div></div><div class="pre-wrap"><div class="pre-wrap-title">1.第一步</div><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">1 | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | 1 | + | |
/** 更新标注展示. */ | /** 更新标注展示. */ | ||
- (void)updateClusters { | - (void)updateClusters { | ||
第392行: | 第89行: | ||
</pre> | </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-wrap"><div class="pre-wrap-title">2.第二步</div><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">2 | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | 2 | + | |
/** 更新标注展示. */ | /** 更新标注展示. */ | ||
- (void)updateClusters { | - (void)updateClusters { | ||
第446行: | 第127行: | ||
</pre> | </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-wrap"><div class="pre-wrap-title">3.名字</div><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">3 | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | 3 | + | |
/** 更新标注展示. */ | /** 更新标注展示. */ | ||
- (void)updateClusters { | - (void)updateClusters { | ||
第500行: | 第165行: | ||
</pre> | </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=test</div></div><div><div class="point"></div><div class="documentA">点融合|/index.php?title=test</div></div><div><div class="point"></div><div class="documentA">添加文字和信息窗|/index.php?title=test</div></div></div></div></div> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | </div> | + |
2022年2月25日 (五) 17:35的最后版本
多模式定位
功能场景
本示例展示了如何通过配置不同定位模式、坐标系获取精准定位结果及丰富定位信息。
Android
//mapopen-website-wiki.bj.bcebos.com/demos/AndroidVideos/多方式定位.mp4
1590746640|//mapopen-website-wiki.bj.bcebos.com/demos/newqrcodes/多方式定位.png
扫码体验
使用产品
Android定位SDK|/index.php?title=android-locsdk
下载源码
//mapopen-website-wiki.bj.bcebos.com/demos/location/ConfigParametersLocation.zip
核心接口
类
接口
描述
LocationClientOption
setLocationMode(LocationClientOption.LocationMode mode)
设置定位模式
LocationClientOption
setIsNeedLocationDescribe(boolean isNeedLocationDescribe)
设置是否需要返回位置语义化信息,可以在BDLocation.getLocationDescribe()中得到数据
LocationClientOption
setIsNeedAddress(boolean isNeed)
设置是否需要地址信息,默认为无地址。 在设备获取gps位置的时候,对应的地址信息不会马上返回,因为gps是直接在本地产生,但地址信息需要从云端获取,是个异步过程,开发者在接收定位返回数据的时候,建议不要立即stop定位sdk以等待数据回调
LocationClientOption
setIsNeedLocationPoiList(boolean isNeedLocationPoiList)
设置是否需要返回位置POI信息,可以在BDLocation.getPoiList()中得到数据
LocationClientOption
setCoorType(java.lang.String coorType)
设置坐标类型
LocationClient
start()
启动定位sdk
LocationClient
setLocOption(LocationClientOption locOption)
给定位客户端设置参数
BDAbstractLocationListener
BDAbstractLocationListener
监听定位结果回调函数
核心代码
1.配置定位参数开启定位
JAVA
/** * 初始化定位 */ private void initLoctionClient() { // 定位服务的客户端。宿主程序在客户端声明此类,并调用,目前只支持在主线程中启动 mLocationClient = new LocationClient(getApplicationContext()); mMyLocationListener = new MyLocationListener(); mLocationClient.registerLocationListener(mMyLocationListener); mLocationClientOption = new LocationClientOption(); // 可选,默认false,设置是否开启Gps定位 mLocationClientOption.setOpenGps(true); // 可选,默认false,设置定位时是否需要海拔信息,默认不需要,除基础定位版本都可用 mLocationClientOption.setIsNeedAltitude(true); // 可选,默认高精度,设置定位模式,高精度,低功耗,仅设备 mLocationClientOption.setLocationMode(LocationMode.Hight_Accuracy); // 可选,默认gcj02,设置返回的定位结果坐标系,如果配合百度地图使用,建议设置为bd09ll; mLocationClientOption.setCoorType("bd09ll"); // 设置发起连续定位请求的间隔 mLocationClientOption.setScanSpan(3000); / 可选,设置是否需要地址信息,默认不需要 mLocationClientOption.setIsNeedAddress(true); // 可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到 mLocationClientOption.setIsNeedLocationPoiList(true); // 可选,设置是否需要设备方向结果 mLocationClientOption.setNeedDeviceDirect(true); // 可选,默认false,设置是否需要位置语义化结果,可以在BDLocation.getLocationDescribe里得到,结果类似于“在北京天安门附近” mLocationClientOption.setIsNeedLocationDescribe(true); // 需将配置好的LocationClientOption对象,通过setLocOption方法传递给LocationClient对象使用 mLocationClient.setLocOption(mLocationClientOption); // 开始定位 mLocationClient.start(); }
复制
深色
复制成功
2.获取定位回调信息
JAVA
/** * 定位信息回调 */ class MyLocationListener extends BDAbstractLocationListener { @Override public void onReceiveLocation(BDLocation bdLocation) { // 在此获取定位结果信息。 } }
复制
深色
复制成功