Skip to content

Commit

Permalink
Merge pull request #96 from G12-Wanderwave/display-beacons-on-map
Browse files Browse the repository at this point in the history
Display beacons on map
  • Loading branch information
IB-12 authored Apr 12, 2024
2 parents da21b3e + 55c3cae commit 7e30c10
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class BeaconConnectionTest {

@Test
fun testAddAndGetItem() = runBlocking {
withTimeout(30000) { // Timeout after 5000 milliseconds (20 seconds)
withTimeout(30000) { // Increase the timeout to 30 seconds
val beacon =
Beacon(
id = "testBeacon",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ class BeaconConnection(private val database: FirebaseFirestore? = null) :

override val db = database ?: super.db

// private val db = FirebaseFirestore.getInstance()

// Document to Beacon
override fun documentToItem(document: DocumentSnapshot): Beacon? {
return Beacon.from(document)
Expand Down Expand Up @@ -81,11 +79,7 @@ class BeaconConnection(private val database: FirebaseFirestore? = null) :
val beaconMap: HashMap<String, Any> =
hashMapOf(
"id" to beacon.id,
"location" to
hashMapOf(
"latitude" to beacon.location.latitude,
"longitude" to beacon.location.longitude,
"name" to beacon.location.name),
"location" to beacon.location.toMap(),
"tracks" to
beacon.tracks.map { track ->
db.collection(trackConnection.collectionName).document(track.id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ class TrackConnection(private val database: FirebaseFirestore? = null) :
return track.toMap()
}

fun addList(tracks: List<Track>) {
tracks.forEach { track -> addItemWithId(track) }
}

fun addItemsIfNotExist(tracks: List<Track>) {
// The goal of this function is to add only if the spotify id of the track is not already in the
// database, for now I just check the normal ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.google.accompanist.permissions.MultiplePermissionsState
import com.google.accompanist.permissions.isGranted
import com.google.accompanist.permissions.rememberMultiplePermissionsState
import com.google.android.gms.maps.CameraUpdateFactory
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.model.CameraPosition
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.MapStyleOptions
Expand Down Expand Up @@ -105,9 +106,7 @@ fun WanderwaveGoogleMap(

@Composable
fun MapContent(viewModel: MapViewModel) {
val epfl = LatLng(46.518831258, 6.559331096)
val beacons = viewModel.uiState.collectAsStateWithLifecycle().value.beacons
Marker(state = MarkerState(position = epfl), title = "Marker at EPFL")
val beacons: List<Beacon> = viewModel.uiState.collectAsStateWithLifecycle().value.beacons
DisplayBeacons(beacons = beacons)
}

Expand Down Expand Up @@ -149,15 +148,11 @@ fun moveCamera(
*/
@Composable
fun DisplayBeacons(beacons: List<Beacon>) {

// Add a marker for each beacon
// source for the icon: https://www.svgrepo.com/svg/448258/waypoint
// val customIcon = BitmapDescriptorFactory.fromResource(R.drawable.waypoint)
// Create each beacon from the list
beacons.forEach() {
Marker(
state = MarkerState(position = it.location.toLatLng()),
title = it.id,
// icon = customIcon,
)
}
}

0 comments on commit 7e30c10

Please sign in to comment.