设为首页 加入收藏

TOP

百度地图API,指定比例尺大小
2015-07-20 17:46:13 来源: 作者: 【 】 浏览:3
Tags:百度 地图 API 指定 比例尺 大小

百度地图在自动定位时,出现的比例尺大小是默认的5公里。但这个范围太大,不能满足应用需求,需要在定位时指定比例尺大小。通过摸索和查询,终于找到了解决方法。

就是要在定位监听中加入以下代码,

float f = mBaiduMap.getMaxZoomLevel();//19.0 最小比例尺
// float m = mBaiduMap.getMinZoomLevel();//3.0 最大比例尺
MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(ll, f-2);//设置到100米的大小

整体的代码:

/**
* 定位SDK监听函数
*/
protected class MyLocationListenner implements BDLocationListener {


@Override
public void onReceiveLocation(BDLocation location) {
// map view 销毁后不在处理新接收的位置
if (location == null || mMapView == null)
return;
MyLocationData locData = new MyLocationData.Builder()
.accuracy(location.getRadius())// 此处设置开发者获取到的方向信息,顺时针0-360
.direction(100).latitude(location.getLatitude())
.longitude(location.getLongitude()).build();
mBaiduMap.setMyLocationData(locData);
LatLng ll = new LatLng(location.getLatitude(),
location.getLongitude());
float f = mBaiduMap.getMaxZoomLevel();//19.0
// float m = mBaiduMap.getMinZoomLevel();//3.0
MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(ll, f-2);
mBaiduMap.animateMapStatus(u);
}


public void onReceivePoi(BDLocation poiLocation) {

}
}

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇hdu4780 费用流 (机器任务工作不.. 下一篇codeforces T-primes 230 B 素数..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·新书介绍《Python数 (2025-12-25 04:49:47)
·怎么利用 Python 进 (2025-12-25 04:49:45)
·金融界大佬力荐,Pyt (2025-12-25 04:49:42)
·你必须要弄懂的多线 (2025-12-25 04:22:35)
·如何在 Java 中实现 (2025-12-25 04:22:32)