|
|
第1行: |
第1行: |
− | <div id="examples_center"> | + | <div id="examples_api_center"><div class="title-hd">基础地图展示</div></div><div class="demos_wrap"><div class="header"><div class="active">功能场景</div></div><div class="wrap-mi">该示例介绍如何使用GL版API创建一张地图,并通过设置地图类型方法,展示3D地图与卫星地球地图之间的切换。</div><div class="header"><div class="active">DEMO</div></div><div class="andiord-wrap wrap"><div class="wrap-wp"><div class="pc-video"><div class="video-box infor"><div class="video-control1"></div><pre>https://mapopen-website-wiki.cdn.bcebos.com/wiki/android-loc-sdk/sdkgetAK.mov</pre> |
− | <div class="title-hd">JSAPI GL版基础地图展示</div>
| + | </div><div class="video-title1">常规3D地图与卫星地球模式切换</div></div></div><div class="api-table-box"><div class="api-top"><div class="pre-nav"><div class="left-icon"></div><div>相关文档</div></div><div><div class="documentA">Android地图SDK|/index.php?title=androidsdk</div><div></div><div class="documentA">显示地图|/index.php?title=androidsdk/guide/create-map/showmap</div></div></div><div class="api-bottom"><div class="pre-nav"><div class="left-icon"></div><div>核心接口</div></div></div></div><div class="header"><div class="active">核心代码</div></div><div class="pre-wrap"><div class="pre-wrap-w pre-wrap-w-and"><pre class="prettyprint prettyprinted pre-and">/** |
− | <div class="title-mi">功能场景</div>
| + | * 初始化地图 |
− | <div class="wrap-mi">使用GL版的JSAPI来创建一张基础地图,GL版地图命名空间为BMapGL,支持三维地图,以及地图的旋转、倾斜等。</div></div>
| + | */ |
− | <div class="demos_wrap"> | + | private void initMapFragment() { |
− | <div class="header">
| + | mFragmentManager = getSupportFragmentManager(); |
− | <div class="andiord-header active">Android</div>
| + | BaiduMapOptions baiduMapOptions = new BaiduMapOptions(); |
− | <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/Android Fragment加载地图.mp4</pre>
| + | baiduMapOptions.mapType(BaiduMap.MAP_TYPE_SATELLITE); |
− | </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/Fragment.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>></div><div class="documentA">显示地图|/index.php?title=androidsdk/guide/create-map/showmap</div></div></div><div class="wrap_right_nav_r">下载源码</div><!-- 安卓源码地址 --><div class="github-url-and">//mapopen-website-wiki.bj.bcebos.com/demos/BaiduMapSDKExample.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">SupportMapFragment</div></div><div><div>newInstance ()</div></div><div><div>创建fragment实例</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-nav"><div>JAVA</div></div><!-- 安卓示例代码位置 --><div class="pre-wrap-w pre-wrap-w-and"><pre class="prettyprint prettyprinted pre-and">/** | + | mMapFragment = SupportMapFragment.newInstance(baiduMapOptions); |
− | * 初始化地图 | + | mFragmentManager.beginTransaction() |
− | */ | + | .add(R.id.map |
− | private void initMapFragment() { | + | , mMapFragment |
− | mFragmentManager = getSupportFragmentManager();
| + | , sNormalFragmentTag) |
− | BaiduMapOptions baiduMapOptions = new BaiduMapOptions();
| + | .commit(); |
− | baiduMapOptions.mapType(BaiduMap.MAP_TYPE_SATELLITE);
| + | } |
− | mMapFragment = SupportMapFragment.newInstance(baiduMapOptions);
| + | |
− | mFragmentManager.beginTransaction()
| + | |
− | .add(R.id.map
| + | |
− | , mMapFragment
| + | |
− | , sNormalFragmentTag)
| + | |
− | .commit();
| + | |
− | } | + | |
| </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 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> |
− | </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">产品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 class="table_wrap_w"><div><div class="table-wrap-className">AMapSearchAP</div></div><div><div>(AMapPOIAroundSearchRequest *)request;</div></div><div><div>POI周边查询接口</div></div><div><div>V4.0.0起</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">AMapSearchAP</div></div><div><div>(AMapPOIAroundSearchRequest *)request;</div></div><div><div>POI周边查询接口</div></div><div><div>V4.0.0起</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">abcdefg</div></div><div><div>(AMapPOIAroundSearchRequest *)request;</div></div><div><div>POI周边查询接口</div></div><div><div>V4.0.0起</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">abcdefg</div></div><div><div>(AMapPOIAroundSearchRequest *)request;</div></div><div><div>POI周边查询接口</div></div><div><div>V4.0.0起</div></div></div><div class="table_wrap_w"><div><div class="table-wrap-className">abcdefg</div></div><div><div>(AMapPOIAroundSearchRequest *)request;</div></div><div><div>POI周边查询接口</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
| + | |
− | /** 更新标注展示. */
| + | |
− | - (void)updateClusters {
| + | |
− | _clusterZoom = (NSInteger)_mapView.zoomLevel;
| + | |
− | @synchronized(_clusterManager.clusterCaches) {
| + | |
− | NSMutableArray *clusters = [_clusterManager.clusterCaches objectAtIndex:(_clusterZoom - 3)];
| + | |
− | if (clusters.count > 0) {
| + | |
− | | + | |
− | // 移除一组标注
| + | |
− | [_mapView removeAnnotations:_mapView.annotations];
| + | |
− | //将一组标注添加到当前地图View中
| + | |
− | [_mapView addAnnotations:clusters];
| + | |
− | } else {
| + | |
− | __weak typeof(self) weakSelf = self;
| + | |
− | dispatch_async(dispatch_get_global_queue(0, 0), ^{
| + | |
− | // 获取聚合后的标注
| + | |
− | __block NSArray *array = [weakSelf.clusterManager getClusters:weakSelf.clusterZoom];
| + | |
− | dispatch_async(dispatch_get_main_queue(), ^{
| + | |
− | for (BMKCluster *item in array) {
| + | |
− | ClusterAnnotation *annotation = [[ClusterAnnotation alloc] init];
| + | |
− | // 设置标注的经纬度坐标
| + | |
− | annotation.coordinate = item.coordinate;
| + | |
− | annotation.size = item.size;
| + | |
− | // 设置标注的标题
| + | |
− | annotation.title = [NSString stringWithFormat:@"我是%lu个", (unsigned long)item.size];
| + | |
− | [clusters addObject:annotation];
| + | |
− | }
| + | |
− | // 移除一组标注
| + | |
− | [weakSelf.mapView removeAnnotations:weakSelf.mapView.annotations];
| + | |
− | // 将一组标注添加到当前地图View中
| + | |
− | [weakSelf.mapView addAnnotations:clusters];
| + | |
− | });
| + | |
− | });
| + | |
− | }
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | </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
| + | |
− | /** 更新标注展示. */
| + | |
− | - (void)updateClusters {
| + | |
− | _clusterZoom = (NSInteger)_mapView.zoomLevel;
| + | |
− | @synchronized(_clusterManager.clusterCaches) {
| + | |
− | NSMutableArray *clusters = [_clusterManager.clusterCaches objectAtIndex:(_clusterZoom - 3)];
| + | |
− | if (clusters.count > 0) {
| + | |
− | | + | |
− | // 移除一组标注
| + | |
− | [_mapView removeAnnotations:_mapView.annotations];
| + | |
− | //将一组标注添加到当前地图View中
| + | |
− | [_mapView addAnnotations:clusters];
| + | |
− | } else {
| + | |
− | __weak typeof(self) weakSelf = self;
| + | |
− | dispatch_async(dispatch_get_global_queue(0, 0), ^{
| + | |
− | // 获取聚合后的标注
| + | |
− | __block NSArray *array = [weakSelf.clusterManager getClusters:weakSelf.clusterZoom];
| + | |
− | dispatch_async(dispatch_get_main_queue(), ^{
| + | |
− | for (BMKCluster *item in array) {
| + | |
− | ClusterAnnotation *annotation = [[ClusterAnnotation alloc] init];
| + | |
− | // 设置标注的经纬度坐标
| + | |
− | annotation.coordinate = item.coordinate;
| + | |
− | annotation.size = item.size;
| + | |
− | // 设置标注的标题
| + | |
− | annotation.title = [NSString stringWithFormat:@"我是%lu个", (unsigned long)item.size];
| + | |
− | [clusters addObject:annotation];
| + | |
− | }
| + | |
− | // 移除一组标注
| + | |
− | [weakSelf.mapView removeAnnotations:weakSelf.mapView.annotations];
| + | |
− | // 将一组标注添加到当前地图View中
| + | |
− | [weakSelf.mapView addAnnotations:clusters];
| + | |
− | });
| + | |
− | });
| + | |
− | }
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | </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
| + | |
− | /** 更新标注展示. */
| + | |
− | - (void)updateClusters {
| + | |
− | _clusterZoom = (NSInteger)_mapView.zoomLevel;
| + | |
− | @synchronized(_clusterManager.clusterCaches) {
| + | |
− | NSMutableArray *clusters = [_clusterManager.clusterCaches objectAtIndex:(_clusterZoom - 3)];
| + | |
− | if (clusters.count > 0) {
| + | |
− | | + | |
− | // 移除一组标注
| + | |
− | [_mapView removeAnnotations:_mapView.annotations];
| + | |
− | //将一组标注添加到当前地图View中
| + | |
− | [_mapView addAnnotations:clusters];
| + | |
− | } else {
| + | |
− | __weak typeof(self) weakSelf = self;
| + | |
− | dispatch_async(dispatch_get_global_queue(0, 0), ^{
| + | |
− | // 获取聚合后的标注
| + | |
− | __block NSArray *array = [weakSelf.clusterManager getClusters:weakSelf.clusterZoom];
| + | |
− | dispatch_async(dispatch_get_main_queue(), ^{
| + | |
− | for (BMKCluster *item in array) {
| + | |
− | ClusterAnnotation *annotation = [[ClusterAnnotation alloc] init];
| + | |
− | // 设置标注的经纬度坐标
| + | |
− | annotation.coordinate = item.coordinate;
| + | |
− | annotation.size = item.size;
| + | |
− | // 设置标注的标题
| + | |
− | annotation.title = [NSString stringWithFormat:@"我是%lu个", (unsigned long)item.size];
| + | |
− | [clusters addObject:annotation];
| + | |
− | }
| + | |
− | // 移除一组标注
| + | |
− | [weakSelf.mapView removeAnnotations:weakSelf.mapView.annotations];
| + | |
− | // 将一组标注添加到当前地图View中
| + | |
− | [weakSelf.mapView addAnnotations:clusters];
| + | |
− | });
| + | |
− | });
| + | |
− | }
| + | |
− | }
| + | |
− | }
| + | |
− | | + | |
− | </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>
| + | |