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
f5a0f47e
Commit
f5a0f47e
authored
Oct 18, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
e2df39b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
1 deletion
+41
-1
LocationMapActivity.kt
.../locationsharewhite/ui/locationmap/LocationMapActivity.kt
+41
-1
No files found.
app/src/main/java/com/base/locationsharewhite/ui/locationmap/LocationMapActivity.kt
View file @
f5a0f47e
...
@@ -22,7 +22,9 @@ import com.google.android.gms.maps.model.LatLng
...
@@ -22,7 +22,9 @@ import com.google.android.gms.maps.model.LatLng
import
com.google.android.gms.maps.model.Marker
import
com.google.android.gms.maps.model.Marker
import
com.google.android.gms.maps.model.MarkerOptions
import
com.google.android.gms.maps.model.MarkerOptions
import
com.google.android.gms.maps.model.PolylineOptions
import
com.google.android.gms.maps.model.PolylineOptions
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.isActive
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
...
@@ -83,9 +85,10 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
...
@@ -83,9 +85,10 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
val
chunxilu
=
LatLng
(
30.655782251943407
,
104.07701072527895
)
val
chunxilu
=
LatLng
(
30.655782251943407
,
104.07701072527895
)
initMyAndFriendLocation
(
chunxilu
)
initMyAndFriendLocation
(
chunxilu
)
sharingLocationJob
()
}
}
fun
resetMyLocation
()
{
private
fun
resetMyLocation
()
{
val
myLatLng
:
LatLng
=
getLastKnowLatLng
()
val
myLatLng
:
LatLng
=
getLastKnowLatLng
()
myMarker
?.
position
=
myLatLng
myMarker
?.
position
=
myLatLng
map
?.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
myLatLng
,
15f
))
map
?.
moveCamera
(
CameraUpdateFactory
.
newLatLngZoom
(
myLatLng
,
15f
))
...
@@ -162,4 +165,41 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
...
@@ -162,4 +165,41 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
})
})
}
}
private
var
sharingJob
:
Job
?
=
null
fun
sharingLocationJob
()
{
if
(
sharingJob
==
null
)
{
myMarker
?:
return
friendMarker
?:
return
var
i
=
0f
var
j
=
0f
sharingJob
=
lifecycleScope
.
launch
{
while
(
isActive
)
{
i
+=
0.001f
j
+=
0.001f
val
myLatLng
=
getLastKnowLatLng
()
myMarker
?.
position
=
myLatLng
//上传我的位置,获取friend位置
val
friendLatLng
=
LatLng
(
30.655782251943407
+
i
,
104.07701072527895
+
j
)
friendMarker
?.
position
=
friendLatLng
delay
(
1
*
1000L
)
}
}
}
}
private
fun
cancelSharingJob
()
{
sharingJob
?.
cancel
()
sharingJob
=
null
}
override
fun
onPause
()
{
super
.
onPause
()
cancelSharingJob
()
}
}
}
\ No newline at end of file
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