Android-, Kotlin- und Google Maps-MarkerAndroid

Forum für diejenigen, die für Android programmieren
Anonymous
 Android-, Kotlin- und Google Maps-Marker

Post by Anonymous »

Ich versuche, eine Android-App mit Kotlin in Android Studio zu entwickeln. Ich möchte in meiner App in Google Maps Markierungen für die Apotheke erstellen. Meine Frage steht in meinem Code:

Code: Select all

private fun searchNearbyPharmacies(location: LatLng) {

val placeFields = listOf(Place.Field.DISPLAY_NAME, Place.Field.LOCATION, Place.Field.TYPES)
val request = FindCurrentPlaceRequest.newInstance(placeFields)

placesClient.findCurrentPlace(request)
.addOnSuccessListener { response ->
for (placeLikelihood in response.placeLikelihoods) {
val place = placeLikelihood.place
val placeTypes = placeLikelihood.place.placeTypes
placeTypes?.forEach { placeType ->
Log.i("PlaceType", "Place type: $placeType")
}

if (placeTypes?.contains(PlaceTypes.PHARMACY) == true) {
val latLng = place.location
latLng?.let {
addMarkerForPharmacy(latLng, place.displayName ?: "Pharmacy")
}
}
}
}.addOnFailureListener { exception ->
exception.printStackTrace()
}
}
in den placeTypes gibt es keine Apotheke, warum ist das so? Wie kann ich das Problem beheben?
Der Code funktioniert so, als ob ich ihn im folgenden Code von PlaceTypes.PHARMACY in PlaceTypes.MUSEUM ändern würde

Code: Select all

if (placeTypes?.contains(PlaceTypes.MUSEUM) == true)
Ich kann Markierungen für andere Arten von Orten wie in diesem Fall das Museum erstellen.
Vielen Dank im Voraus.
Der Code ist in Ordnung, da ich Markierungen wie Einrichtung, Sehenswürdigkeit, Museum usw. erstellen kann. Aber es gibt dort keine Apotheke. Aber wenn ich in die Karte hineinzoome, kann ich Pharmacys sehen. Ich habe es im Emulator und auch mit einem echten Gerät versucht.
Ich schreibe die Ortstypen in das Protokoll und es gibt nur diese Typen:

Code: Select all

placeTypes?.forEach { placeType ->Log.i("PlaceType", "Place type: $placeType")}

I  Place type: tourist_attraction
I  Place type: point_of_interest
I  Place type: establishment
I  Place type: street_address
I  Place type: transit_station
I  Place type: cafe
I  Place type: bar
I  Place type: restaurant
I  Place type: food
I  Place type: store
I  Place type: museum

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post