高德地图sdk默认的地图放大缩小控件由于大小不太合适,因此我们又自己定义了一个

1.在布局文件中定义两个ImageView

                       "@+id/iv_zoom_large"                        android:clickable="true"                        android:src="@drawable/icon_zoom_large"                        android:layout_width="35dp"                        android:layout_height="35dp"                        android:scaleType="fitXY"                        />                    "@+id/iv_zoom_small"                        android:clickable="true"                        android:src="@drawable/icon_zoom_small"                        android:layout_width="35dp"                        android:layout_height="35dp"                        android:scaleType="fitXY"

2.处理放大缩小的点击事件

 @OnClick({R.id.iv_zoom_small, R.id.rl_scale_loc_compass})    public void onClick(View view) {        Intent intent;         CameraPosition cameraPosition;         float mapZoom;         LatLng mapTarget;        switch (view.getId()) {            case R.id.iv_zoom_large:                cameraPosition = aMap.getCameraPosition();                mapZoom = cameraPosition.zoom;                mapTarget = cameraPosition.target;                Log.d(TAG, "onClick: large"+cameraPosition.target.latitude+":"+mapZoom);                scaleLargeMap(mapTarget, ++mapZoom);                break;            case R.id.iv_zoom_small:                 cameraPosition = aMap.getCameraPosition();                 mapZoom = cameraPosition.zoom;                 mapTarget = cameraPosition.target;                Log.d(TAG, "onClick: small"+cameraPosition.target.latitude+":"+mapZoom);                scaleLargeMap(mapTarget,--mapZoom);                break;            case R.id.rl_scale_loc_compass:                break;        }    }  public void scaleLargeMap(LatLng nowLocation,float scaleValue) {        aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(nowLocation, scaleValue));//        aMap.moveCamera();    }

更多相关文章

  1. ImageView的属性android:scaleType
  2. 自定义Android应用程序标题条
  3. Android日志系统分析之日志设备驱动程序代码阅读
  4. android 自带的主题 theme 的使用
  5. 自定义RadioButton 文字在下,图片在上
  6. android 自定义加减按钮
  7. android AlertDialog 弹窗自定义布局 点击外部不关闭弹窗
  8. 自定义progressbar使用图片
  9. Android(安卓)VectorDrawable与SVG

随机推荐

  1. Android实现语音识别 && 讯飞平台语音识
  2. 学Android开发的人可以去的几个网站
  3. Android O/P/Q 版本如何预装 APK
  4. CMake学习
  5. Android 电子书应用完全开源代码
  6. MTP in Android
  7. Android 抢购功能(时间戳之间的倒计时)
  8. Android 获取网络视频某一帧图片
  9. Android(安卓)Lottie动画初探
  10. Unity3D和Android之间的方法交互(jar模式