Commit 86abada5 authored by wanglei's avatar wanglei

init

parent ec04f8fb
......@@ -2,7 +2,9 @@ package com.base.locationsharewhite.ui.locationmap
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import androidx.activity.addCallback
import androidx.lifecycle.lifecycleScope
import com.base.locationsharewhite.R
import com.base.locationsharewhite.databinding.ActivityLocationMapBinding
import com.base.locationsharewhite.helper.BaseActivity
......@@ -10,12 +12,18 @@ import com.base.locationsharewhite.map.MapUtils.addLocationMarker
import com.base.locationsharewhite.map.MapUtils.cameraMovePointsBounds
import com.base.locationsharewhite.map.MapUtils.getLastKnowLatLng
import com.base.locationsharewhite.utils.BarUtils
import com.base.locationsharewhite.utils.BitmapUtils
import com.base.locationsharewhite.utils.LogEx
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.Marker
import com.google.android.gms.maps.model.MarkerOptions
import com.google.android.gms.maps.model.PolylineOptions
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapReadyCallback {
......@@ -57,6 +65,9 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
val chunxilu = LatLng(30.655782251943407, 104.07701072527895)
showMeAndFriendLocation(chunxilu)
rotateMarker()
}
......@@ -67,7 +78,7 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
val myAvatar = LayoutInflater.from(this).inflate(R.layout.avatar_me, null)
val friendAvatar = LayoutInflater.from(this).inflate(R.layout.avatar_friend, null)
map?.addLocationMarker(myAvatar, myPair, "my")
// map?.addLocationMarker(myAvatar, myPair, "my")
map?.addLocationMarker(friendAvatar, friendLatLng, "friend")
val padding = resources.getDimensionPixelOffset(R.dimen.dp_150)
......@@ -88,6 +99,30 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
LatLng(30.654908885860806, 104.08053620625755),//ifs
)
fun rotateMarker() {
val myAvatar = LayoutInflater.from(this).inflate(R.layout.avatar_me, null)
val myPair: LatLng = getLastKnowLatLng()
val bitmapDescriptor = BitmapUtils.getBitmapDescriptorFromLayoutResId(myAvatar)
val marker: Marker? = map?.addMarker(
MarkerOptions()
.icon(bitmapDescriptor)
.position(myPair)
.anchor(0.5f, 0.5f) // 设置锚点为中心
.rotation(90.0f) // 设置旋转角度
.flat(true)
) // 设置为平面Marker
lifecycleScope.launch {
for (i in 0..360) {
marker?.rotation = i.toFloat()
delay(200)
}
}
}
fun addFriendPolyline(list: List<LatLng>) {
map?.addPolyline(PolylineOptions().apply {
list.forEach { add(it) }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment