mapbox / mapbox/mapbox-plugins-android
Line manager won't show lines
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Java
- Sterne
- 242
- Forks
- 116
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
On Android 6.0 - Android 7.0 (I've tested on those versions) the lines are not displayed.
On Android 10.0 lines are normally showed with exact same implementation as on Android 6.0 - Android 7.0 (not sure for 8.0 - 10.0 versions).
lineManager = LineManager(map, this, style).apply {
lineCap = Property.LINE_CAP_ROUND
}
points.map { line ->
val lineOptions = LineOptions()
.withLineColor(linesColor)
.withLineWidth(3f)
.withGeometry(
LineString.fromLngLats(line.map { Point.fromLngLat(it.longitude, it.latitude) })
)
lines.add(lineManager.create(lineOptions))
}
Then I've just noticed that the line appeared for a brief second and then disappeared.
Then I tried with a different approach:
I tried adding GeoJsonSource and LineLayer. Lines are shown, but when I update GeoJsonSource with different data, lines are hidden again 👎 When I load the exact same data as previously into GeoJsonSource, lines are shown again.
This is also happening on Android 6.0 - Android 7.0
fun addOrEditRouteLines(style: Style?, color: String, data: List<List<LatLng>>) {
with(style ?: return) {
(sources.find { it.id == DEFAULT_LAYER_LINES } as? GeoJsonSource)?.apply {
(getLayer(DEFAULT_LAYER_LINES) as LineLayer).apply {
withProperties(PropertyFactory.lineColor(color))
}
clearLines(style)
setGeoJson(
fromFeatures(
data.map { line ->
Feature.fromGeometry(
LineString.fromLngLats(line.map { Point.fromLngLat(it.longitude, it.latitude) })
)
}
)
)
return
}
val routeLines = GeoJsonSource(
DEFAULT_LAYER_LINES,
fromFeatures(
data.map { line ->
Feature.fromGeometry(
LineString.fromLngLats(line.map { Point.fromLngLat(it.longitude, it.latitude) })
)
}
)
)
addSource(routeLines)
addLayer(
LineLayer(DEFAULT_LAYER_LINES, DEFAULT_LAYER_LINES).withProperties(
PropertyFactory.lineWidth(3f),
PropertyFactory.lineColor(color),
PropertyFactory.lineCap(Property.LINE_CAP_ROUND)
)
)
}
}
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, den Bericht über addOrEditRouteLines zu reproduzieren, zuerst mit LineManager und anschließend mit GeoJsonSource und LineLayer, auf Android 6.0–7.0. Beobachte das kurze Erscheinen und Verschwinden nach der Aktualisierung der Quelle; erledigt ist es, wenn die Routenlinien nach Aktualisierungen sichtbar bleiben, auch wenn sich die Daten ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- android, kotlin
- Bereich
- mobile-dev
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 32/100