Thêm Marker Symbol
Ví dụ này thêm một marker với biểu tượng ảnh

package com.mapbox.maps.testapp.examples.markersandcallouts import android.graphics.BitmapFactoryimport android.os.Bundleimport androidx.appcompat.app.AppCompatActivityimport com.mapbox.geojson.Pointimport com.mapbox.maps.CameraOptionsimport com.mapbox.maps.MapViewimport com.mapbox.maps.Styleimport com.mapbox.maps.extension.style.image.imageimport com.mapbox.maps.extension.style.layers.generated.symbolLayerimport com.mapbox.maps.extension.style.layers.properties.generated.IconAnchorimport com.mapbox.maps.extension.style.sources.generated.geoJsonSourceimport com.mapbox.maps.extension.style.styleimport com.mapbox.maps.testapp.R /*** Add a blue teardrop-shaped marker image to a style and display it on the* map using a SymbolLayer.*/class AddOneMarkerSymbolActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)val mapView = MapView(this)setContentView(mapView) mapView.getMapboxMap().also {it.setCamera(CameraOptions.Builder().center(Point.fromLngLat(LONGITUDE, LATITUDE)).zoom(5).build())}.loadStyle(styleExtension = style("https://api.ekgis.vn/v2/mapstyles/style/osmplus/bright/style.json?api_key={YOUR_API_KEY}") {// prepare blue marker from resources+image(BLUE_ICON_ID) {bitmap(BitmapFactory.decodeResource(resources, R.drawable.blue_marker_view))}+geoJsonSource(SOURCE_ID) {geometry(Point.fromLngLat(LONGITUDE, LATITUDE))}+symbolLayer(LAYER_ID, SOURCE_ID) {iconImage(BLUE_ICON_ID)iconAnchor(IconAnchor.BOTTOM)}})} companion object {private const val BLUE_ICON_ID = "blue"private const val SOURCE_ID = "source_id"private const val LAYER_ID = "layer_id"private const val LATITUDE = 16.34private const val LONGITUDE = 109.11}}