百度地图API,指定比例尺大小

时间:2014-09-02 12:26:34   收藏:0   阅读:971

百度地图在自动定位时,出现的比例尺大小是默认的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) {

}
}

原文:http://blog.csdn.net/rbyyyblog/article/details/39003473

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!