TextureView
This example demonstrates how to display a map using a TextureView
as the render surface. The code snippet includes a class TextureViewActivity
extending AppCompatActivity
, where an instance of MapboxMap
is created. The onCreate
method initializes the MapboxMap
instance, inflates the layout from ActivityTextureViewBinding
, sets the content view, and loads the Mapbox Standard map style using mapboxMap.loadStyle(Style.STANDARD)
.
This example code is part of the Maps SDK for Android Examples App, a working Android project available on GitHub. Android developers are encouraged to run the examples app locally to interact with this example in an emulator and explore other features of the Maps SDK.
See our Run the Maps SDK for Android Examples App tutorial for step-by-step instructions.
package com.mapbox.maps.testapp.examples
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.mapbox.maps.MapboxMap
import com.mapbox.maps.Style
import com.mapbox.maps.testapp.databinding.ActivityTextureViewBinding
/**
* Example of displaying a map using TextureView as render surface.
*/
class TextureViewActivity : AppCompatActivity() {
private lateinit var mapboxMap: MapboxMap
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val binding = ActivityTextureViewBinding.inflate(layoutInflater)
setContentView(binding.root)
mapboxMap = binding.mapView.mapboxMap
mapboxMap.loadStyle(Style.STANDARD)
}
}