Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
L
location share white
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
location share white
Commits
86abada5
Commit
86abada5
authored
Oct 18, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
ec04f8fb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
1 deletion
+36
-1
LocationMapActivity.kt
.../locationsharewhite/ui/locationmap/LocationMapActivity.kt
+36
-1
No files found.
app/src/main/java/com/base/locationsharewhite/ui/locationmap/LocationMapActivity.kt
View file @
86abada5
...
...
@@ -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
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment