Replace mapboxMap with maplibreMap (#2314)
This commit is contained in:
@@ -33,7 +33,7 @@ class JsonApiActivity : AppCompatActivity() {
|
||||
// Declare a variable for MapView
|
||||
private lateinit var mapView: MapView
|
||||
|
||||
// Declare a variable for MapboxMap
|
||||
// Declare a variable for MapLibreMap
|
||||
private lateinit var maplibreMap: MapLibreMap
|
||||
/* ANCHOR_END: top */
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.maplibre.android.testapp.R
|
||||
* Test activity showcasing using the MapFragment API using SDK Fragments.
|
||||
*
|
||||
*
|
||||
* Uses MapboxMapOptions to initialise the Fragment.
|
||||
* Uses MapLibreMapOptions to initialise the Fragment.
|
||||
*
|
||||
*/
|
||||
class MapFragmentActivity :
|
||||
|
||||
@@ -113,7 +113,7 @@ class NestedViewPagerActivity : AppCompatActivity() {
|
||||
0 -> {
|
||||
options.camera(CameraPosition.Builder().target(LatLng(34.920526, 102.634774)).zoom(3.0).build())
|
||||
val fragment = SupportMapFragment.newInstance(options)
|
||||
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.getPredefinedStyle("Streets")) }
|
||||
fragment.getMapAsync { maplibreMap -> maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) }
|
||||
return fragment
|
||||
}
|
||||
1 -> {
|
||||
@@ -122,7 +122,7 @@ class NestedViewPagerActivity : AppCompatActivity() {
|
||||
2 -> {
|
||||
options.camera(CameraPosition.Builder().target(LatLng(62.326440, 92.764913)).zoom(3.0).build())
|
||||
val fragment = SupportMapFragment.newInstance(options)
|
||||
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.getPredefinedStyle("Pastel")) }
|
||||
fragment.getMapAsync { maplibreMap -> maplibreMap.setStyle(Style.getPredefinedStyle("Pastel")) }
|
||||
return fragment
|
||||
}
|
||||
3 -> {
|
||||
@@ -131,7 +131,7 @@ class NestedViewPagerActivity : AppCompatActivity() {
|
||||
4 -> {
|
||||
options.camera(CameraPosition.Builder().target(LatLng(-25.007786, 133.623852)).zoom(3.0).build())
|
||||
val fragment = SupportMapFragment.newInstance(options)
|
||||
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid")) }
|
||||
fragment.getMapAsync { maplibreMap -> maplibreMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid")) }
|
||||
return fragment
|
||||
}
|
||||
5 -> {
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.maplibre.android.testapp.R
|
||||
* Test activity showcasing using the MapFragment API using Support Library Fragments.
|
||||
*
|
||||
*
|
||||
* Uses MapboxMapOptions to initialise the Fragment.
|
||||
* Uses MapLibreMapOptions to initialise the Fragment.
|
||||
*
|
||||
*/
|
||||
class SupportMapFragmentActivity :
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.maplibre.android.testapp.utils.IconUtils
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Test activity showcasing how to dynamically update InfoWindow when Using an MapboxMap.InfoWindowAdapter.
|
||||
* Test activity showcasing how to dynamically update InfoWindow when Using an MapLibreMap.InfoWindowAdapter.
|
||||
*/
|
||||
class DynamicInfoWindowAdapterActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
private lateinit var maplibreMap: MapLibreMap
|
||||
|
||||
@@ -56,8 +56,8 @@ open class DebugModeActivity : AppCompatActivity(), OnMapReadyCallback, OnFpsCha
|
||||
}
|
||||
|
||||
private fun setupMapView(savedInstanceState: Bundle?) {
|
||||
val mapboxMapOptions = setupMapboxMapOptions()
|
||||
mapView = MapView(this, mapboxMapOptions)
|
||||
val maplibreMapOptions = setupMapLibreMapOptions()
|
||||
mapView = MapView(this, maplibreMapOptions)
|
||||
(findViewById<View>(R.id.coordinator_layout) as ViewGroup).addView(mapView, 0)
|
||||
mapView.addOnDidFinishLoadingStyleListener {
|
||||
if (maplibreMap != null) {
|
||||
@@ -70,7 +70,7 @@ open class DebugModeActivity : AppCompatActivity(), OnMapReadyCallback, OnFpsCha
|
||||
mapView.addOnDidFinishLoadingStyleListener { Timber.d("Style loaded") }
|
||||
}
|
||||
|
||||
protected open fun setupMapboxMapOptions(): MapLibreMapOptions {
|
||||
protected open fun setupMapLibreMapOptions(): MapLibreMapOptions {
|
||||
return MapLibreMapOptions.createFromAttributes(this, null)
|
||||
}
|
||||
|
||||
|
||||
@@ -143,9 +143,9 @@ open class GLSurfaceRecyclerViewActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
fun bind(mapItem: MapItem) {
|
||||
mapView.getMapAsync { mapboxMap ->
|
||||
mapboxMap.setStyle(mapItem.style) {
|
||||
mapboxMap.snapshot { }
|
||||
mapView.getMapAsync { maplibreMap ->
|
||||
maplibreMap.setStyle(mapItem.style) {
|
||||
maplibreMap.snapshot { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,10 +66,10 @@ class DraggableMarkerActivity : AppCompatActivity() {
|
||||
|
||||
mapView = binding.mapView
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { mapboxMap ->
|
||||
this.maplibreMap = mapboxMap
|
||||
mapView.getMapAsync { maplibreMap ->
|
||||
this.maplibreMap = maplibreMap
|
||||
|
||||
mapboxMap.setStyle(
|
||||
maplibreMap.setStyle(
|
||||
Style.Builder()
|
||||
.fromUri(Style.getPredefinedStyle("Streets"))
|
||||
.withImage(markerImageId, IconFactory.getInstance(this).defaultMarker().bitmap)
|
||||
@@ -83,16 +83,16 @@ class DraggableMarkerActivity : AppCompatActivity() {
|
||||
addMarker(LatLng(51.514886, -0.112589))
|
||||
|
||||
// Initial camera position
|
||||
mapboxMap.moveCamera(
|
||||
maplibreMap.moveCamera(
|
||||
CameraUpdateFactory.newLatLngZoom(
|
||||
LatLng(45.0, 8.0),
|
||||
3.0
|
||||
)
|
||||
)
|
||||
|
||||
mapboxMap.addOnMapClickListener {
|
||||
maplibreMap.addOnMapClickListener {
|
||||
// Adding a marker on map click
|
||||
val features = mapboxMap.queryRenderedSymbols(it, layerId)
|
||||
val features = maplibreMap.queryRenderedSymbols(it, layerId)
|
||||
if (features.isEmpty()) {
|
||||
addMarker(it)
|
||||
} else {
|
||||
@@ -110,7 +110,7 @@ class DraggableMarkerActivity : AppCompatActivity() {
|
||||
|
||||
draggableSymbolsManager = DraggableSymbolsManager(
|
||||
mapView,
|
||||
mapboxMap,
|
||||
maplibreMap,
|
||||
featureCollection,
|
||||
source,
|
||||
layerId,
|
||||
@@ -175,7 +175,7 @@ class DraggableMarkerActivity : AppCompatActivity() {
|
||||
* we still need to listen for move gesture events which map won't be able to provide anymore.
|
||||
*
|
||||
* @param mapView the mapView
|
||||
* @param maplibreMap the mapboxMap
|
||||
* @param maplibreMap the maplibreMap
|
||||
* @param symbolsCollection the collection that contains all the symbols that we want to be draggable
|
||||
* @param symbolsSource the source that contains the [symbolsCollection]
|
||||
* @param symbolsLayerId the ID of the layer that the symbols are displayed on
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.io.FileWriter
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
/**
|
||||
* Test activity showcasing how to use a file:// resource for the style.json and how to use MapboxMap#setStyleJson.
|
||||
* Test activity showcasing how to use a file:// resource for the style.json and how to use MapLibreMap#setStyleJson.
|
||||
*/
|
||||
class StyleFileActivity : AppCompatActivity() {
|
||||
private lateinit var maplibreMap: MapLibreMap
|
||||
@@ -83,8 +83,8 @@ class StyleFileActivity : AppCompatActivity() {
|
||||
override fun onPostExecute(json: String) {
|
||||
super.onPostExecute(json)
|
||||
Timber.d("Read json, %s", json)
|
||||
val mapboxMap = maplibreMap.get()
|
||||
mapboxMap?.setStyle(Style.Builder().fromJson(json))
|
||||
val maplibreMap = maplibreMap.get()
|
||||
maplibreMap?.setStyle(Style.Builder().fromJson(json))
|
||||
}
|
||||
|
||||
init {
|
||||
@@ -127,8 +127,8 @@ class StyleFileActivity : AppCompatActivity() {
|
||||
|
||||
override fun onPostExecute(result: Long) {
|
||||
// Actual file:// usage
|
||||
val mapboxMap = maplibreMap.get()
|
||||
mapboxMap?.setStyle(
|
||||
val maplibreMap = maplibreMap.get()
|
||||
maplibreMap?.setStyle(
|
||||
Style.Builder().fromUri("file://" + cacheStyleFile!!.absolutePath)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ class SymbolGeneratorActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
* Utility class to generate Bitmaps for Symbol.
|
||||
*
|
||||
*
|
||||
* Bitmaps can be added to the map with [com.mapbox.mapboxsdk.maps.MapboxMap.addImage]
|
||||
* Bitmaps can be added to the map with [org.maplibre.android.maps.Style.addImage]
|
||||
*
|
||||
*/
|
||||
private object SymbolGenerator {
|
||||
|
||||
@@ -9,10 +9,10 @@ import org.maplibre.android.testapp.utils.NavUtils
|
||||
* Test activity showcasing the different debug modes and allows to cycle between the default map styles.
|
||||
*/
|
||||
class TextureViewDebugModeActivity : DebugModeActivity(), OnMapReadyCallback {
|
||||
override fun setupMapboxMapOptions(): MapLibreMapOptions {
|
||||
val mapboxMapOptions = super.setupMapboxMapOptions()
|
||||
mapboxMapOptions.textureMode(true)
|
||||
return mapboxMapOptions
|
||||
override fun setupMapLibreMapOptions(): MapLibreMapOptions {
|
||||
val maplibreMapOptions = super.setupMapLibreMapOptions()
|
||||
maplibreMapOptions.textureMode(true)
|
||||
return maplibreMapOptions
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
||||
@@ -39,9 +39,9 @@ class PhysicalUnitCircleActivity : AppCompatActivity(), SeekBar.OnSeekBarChangeL
|
||||
binding = ActivityPhysicalCircleBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
binding.mapView.onCreate(savedInstanceState)
|
||||
binding.mapView.getMapAsync { mapboxMap ->
|
||||
binding.mapView.getMapAsync { maplibreMap ->
|
||||
|
||||
mapboxMap.cameraPosition = CameraPosition.Builder()
|
||||
maplibreMap.cameraPosition = CameraPosition.Builder()
|
||||
.target(LatLng(LATITUDE, LONGITUDE))
|
||||
.zoom(ZOOM)
|
||||
.build()
|
||||
@@ -59,7 +59,7 @@ class PhysicalUnitCircleActivity : AppCompatActivity(), SeekBar.OnSeekBarChangeL
|
||||
binding.stepsBar.setOnSeekBarChangeListener(this)
|
||||
binding.radiusBar.setOnSeekBarChangeListener(this)
|
||||
|
||||
mapboxMap.setStyle(
|
||||
maplibreMap.setStyle(
|
||||
Style.Builder()
|
||||
.fromUri(Style.getPredefinedStyle("Satellite Hybrid"))
|
||||
.withLayer(
|
||||
|
||||
Reference in New Issue
Block a user