Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
com.akaver.sportmap
SportMap-Android
Commits
317807b0
Commit
317807b0
authored
Apr 20, 2020
by
Andres Käver
Browse files
some drawings on maps
parent
b605075e
Changes
3
Show whitespace changes
Inline
Side-by-side
app/src/main/java/com/akaver/sportmap/C.kt
View file @
317807b0
...
...
@@ -11,6 +11,11 @@ class C {
const
val
LOCATION_UPDATE_ACTION
=
PREFIX
+
"location_update"
const
val
LOCATION_UPDATE_STOP
=
PREFIX
+
"location_stop"
const
val
LOCATION_UPDATE_ACTION_LAT
=
PREFIX
+
"location_update.lat"
const
val
LOCATION_UPDATE_ACTION_LON
=
PREFIX
+
"location_update.lon"
const
val
LOCATION_UPDATE_ACTION_OVERALL_DIRECT
=
PREFIX
+
"location_update.overall_direct"
const
val
LOCATION_UPDATE_ACTION_OVERALL_TOTAL
=
PREFIX
+
"location_update.overall_total"
const
val
LOCATION_UPDATE_ACTION_CP_DIRECT
=
PREFIX
+
"location_update.cp_direct"
...
...
app/src/main/java/com/akaver/sportmap/LocationService.kt
View file @
317807b0
...
...
@@ -235,6 +235,10 @@ class LocationService : Service() {
// broadcast new location to UI
val
intent
=
Intent
(
C
.
LOCATION_UPDATE_ACTION
)
intent
.
putExtra
(
C
.
LOCATION_UPDATE_ACTION_LAT
,
location
.
latitude
)
intent
.
putExtra
(
C
.
LOCATION_UPDATE_ACTION_LON
,
location
.
longitude
)
intent
.
putExtra
(
C
.
LOCATION_UPDATE_ACTION_OVERALL_DIRECT
,
distanceOverallDirect
)
intent
.
putExtra
(
C
.
LOCATION_UPDATE_ACTION_OVERALL_TOTAL
,
distanceOverallTotal
)
intent
.
putExtra
(
C
.
LOCATION_UPDATE_ACTION_CP_DIRECT
,
distanceCPDirect
)
...
...
@@ -288,7 +292,7 @@ class LocationService : Service() {
// broadcast stop to UI
val
intent
=
Intent
(
C
.
LOCATION_UPDATE_
ACTION
)
val
intent
=
Intent
(
C
.
LOCATION_UPDATE_
STOP
)
LocalBroadcastManager
.
getInstance
(
this
).
sendBroadcast
(
intent
)
}
...
...
app/src/main/java/com/akaver/sportmap/MapsActivity.kt
View file @
317807b0
...
...
@@ -24,8 +24,7 @@ import com.google.android.gms.maps.CameraUpdateFactory
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.MarkerOptions
import
com.google.android.gms.maps.model.*
import
com.google.android.material.snackbar.Snackbar
import
kotlinx.android.synthetic.main.map_actions.*
...
...
@@ -35,12 +34,12 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback {
}
private
lateinit
var
mMap
:
GoogleMap
private
var
marker
:
Marker
?
=
null
private
var
mapPolylineOptions
:
PolylineOptions
=
PolylineOptions
()
private
var
mapPolyline
:
Polyline
?
=
null
private
val
broadcastReceiver
=
InnerBroadcastReceiver
()
private
val
broadcastReceiverIntentFilter
:
IntentFilter
=
IntentFilter
()
private
var
locationServiceActive
=
false
...
...
@@ -108,12 +107,35 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback {
mMap
=
googleMap
// Add a marker in Sydney and move the camera
val
sydney
=
LatLng
(-
34.0
,
151.0
)
mMap
.
addMarker
(
MarkerOptions
().
position
(
sydney
).
title
(
"Marker in Sydney"
))
mMap
.
moveCamera
(
CameraUpdateFactory
.
newLatLng
(
sydney
))
//val sydney = LatLng(-34.0, 151.0)
//mMap.addMarker(MarkerOptions().position(sydney).title("Marker in Sydney"))
mMap
.
moveCamera
(
CameraUpdateFactory
.
newLatLng
(
LatLng
(
59.3927437
,
24.6642
)))
mMap
.
animateCamera
(
CameraUpdateFactory
.
zoomTo
(
17.0f
))
}
private
fun
updateMap
(
lat
:
Double
,
lon
:
Double
){
// mMap.clear()
val
center
=
LatLng
(
lat
,
lon
)
if
(
marker
!=
null
){
marker
!!
.
remove
()
}
if
(
mapPolyline
!=
null
){
mapPolyline
!!
.
remove
()
}
mapPolylineOptions
.
add
(
center
)
marker
=
mMap
.
addMarker
(
MarkerOptions
().
position
(
center
).
icon
(
BitmapDescriptorFactory
.
fromResource
(
R
.
drawable
.
baseline_location_searching_black_36
)))
mapPolyline
=
mMap
.
addPolyline
(
mapPolylineOptions
)
mMap
.
moveCamera
(
CameraUpdateFactory
.
newLatLng
(
center
))
}
// ============================================== LIFECYCLE CALLBACKS =============================================
override
fun
onStart
()
{
Log
.
d
(
TAG
,
"onStart"
)
...
...
@@ -272,6 +294,10 @@ class MapsActivity : AppCompatActivity(), OnMapReadyCallback {
textViewCPTotal
.
text
=
intent
.
getFloatExtra
(
C
.
LOCATION_UPDATE_ACTION_CP_TOTAL
,
0.0f
).
toInt
().
toString
()
textViewWPDirect
.
text
=
intent
.
getFloatExtra
(
C
.
LOCATION_UPDATE_ACTION_WP_DIRECT
,
0.0f
).
toInt
().
toString
()
textViewWPTotal
.
text
=
intent
.
getFloatExtra
(
C
.
LOCATION_UPDATE_ACTION_WP_TOTAL
,
0.0f
).
toInt
().
toString
()
updateMap
(
intent
.
getDoubleExtra
(
C
.
LOCATION_UPDATE_ACTION_LAT
,
0.0
),
intent
.
getDoubleExtra
(
C
.
LOCATION_UPDATE_ACTION_LON
,
0.0
))
}
C
.
LOCATION_UPDATE_STOP
->
{
}
}
}
...
...
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