第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">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/签到.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><!-- 安卓使用产品下选项,可有多个 --><!-- 产品1|/index.php?title=test --><div class="documentA">Android地图SDK|/index.php?title=androidsdk</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/SignInSceneLocationDemo.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></div><!-- 表格接口,可有多个 --><div class="table_wrap_con"><div class="table_wrap_w"><div><div class="table-wrap-className">ReverseGeoCodeOption</div></div><div><div>newVersion(int latestAdmin)</div></div><div><div>设置是否返回新数据1返回0不返回</div></div><div><div>地图SDK</div></div></div><!-- --><div class="table_wrap_w"><div><div class="table-wrap-className">ReverseGeoCodeOption</div></div><div><div>radius(500)</div></div><div><div>POI召回半径,允许设置区间为0-1000米,超过1000米按1000米召回。默认值为1000</div></div><div><div>地图SDK</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">SpatialRelationUtil</div></div><div><div>isCircleContainsPoint(LatLng center, int radius, LatLng point)</div></div><div><div>判断圆形是否包含传入的经纬度点</div></div><div><div>地图SDK</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>定位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>定位SDK</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>定位SDK</div></div></div></div></div></div></div></div><div class="pre-nav"><div class="left-icon"></div><div>重点关注</div></div><div class="pre-nav" style="margin-left: 10px;"><div>签到场景的核心难点在于解决定位不准的情况下纠正用户位置,示例中提供用户手动纠正位置功能来解决这一问题。</div></div><div class="pre-nav" style="margin-left: 10px;"><div>当正常通过定位确定用户位置之后,会给出周边POI列表供用户选择准确位置。</div></div><div class="pre-nav" style="margin-left: 10px"><div style="line-height: 22px;">当定位发生微小漂移时,用户通过手动移动地图做位置调整,当前微调范围被限定在500米以内(可自定义),超过500米时弹出toast告知用户“微调距离不可超过500米”。</div></div><!-- <div class="more-nav"> | |
− | + | ||
− | + | ||
− | + | ||
− | </div> | + | |
− | <div class="demos_wrap"> | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
<div class="left-icon"></div> | <div class="left-icon"></div> | ||
<div>更多功能</div> | <div>更多功能</div> | ||
</div> | </div> | ||
− | <div class="more-wrap"> --> | + | <div class="more-wrap"> --><!-- 安卓更多功能下选项 --><!-- 点标记动画|/index.php?title=test --><!-- <div> |
− | + | ||
− | + | ||
− | + | ||
<div class="point"></div> | <div class="point"></div> | ||
<div class="documentA">点标记动画|/index.php?title=test</div> | <div class="documentA">点标记动画|/index.php?title=test</div> | ||
第186行: | 第16行: | ||
<div class="documentA">添加文字和信息窗|/index.php?title=test</div> | <div class="documentA">添加文字和信息窗|/index.php?title=test</div> | ||
</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"></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> | </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 iosqrCode"><!-- ios二维码位置 --><div class="qrCode-ios">1590746640|//mapopen-website-wiki.bj.bcebos.com/demos/ioscodes/签到场景@1xios.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">产品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/location/signinscenceSDKDemo.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">BMKMapView</div></div><div><div>- (void)addOverlay:(id <BMKOverlay>)overlay;</div></div><div><div>地图窗口添加Overlay,需要实现BMKMapViewDelegate的-mapView:viewForOverlay:函数来生成标注对应的View</div></div></div><!-- --><div class="table_wrap_w"><div><div class="table-wrap-className">BMKMapView</div></div><div><div>- (BMKOverlayView *)mapView:(BMKMapView *)mapView viewForOverlay:(id<BMKOverlay>)overlay;</div></div><div><div>根据overlay生成对应的View</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">BMKMapView</div></div><div><div>- (void)addAnnotation:(id <BMKAnnotation>)annotation;</div></div><div><div>向地图窗口添加标注,需要实现BMKMapViewDelegate的-mapView:viewForAnnotation:函数来生成标注对应的View</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">BMKMapView</div></div><div><div>- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id<BMKAnnotation>)annotation;</div></div><div><div>根据anntation生成对应的View</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">BMKMapView</div></div><div><div>- (void)mapView:(BMKMapView *)mapView regionDidChangeAnimated:(BOOL)animated reason:(BMKRegionChangeReason)reason;</div></div><div><div>地图区域改变完成后会调用此方法</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">BMKLocationManager</div></div><div><div>- (BOOL)requestLocationWithReGeocode:(BOOL)withReGeocode withNetworkState:(BOOL)withNetWorkState completionBlock:(BMKLocatingCompletionBlock _Nonnull)completionBlock;</div></div><div><div>开始单次定位</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">BMKGeoCodeSearch</div></div><div><div>- (void)onGetReverseGeoCodeResult:(BMKGeoCodeSearch *)searcher result:(BMKReverseGeoCodeSearchResult *)result errorCode:(BMKSearchErrorCode)error;</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" style="margin-left: 10px;"><div style="line-height: 26px;">签到场景的核心难点在于解决定位不准的情况下纠正用户位置,示例中提供用户手动纠正位置功能来解决这一问题。<br/>当正常通过定位确定用户位置之后,会给出周边POI列表供用户选择准确位置。<br/>当定位发生微小漂移时,用户通过手动移动地图做位置调整,当前微调范围被限定在500米以内(可自定义),超过500米时弹出toast告知用户“微调距离不可超过500米”。</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">_mapView = [[BMKMapView alloc] initWithFrame: CGRectMake(0, 0, SCREEN_WIDTH, CONTENT_HEIGHT - 200)]; | |
− | + | // 地图比例尺级别 | |
− | + | _mapView.zoomLevel = 17; | |
− | + | // 设置代理 | |
− | + | _mapView.delegate = self; | |
− | + | ||
− | + | </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.添加签到范围overlay</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">// 创建overlay | |
− | + | _circleOverlay = [[BMKCircle alloc] init]; | |
− | + | _circleOverlay.coordinate = CLLocationCoordinate2DMake(40.055854, 116.306761); | |
− | + | _circleOverlay.radius = 500; | |
− | + | // 添加overlay | |
− | + | [self.mapView addOverlay:self.circleOverlay]; | |
− | + | ||
− | + | </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">_locationManager = [[BMKLocationManager alloc] init]; | |
− | + | // 设置返回位置的坐标系类型 | |
− | + | _locationManager.coordinateType = BMKLocationCoordinateTypeBMK09LL; | |
− | + | // 设置距离过滤参数 | |
− | + | _locationManager.distanceFilter = 5.0; | |
− | + | // 设置预期精度参数 | |
− | + | _locationManager.desiredAccuracy = kCLLocationAccuracyBest; | |
− | + | // 设置应用位置类型 | |
− | + | _locationManager.activityType = CLActivityTypeAutomotiveNavigation; | |
− | + | // 设置是否自动停止位置更新 | |
− | + | _locationManager.pausesLocationUpdatesAutomatically = NO; | |
− | + | // 设置位置获取超时时间 | |
− | + | _locationManager.locationTimeout = 10; | |
− | + | // 设置获取地址信息超时时间 | |
− | + | _locationManager.reGeocodeTimeout = 10; | |
− | + | // 设置delegate | |
− | + | _locationManager.delegate = self; | |
− | + | ||
− | + | </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>4.开始定位</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">[self.locationManager requestLocationWithReGeocode:YES withNetworkState:YES completionBlock:^(BMKLocation * _Nullable location, BMKLocationNetworkState state, NSError * _Nullable error) { | |
− | + | // 定位错误信息 | |
− | + | if (error) { | |
− | + | NSLog(@"locError:{%zd - %@};", error.code, error.localizedDescription); | |
− | + | return; | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | [ | + | |
− | + | ||
− | }); | + | |
} | } | ||
− | + | ||
− | } | + | // 定位结果 |
+ | if (location) { | ||
+ | CLLocationCoordinate2D coord = location.location.coordinate; | ||
+ | // 逆地理编码,获取当前位置周边POI | ||
+ | [self rgcSearch:coord]; | ||
+ | // 设置地图中心点 | ||
+ | [self.mapView setCenterCoordinate:coord]; | ||
+ | // 更新当前位置数据 | ||
+ | [self updateUserLocation:coord]; | ||
+ | }]; | ||
+ | |||
+ | </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>5.定位成功添加当前位置Annotation</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">// 创建当前位置Annotation | ||
+ | _userLocAnnotation = [[BMKPointAnnotation alloc] init]; | ||
+ | _userLocAnnotation.isLockedToScreen = YES; | ||
− | + | // 经纬度转屏幕坐标 | |
− | + | CGPoint userLocScreenPoint = [self.mapView convertCoordinate:coord toPointToView:self.mapView]; | |
− | + | // 设置当前位置锁定到屏幕的坐标 | |
− | + | self.userLocAnnotation.screenPointToLock = userLocScreenPoint; | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | // 添加当前位置Annotation | |
− | + | if (![self.mapView.annotations containsObject:self.userLocAnnotation]) { | |
− | + | [self.mapView addAnnotation:self.userLocAnnotation]; | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
} | } | ||
− | + | ||
− | + | ||
− | + | ||
</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-nav"><div>6.逆地理编码,获取当前位置周边签到范围内的POI</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">// 初始化逆地理编码检索对象 | |
− | + | BMKGeoCodeSearch *search = [[BMKGeoCodeSearch alloc] init]; | |
− | + | // 设置正地理编码检索代理 | |
− | + | search.delegate = self; | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | / | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | // 构造逆地理编码检索参数 | |
− | + | BMKReverseGeoCodeSearchOption *searchOption = [[BMKReverseGeoCodeSearchOption alloc] init]; | |
− | + | // 待解析的经纬度坐标(必选) | |
− | + | searchOption.location = coord; | |
− | + | // 设置POI召回半径,此处等于签到范围半径 | |
− | + | searchOption.radius = 500; | |
− | + | // 是否访问最新版行政区划数据(仅对中国数据生效) | |
− | + | searchOption.isLatestAdmin = YES; | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | // 发起逆地理编码检索请求 | ||
+ | [search reverseGeoCode:searchOption]; | ||
+ | |||
</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-nav"><div>7.获取自定义View截图</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 userLocCoord = [self.mapView convertPoint:self.userLocAnnotation.screenPointToLock toCoordinateFromView:self.mapView]; | |
− | + | // 判断当前位置是否在签到范围内 | |
− | + | BOOL isContains = BMKCircleContainsCoordinate(userLocCoord, self.circleOverlay.coordinate, self.circleOverlay.radius); | |
− | + | if (isContains) { // 在签到范围内 | |
− | + | self.signInCoord = userLocCoord; | |
− | + | } else { // 在签到范围外 | |
− | + | [self showMsg:@"微调距离不可超过500米"]; | |
− | + | [mapView setCenterCoordinate:self.userLocCoord animated: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="pre-nav"><div>8.签到</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">// 添加签到位置标注 | |
− | + | [self.mapView addAnnotation:self.signInLocAnnotation]; | |
− | + | // 调用签到接口 | |
− | + | ||
− | + | </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></div> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | <div class=" | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | </div> | + |
2020年9月1日 (二) 15:12的版本
签到场景
功能场景
本示例展示了如何在附近位置场所进行签到。
Android
iOS
//mapopen-website-wiki.bj.bcebos.com/demos/签到.mp4
1590746640|//mapopen-website-wiki.bj.bcebos.com/demos/newqrcodes/签到.png
扫码体验
使用产品
Android地图SDK|/index.php?title=androidsdk
Android定位SDK|/index.php?title=android-locsdk
下载源码
//mapopen-website-wiki.bj.bcebos.com/demos/location/SignInSceneLocationDemo.zip
核心接口
类
接口
描述
备注
ReverseGeoCodeOption
newVersion(int latestAdmin)
设置是否返回新数据1返回0不返回
地图SDK
ReverseGeoCodeOption
radius(500)
POI召回半径,允许设置区间为0-1000米,超过1000米按1000米召回。默认值为1000
地图SDK
SpatialRelationUtil
isCircleContainsPoint(LatLng center, int radius, LatLng point)
判断圆形是否包含传入的经纬度点
地图SDK
LocationClient
start()
启动定位sdk
定位SDK
LocationClient
setLocOption(LocationClientOption locOption)
给定位客户端设置参数
定位SDK
BDAbstractLocationListener
BDAbstractLocationListener
监听定位结果回调函数
定位SDK
重点关注
签到场景的核心难点在于解决定位不准的情况下纠正用户位置,示例中提供用户手动纠正位置功能来解决这一问题。
当正常通过定位确定用户位置之后,会给出周边POI列表供用户选择准确位置。
当定位发生微小漂移时,用户通过手动移动地图做位置调整,当前微调范围被限定在500米以内(可自定义),超过500米时弹出toast告知用户“微调距离不可超过500米”。