JSAPI GL版基础地图展示
功能场景
使用GL版的JSAPI来创建一张基础地图,GL版地图命名空间为BMapGL,支持三维地图,以及地图的旋转倾斜等。
//mapopen-website-wiki.bj.bcebos.com/demos/AndroidVideos/Android Fragment加载地图.mp4
1590746640|//mapopen-website-wiki.bj.bcebos.com/demos/newqrcodes/Fragment.png
扫码体验
使用产品
Android地图SDK|/index.php?title=androidsdk
>
显示地图|/index.php?title=androidsdk/guide/create-map/showmap
下载源码
//mapopen-website-wiki.bj.bcebos.com/demos/BaiduMapSDKExample.zip
/**
* 初始化地图
*/
private void initMapFragment() {
mFragmentManager = getSupportFragmentManager();
BaiduMapOptions baiduMapOptions = new BaiduMapOptions();
baiduMapOptions.mapType(BaiduMap.MAP_TYPE_SATELLITE);
mMapFragment = SupportMapFragment.newInstance(baiduMapOptions);
mFragmentManager.beginTransaction()
.add(R.id.map
, mMapFragment
, sNormalFragmentTag)
.commit();
}
复制成功
//mapopen-website-wiki.bj.bcebos.com/demos/iostest.MP4
//mapopen-website-wiki.bj.bcebos.com/demos/play.png
扫码手机观看
使用产品
产品1|/index.php?title=test
>
产品2|/index.php?title=test
下载源码
//mapopen-website-wiki.bj.bcebos.com/demos/xs%20max.png
- (void)clearClusterItems;
- (NSArray<BMKCluster *> *)getClusters:(CGFloat)zoomLevel;
(AMapPOIAroundSearchRequest *)request;
(AMapPOIAroundSearchRequest *)request;
(AMapPOIAroundSearchRequest *)request;
(AMapPOIAroundSearchRequest *)request;
(AMapPOIAroundSearchRequest *)request;
1.第一步
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];
});
});
}
}
}
复制成功
2.第二步
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];
});
});
}
}
}
复制成功
3.名字
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];
});
});
}
}
}
复制成功
点标记动画|/index.php?title=test
点融合|/index.php?title=test
添加文字和信息窗|/index.php?title=test