arcgis android 指南针,Arcgis runtime for Android 100.5 (六) 自定义指南针
Arcgis沒有提供指南針控件,如果需要,可以自定義一個,很簡單
去阿里圖標庫下載一個能用的指南針如
指南針
放置在布局文件中
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:id="@+id/ivCompass"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="5dp"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:src="@mipmap/ic_compass" />
監聽地圖旋轉角度,指南針跟著轉
private var lastBearing = 0f//指南針最后旋轉角度
mapView.addMapRotationChangedListener {
val bearing: Float =
(360f - mapView.mapRotation).toFloat()
//創建指南針旋轉動畫
val rotateAnimation = RotateAnimation(
lastBearing, bearing, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f
)
rotateAnimation.fillAfter = true
ivCompass.startAnimation(rotateAnimation)
lastBearing = bearing
}
點擊指南針,地圖角度回正
ivCompass.setOnClickListener {
mapView.setViewpointRotationAsync(0.0)
}
這樣就OK了
總結
以上是生活随笔為你收集整理的arcgis android 指南针,Arcgis runtime for Android 100.5 (六) 自定义指南针的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 大数据笔试题目练习(附答案)
- 下一篇: php表格升序降序,excel如何实现升