Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line manager won't show lines #1155

Open
kikothemaster opened this issue Aug 28, 2020 · 2 comments
Open

Line manager won't show lines #1155

kikothemaster opened this issue Aug 28, 2020 · 2 comments

Comments

@kikothemaster
Copy link

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)
            )
        )
    }
}
@kikothemaster
Copy link
Author

Any info about that?

@wprenison
Copy link

wprenison commented Jul 20, 2021

Lines are only shown for me using the lineManager if I use the withLinePattern functionality, as soon as I try using color they don't show up on Android 10.

Haven't tried your alternate approach yet.

This is on 0.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants