Multiple markers on Mapbox v10

46 Views Asked by At

In the latest version of mapbox the multiple marker is not showing. The given is the code I used. Is there any problem with my code or any suggestions? I used this tutorial.

    val listOfFeatures = arrayListOf<Feature>()
    courtsListingResponse?.data?.list?.forEach {
        if (it.location?.longitude != null && it.location.latitude != null) {
            val pointFeature = Feature.fromGeometry(
                Point.fromLngLat(
                    it.location.longitude,
                    it.location.latitude
                )
            )
            listOfFeatures.add(pointFeature)
        }
    }
    val featureCollection = FeatureCollection.fromFeatures(listOfFeatures)
    binding.mapView.getMapboxMap()
        .loadStyle(styleExtension = style(Style.MAPBOX_STREETS) {
            image("default-icon") {
                bitmapFromDrawableRes(this@CourtFinderActivity,
                    R.drawable.ic_baseline_location_on_24)?.let { it1 ->
                    bitmap(
                        it1
                    )
                }
            }
            geoJsonSource("source") {
                featureCollection(featureCollection)
            }
            symbolLayer("layer", "source") {
                iconImage(
                    literal("default-icon")
                )
                iconAllowOverlap(true)
                iconAnchor(IconAnchor.BOTTOM)
            }
        })
0

There are 0 best solutions below