Stuck on Plotting path from some sample random GeoJson in mapbox java android

Viewed 121

i am a beginner in java and trying to plot a path from sample coordinates. For this, i am following the official documentation. Here is the link to it: https://docs.mapbox.com/android/maps/examples/draw-geo-json-line/. i did not find relevant resources for newer mapbox 10.1.0. No lifecycle need to be defined, getInstance, getAsync method are not there in the new one. so, i decomplied kotlin to java to try if i could make it work. This code snippet from the reference link i provided:

mapView.getMapboxMap().loadStyle(
(
style(styleUri = Style.MAPBOX_STREETS) {
+geoJsonSource(GEOJSON_SOURCE_ID) {
url("asset://from_crema_to_council_crest.geojson")
}
+lineLayer("linelayer", GEOJSON_SOURCE_ID) {
lineCap(LineCap.ROUND)
lineJoin(LineJoin.ROUND)
lineOpacity(0.7)
lineWidth(8.0)
lineColor("#888")
}
}
)
)

gets converted to m

apView.getMapboxMap().loadStyle(StyleExtensionImplKt.style("mapbox://styles/mapbox/streets-v11", (Function1)null.INSTANCE));

the style method inside StyleExtensionImplKt.kt is shown below:

/**
 * DSL function to construct a style extension.
 */
fun style(styleUri: String, block: Builder.() -> Unit) =
  Builder(styleUri).apply(block).build()

Now, it says the second parameter is a DSL function and now i am stuck on how should i implement this. I only wanted to plot a simple GeoJSON path on the map using some sample coordinate array. I have plotted the map but am stuck on this now. Can someone help me? Could someone provide some reference?

Here is my code snippet to show the map, on MainActivity.java:

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        MapView mapView = findViewById(R.id.mapView);


        if(mapView != null){
        mapView.getMapboxMap().loadStyleUri(Style.MAPBOX_STREETS);
    }
0 Answers
Related