googlemaps / googlemaps/android-maps-compose

Adding support for KmlLayer without relying on MapEffect

Aperta
#447 2 commenti 9 reazioni 0 assegnatari Vedi su GitHub
priority: p2 type: feature request
Lingua principale
Kotlin
Stelle
1.3k
Fork
181
Merge medio
2g 23h
PR unite (30g)
18

Descrizione

As developer I would like to be able to add different layers (Kml, GeoJson, etc) to the GoogleMap composable.

A KmlLayer needs a GoogleMap instance to be built. `KmlLayer(GoogleMap map, int resourceId, Context context)`
At the moment the only way to add a Kml layer is using the experimental `MapEffect` (which it may get removed in the future).

Loading a KmlLayer is also slow so it needs to be done in a background thread.

Considering all of the above I came up with a solution but it would be nice to have a different way to do it.
This solution will not work anymore if MapEffect is removed.

```
val scope = rememberCoroutineScope()
val context = LocalContext.current
val aKmlLayer: KmlLayer? = null
GoogleMap(
...
) {
MapEffect { gMap ->
scope.launch {
withContext(Dispatchers.IO) {
aKmlLayer = KmlLayer(gMap, R.raw.kml_file, context)
withContext(Dispatchers.Main) {
aKmlLayer?.addLayerToMap()
}
}
}
}
}
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia con il composable GoogleMap e l’entry point sperimentale MapEffect descritti nell’issue, quindi esamina come viene costruito KmlLayer con un GoogleMap e Context. Il lavoro è completo quando esiste un modo supportato per aggiungere KML e layer simili senza MapEffect, gestendo il caricamento lento dei layer al di fuori del thread principale.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
android, kotlin
Ambito
mobile
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.