自己定义写的比例尺,调用高德地图的API 实现 放大 +缩小 功能:
case R.id.enlarge:
//enlarge
troubleMap.moveCamera(CameraUpdateFactory.zoomIn());
App.d(" enlarge zoom :" +troubleMap.getCameraPosition().zoom);
break;
case R.id.narrow:
//narrow
troubleMap.moveCamera(CameraUpdateFactory.zoomOut());
App.d(" narrow zoom :"+troubleMap.getCameraPosition().zoom);
break;
case R.id.zoomer:
App.d(TAG+" zoomer click ");
break;
响应放大缩小的图标背景变化 要如下:
public void onCameraChangeFinish(CameraPosition cameraPosition) {
App.d("----m1ZoomLevel : onCameraChangeFinish :"+cameraPosition.zoom);
if(cameraPosition.zoom==troubleMap.getMaxZoomLevel()){
App.d("troubleMap.getMaxZoomLevel() :"+troubleMap.getMaxZoomLevel());
enlargeBtn.setBackgroundResource(R.drawable.ic_unenlarge);
enlargeBtn.setClickable(false);
}else if(cameraPosition.zoom==troubleMap.getMinZoomLevel()){
App.d("troubleMap.getMinZoomLevel() :"+troubleMap.getMinZoomLevel());
narrowBtn.setBackgroundResource(R.drawable.ic_unnarrow);
narrowBtn.setClickable(false);
}else{
enlargeBtn.setClickable(true);
narrowBtn.setClickable(true);
enlargeBtn.setBackgroundResource(R.drawable.ic_enlargeble);
narrowBtn.setBackgroundResource(R.drawable.ic_narrow);
}
其它地方,去得到的当前缩放级别
troubleMap.getCameraPosition().zoom 都不是当前的,只有上面方法才是
网友评论