Remove MapTiler dependency Instrumentation Tests (#2438)

This commit is contained in:
Bart Louwers
2024-06-11 19:01:30 +02:00
committed by GitHub
parent de4dd0bb03
commit 7437d800f6
102 changed files with 305 additions and 181 deletions

View File

@@ -56,7 +56,7 @@ class StyleTest {
@Test
fun testFromUrl() {
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
val builder = Style.Builder().fromUri(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(builder)
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
}
@@ -144,7 +144,7 @@ class StyleTest {
val source = mockk<GeoJsonSource>()
every { source.id } returns "1"
val builder =
Style.Builder().fromUrl(Style.getPredefinedStyle("Streets")).withSource(source)
Style.Builder().fromUri(Style.getPredefinedStyle("Streets")).withSource(source)
maplibreMap.setStyle(builder)
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
maplibreMap.notifyStyleLoaded()
@@ -155,7 +155,7 @@ class StyleTest {
fun testWithFromLoadingLayer() {
val layer = mockk<SymbolLayer>()
every { layer.id } returns "1"
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets")).withLayer(layer)
val builder = Style.Builder().fromUri(Style.getPredefinedStyle("Streets")).withLayer(layer)
maplibreMap.setStyle(builder)
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
maplibreMap.notifyStyleLoaded()
@@ -172,7 +172,7 @@ class StyleTest {
val layer = mockk<SymbolLayer>()
every { layer.id } returns "1"
val builder =
Style.Builder().fromUrl(Style.getPredefinedStyle("Streets")).withLayerAt(layer, 1)
Style.Builder().fromUri(Style.getPredefinedStyle("Streets")).withLayerAt(layer, 1)
maplibreMap.setStyle(builder)
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
maplibreMap.notifyStyleLoaded()
@@ -183,7 +183,7 @@ class StyleTest {
fun testWithFromLoadingLayerBelow() {
val layer = mockk<SymbolLayer>()
every { layer.id } returns "1"
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
val builder = Style.Builder().fromUri(Style.getPredefinedStyle("Streets"))
.withLayerBelow(layer, "below")
maplibreMap.setStyle(builder)
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
@@ -195,7 +195,7 @@ class StyleTest {
fun testWithFromLoadingLayerAbove() {
val layer = mockk<SymbolLayer>()
every { layer.id } returns "1"
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
val builder = Style.Builder().fromUri(Style.getPredefinedStyle("Streets"))
.withLayerBelow(layer, "below")
maplibreMap.setStyle(builder)
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
@@ -206,7 +206,7 @@ class StyleTest {
@Test
fun testWithFromLoadingTransitionOptions() {
val transitionOptions = TransitionOptions(100, 200)
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
val builder = Style.Builder().fromUri(Style.getPredefinedStyle("Streets"))
.withTransition(transitionOptions)
maplibreMap.setStyle(builder)
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
@@ -218,7 +218,7 @@ class StyleTest {
fun testFromCallback() {
val callback = mockk<Style.OnStyleLoaded>()
every { callback.onStyleLoaded(any()) } answers {}
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
val builder = Style.Builder().fromUri(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(builder, callback)
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
maplibreMap.notifyStyleLoaded()
@@ -274,7 +274,7 @@ class StyleTest {
val source = mockk<GeoJsonSource>()
every { source.id } returns "1"
val builder =
Style.Builder().fromUrl(Style.getPredefinedStyle("Streets")).withSource(source)
Style.Builder().fromUri(Style.getPredefinedStyle("Streets")).withSource(source)
maplibreMap.setStyle(builder)
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Streets") }
maplibreMap.notifyStyleLoaded()
@@ -290,7 +290,7 @@ class StyleTest {
@Test
fun testGetNullWhileLoading() {
val transitionOptions = TransitionOptions(100, 200)
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
val builder = Style.Builder().fromUri(Style.getPredefinedStyle("Streets"))
.withTransition(transitionOptions)
maplibreMap.setStyle(builder)
Assert.assertNull(maplibreMap.style)
@@ -315,11 +315,11 @@ class StyleTest {
@Test(expected = IllegalStateException::class)
fun testIllegalStateExceptionWithStyleReload() {
val builder = Style.Builder().fromUrl(Style.getPredefinedStyle("Streets"))
val builder = Style.Builder().fromUri(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(builder)
maplibreMap.notifyStyleLoaded()
val style = maplibreMap.style
maplibreMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
maplibreMap.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Bright")))
style!!.addLayer(mockk<SymbolLayer>())
}
@@ -327,7 +327,7 @@ class StyleTest {
fun testAddImage() {
val bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)
val builder =
Style.Builder().fromUrl(Style.getPredefinedStyle("Satellite Hybrid")).withImage("id", bitmap)
Style.Builder().fromUri(Style.getPredefinedStyle("Satellite Hybrid")).withImage("id", bitmap)
maplibreMap.setStyle(builder)
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Satellite Hybrid") }
verify(exactly = 0) { nativeMapView.addImages(any()) }
@@ -341,7 +341,7 @@ class StyleTest {
drawable.intrinsicHeight = 10
drawable.intrinsicWidth = 10
val builder =
Style.Builder().fromUrl(Style.getPredefinedStyle("Satellite Hybrid")).withImage("id", drawable)
Style.Builder().fromUri(Style.getPredefinedStyle("Satellite Hybrid")).withImage("id", drawable)
maplibreMap.setStyle(builder)
verify(exactly = 1) { nativeMapView.styleUri = Style.getPredefinedStyle("Satellite Hybrid") }
verify(exactly = 0) { nativeMapView.addImages(any()) }

View File

@@ -4,6 +4,7 @@ import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import androidx.test.uiautomator.UiSelector
import org.junit.Ignore
import org.maplibre.android.testapp.activity.fragment.FragmentBackStackActivity
import org.junit.Rule
import org.junit.Test
@@ -19,6 +20,7 @@ class FragmentBackStackTest : BaseIntegrationTest() {
var activityRule: ActivityTestRule<FragmentBackStackActivity> = ActivityTestRule(FragmentBackStackActivity::class.java)
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2469")
@LargeTest
fun backPressedOnBackStackResumed() {
device.waitForIdle()

View File

@@ -3,6 +3,7 @@ package org.maplibre.android.integration
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import org.junit.Ignore
import org.maplibre.android.testapp.activity.textureview.TextureViewDebugModeActivity
import org.junit.Rule
import org.junit.Test

View File

@@ -3,6 +3,7 @@ package org.maplibre.android.integration
import androidx.test.filters.LargeTest
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.rule.ActivityTestRule
import org.junit.Ignore
import org.maplibre.android.testapp.activity.maplayout.TextureRecyclerViewActivity
import org.junit.Rule
import org.junit.Test

View File

@@ -35,6 +35,7 @@ import org.junit.Assert.assertArrayEquals
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.runner.RunWith
import org.maplibre.android.testapp.styles.TestStyles
@RunWith(AndroidJUnit4ClassRunner::class)
class LocationComponentTest : EspressoTest() {
@@ -191,7 +192,7 @@ class LocationComponentTest : EspressoTest() {
uiController: UiController,
context: Context
) {
maplibreMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
maplibreMap.setStyle(Style.Builder().fromUrl(TestStyles.getPredefinedStyleWithFallback("Bright")))
component.activateLocationComponent(
LocationComponentActivationOptions
@@ -676,7 +677,7 @@ class LocationComponentTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
component.isLocationComponentEnabled = false
maplibreMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
maplibreMap.setStyle(Style.Builder().fromUrl(TestStyles.getPredefinedStyleWithFallback("Bright")))
component.isLocationComponentEnabled = true
TestingAsyncUtils.waitForLayer(uiController, mapView)
@@ -797,7 +798,7 @@ class LocationComponentTest : EspressoTest() {
component.onStop()
component.onStart()
maplibreMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
maplibreMap.setStyle(Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Bright")))
TestingAsyncUtils.waitForLayer(uiController, mapView)
}
}
@@ -822,7 +823,7 @@ class LocationComponentTest : EspressoTest() {
.build()
)
component.isLocationComponentEnabled = true
maplibreMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
maplibreMap.setStyle(Style.Builder().fromUrl(TestStyles.getPredefinedStyleWithFallback("Bright")))
component.onStop()
component.onStart()
TestingAsyncUtils.waitForLayer(uiController, mapView)
@@ -909,7 +910,7 @@ class LocationComponentTest : EspressoTest() {
)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
maplibreMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
maplibreMap.setStyle(Style.Builder().fromUrl(TestStyles.getPredefinedStyleWithFallback("Bright")))
component.onStop()
TestingAsyncUtils.waitForLayer(uiController, mapView)
component.onStart()

View File

@@ -38,6 +38,7 @@ import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.maplibre.android.testapp.styles.TestStyles
import kotlin.math.abs
@RunWith(AndroidJUnit4ClassRunner::class)
@@ -154,7 +155,7 @@ class LocationLayerControllerTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
styleChangeIdlingResource.waitForStyle(maplibreMap, Style.getPredefinedStyle("Bright"))
styleChangeIdlingResource.waitForStyle(maplibreMap, TestStyles.getPredefinedStyleWithFallback("Bright"))
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL)))
@@ -456,7 +457,7 @@ class LocationLayerControllerTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
styleChangeIdlingResource.waitForStyle(maplibreMap, Style.getPredefinedStyle("Bright"))
styleChangeIdlingResource.waitForStyle(maplibreMap, TestStyles.getPredefinedStyleWithFallback("Bright"))
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL)))
@@ -503,7 +504,7 @@ class LocationLayerControllerTest : EspressoTest() {
`is`(true)
)
maplibreMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
maplibreMap.setStyle(Style.Builder().fromUrl(TestStyles.getPredefinedStyleWithFallback("Bright")))
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(

View File

@@ -21,6 +21,7 @@ import org.junit.Assert.*
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.maplibre.android.testapp.styles.TestStyles
@RunWith(AndroidJUnit4ClassRunner::class)
class NativeMapViewTest : AppCenter() {
@@ -61,7 +62,7 @@ class NativeMapViewTest : AppCenter() {
@Test
@UiThreadTest
fun testSetStyleUrl() {
val expected = Style.getPredefinedStyle("Pastel")
val expected = TestStyles.getPredefinedStyleWithFallback("Pastel")
nativeMapView.styleUri = expected
val actual = nativeMapView.styleUri
assertEquals("Style URL should match", expected, actual)

View File

@@ -10,8 +10,10 @@ import org.maplibre.android.testapp.activity.BaseTest
import org.maplibre.android.testapp.activity.espresso.PixelTestActivity
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Ignore
import org.junit.Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2468")
class VisibleRegionTest : BaseTest() {
override fun getActivityClass(): Class<*> {

View File

@@ -5,11 +5,11 @@ import androidx.test.rule.ActivityTestRule
import org.junit.Ignore
import org.maplibre.geojson.Point
import org.maplibre.android.log.Logger
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.activity.FeatureOverviewActivity
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.maplibre.android.testapp.styles.TestStyles
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
@@ -71,7 +71,7 @@ class OfflineDownloadTest : OfflineRegion.OfflineRegionObserver {
private fun createTestRegionDefinition(): OfflineRegionDefinition {
return OfflineGeometryRegionDefinition(
Style.getPredefinedStyle("Streets"),
TestStyles.getPredefinedStyleWithFallback("Streets"),
Point.fromLngLat(50.847857, 4.360137),
17.0,
17.0,

View File

@@ -14,6 +14,7 @@ import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.maplibre.android.testapp.styles.TestStyles
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
@@ -40,7 +41,7 @@ class MapSnapshotterTest {
val options = MapSnapshotter.Options(512, 512)
.withPixelRatio(1.0f)
.withStyleBuilder(
Style.Builder().fromUri(Style.getPredefinedStyle("Satellite Hybrid"))
Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"))
.withLayerAbove(bg, "country-label")
)
.withCameraPosition(

View File

@@ -4,6 +4,7 @@ import androidx.annotation.UiThread
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.activity.espresso.EspressoTestActivity
import org.maplibre.android.testapp.styles.TestStyles
/**
* Base class for all tests using EspressoTestActivity as wrapper.
@@ -19,7 +20,7 @@ open class EspressoTest : BaseTest() {
@UiThread
override fun initMap(maplibreMap: MapLibreMap) {
maplibreMap.setStyle(Style.Builder().fromUri("asset://streets.json"))
maplibreMap.setStyle(Style.Builder().fromUri(TestStyles.VERSATILES))
super.initMap(maplibreMap)
}
}

View File

@@ -138,7 +138,7 @@ public class GeoJsonConversionTest extends EspressoTest {
SymbolLayer layer = new SymbolLayer("layer", "source")
.withProperties(
PropertyFactory.iconOffset(Expression.get("property")),
PropertyFactory.iconImage("zoo-15")
PropertyFactory.iconImage("icon-zoo")
);
maplibreMap.getStyle().addLayer(layer);

View File

@@ -71,8 +71,8 @@ class ImageMissingTest : AppCenter() {
{
"version": 8,
"name": "Streets",
"sprite": "maptiler://sprites/streets/sprite",
"glyphs": "maptiler://fonts/{fontstack}/{range}.pbf",
"sprite": "https://maputnik.github.io/osm-liberty/sprites/osm-liberty",
"glyphs": "https://orangemug.github.io/font-glyphs/glyphs/{fontstack}/{range}.pbf",
"sources": {
"point": {
"type": "geojson",
@@ -115,8 +115,8 @@ class ImageMissingTest : AppCenter() {
{
"version": 8,
"name": "Streets",
"sprite": "maptiler://sprites/streets/sprite",
"glyphs": "maptiler://fonts/{fontstack}/{range}.pbf",
"sprite": "https://maputnik.github.io/osm-liberty/sprites/osm-liberty",
"glyphs": "https://orangemug.github.io/font-glyphs/glyphs/{fontstack}/{range}.pbf",
"sources": {
"point": {
"type": "geojson",

View File

@@ -1,5 +1,6 @@
package org.maplibre.android.testapp.style;
import org.junit.Ignore;
import org.maplibre.geojson.Feature;
import org.maplibre.geojson.Point;
import org.maplibre.android.geometry.LatLng;
@@ -286,6 +287,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testConstFormatExpression() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -309,6 +311,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testConstFormatExpressionFontScaleParam() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -332,6 +335,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testConstFormatExpressionTextFontParam() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -362,6 +366,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testConstFormatExpressionTextColorParam() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -391,6 +396,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testConstFormatExpressionAllParams() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -425,6 +431,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testConstFormatExpressionMultipleInputs() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -462,6 +469,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testVariableFormatExpression() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -493,6 +501,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testVariableFormatExpressionMultipleInputs() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -525,6 +534,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testFormatExpressionPlainTextCoercion() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -546,6 +556,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testTextFieldFormattedArgument() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -572,6 +583,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testNumberFormatCurrencyExpression() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -597,6 +609,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testNumberFormatMaxExpression() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -622,6 +635,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testNumberFormatMinExpression() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -647,6 +661,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testNumberFormatLocaleExpression() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {
@@ -673,6 +688,7 @@ public class ExpressionTest extends EspressoTest {
}
@Test
@Ignore("https://github.com/maplibre/maplibre-native/issues/2437")
public void testNumberFormatNonConstantExpression() {
validateTestSetup();
invoke(maplibreMap, (uiController, maplibreMap) -> {

View File

@@ -66,7 +66,7 @@ open class MapLibreApplication : MultiDexApplication() {
}
companion object {
val TILE_SERVER = WellKnownTileServer.MapTiler
val TILE_SERVER = WellKnownTileServer.MapLibre
private const val DEFAULT_API_KEY = "YOUR_API_KEY_GOES_HERE"
private const val API_KEY_NOT_SET_MESSAGE =
(

View File

@@ -16,8 +16,8 @@ import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.GeoParseUtil
import timber.log.Timber
import java.io.IOException
@@ -43,7 +43,7 @@ class BulkMarkerActivity : AppCompatActivity(), OnItemSelectedListener {
private fun initMap(maplibreMap: MapLibreMap) {
this.maplibreMap = maplibreMap
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {

View File

@@ -12,8 +12,8 @@ import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.IconUtils
/**
@@ -31,7 +31,7 @@ class DynamicMarkerChangeActivity : AppCompatActivity() {
mapView.onCreate(savedInstanceState)
mapView.getMapAsync(
OnMapReadyCallback { maplibreMap: MapLibreMap ->
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
this@DynamicMarkerChangeActivity.maplibreMap = maplibreMap
// Create marker
val markerOptions = MarkerOptions()

View File

@@ -12,6 +12,7 @@ import org.maplibre.android.camera.CameraPosition
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.* // ktlint-disable no-wildcard-imports
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import java.util.ArrayList
/**
@@ -55,7 +56,7 @@ class PolygonActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(map: MapLibreMap) {
maplibreMap = map
map.setStyle(Style.getPredefinedStyle("Streets"))
map.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
map.setOnPolygonClickListener { polygon: Polygon ->
Toast.makeText(
this@PolygonActivity,

View File

@@ -13,8 +13,8 @@ import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import java.util.*
/**
@@ -46,7 +46,7 @@ class PolylineActivity : AppCompatActivity() {
mapView.getMapAsync(
OnMapReadyCallback { maplibreMap: MapLibreMap ->
this@PolylineActivity.maplibreMap = maplibreMap
maplibreMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"))
maplibreMap.setOnPolylineClickListener { polyline: Polyline ->
Toast.makeText(
this@PolylineActivity,

View File

@@ -9,8 +9,8 @@ import org.maplibre.android.annotations.MarkerOptions
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import java.text.DecimalFormat
import java.util.ArrayList
@@ -43,7 +43,7 @@ class PressForMarkerActivity : AppCompatActivity() {
addMarker(point)
false
}
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
if (savedInstanceState != null) {
markerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST)
if (markerList != null) {

View File

@@ -14,6 +14,7 @@ import org.maplibre.android.maps.MapLibreMap.OnCameraIdleListener
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
/**
@@ -64,7 +65,7 @@ class CameraAnimationTypeActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(map: MapLibreMap) {
maplibreMap = map
maplibreMap.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Streets")))
maplibreMap.setStyle(Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Streets")))
maplibreMap.uiSettings.isAttributionEnabled = false
maplibreMap.uiSettings.isLogoEnabled = false
maplibreMap.addOnCameraIdleListener(cameraIdleListener)

View File

@@ -21,6 +21,7 @@ import org.maplibre.android.camera.CameraUpdateFactory
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.*
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/** Test activity showcasing using Android SDK animators to animate camera position changes. */
class CameraAnimatorActivity : AppCompatActivity(), OnMapReadyCallback {
@@ -40,7 +41,7 @@ class CameraAnimatorActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(map: MapLibreMap) {
maplibreMap = map
map.setStyle(Style.getPredefinedStyle("Streets"))
map.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
initFab()
}

View File

@@ -25,6 +25,7 @@ import org.maplibre.android.maps.MapLibreMap.*
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
/** Test activity showcasing how to listen to camera change events. */
@@ -47,7 +48,7 @@ class CameraPositionActivity : FragmentActivity(), OnMapReadyCallback, View.OnCl
override fun onMapReady(map: MapLibreMap) {
maplibreMap = map
map.setStyle(Style.getPredefinedStyle("Satellite Hybrid")) { style: Style? ->
map.setStyle(TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid")) { style: Style? ->
// add a listener to FAB
fab = findViewById(R.id.fab)
fab.setColorFilter(ContextCompat.getColor(this@CameraPositionActivity, R.color.primary))

View File

@@ -22,8 +22,8 @@ import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.MapLibreMap.*
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.FontCache
import org.maplibre.android.testapp.utils.ResourceUtils
import java.lang.annotation.Retention
@@ -46,7 +46,7 @@ class GestureDetectorActivity : AppCompatActivity() {
mapView.getMapAsync(
OnMapReadyCallback { maplibreMap: MapLibreMap ->
this@GestureDetectorActivity.maplibreMap = maplibreMap
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
initializeMap()
}
)

View File

@@ -18,6 +18,7 @@ import org.maplibre.android.style.layers.SymbolLayer
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.databinding.ActivityLatlngboundsBinding
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.GeoParseUtil
import org.maplibre.android.utils.BitmapUtils
import java.net.URISyntaxException
@@ -70,7 +71,7 @@ class LatLngBoundsActivity : AppCompatActivity() {
private fun loadStyle(featureCollection: FeatureCollection) {
maplibreMap.setStyle(
Style.Builder()
.fromUri(Style.getPredefinedStyle("Streets"))
.fromUri(TestStyles.getPredefinedStyleWithFallback("Streets"))
.withLayer(
SymbolLayer("symbol", "symbol")
.withProperties(

View File

@@ -11,6 +11,7 @@ import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity showcasing the zoom Camera API.
@@ -28,7 +29,7 @@ class ManualZoomActivity : AppCompatActivity() {
mapView.getMapAsync { maplibreMap: MapLibreMap ->
this@ManualZoomActivity.maplibreMap = maplibreMap
maplibreMap.setStyle(
Style.Builder().fromUri(Style.getPredefinedStyle("Satellite Hybrid"))
Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"))
)
val uiSettings = this@ManualZoomActivity.maplibreMap.uiSettings
uiSettings.setAllGesturesEnabled(false)

View File

@@ -9,6 +9,7 @@ import org.maplibre.android.maps.MapLibreMap.OnMapClickListener
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
/** Test activity showcasing using maximum and minimum zoom levels to restrict camera movement. */
@@ -17,7 +18,7 @@ class MaxMinZoomActivity : AppCompatActivity(), OnMapReadyCallback {
private lateinit var maplibreMap: MapLibreMap
private val clickListener = OnMapClickListener {
if (maplibreMap != null) {
maplibreMap.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Outdoor")))
maplibreMap.setStyle(Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Outdoor")))
}
true
}
@@ -35,7 +36,7 @@ class MaxMinZoomActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(map: MapLibreMap) {
maplibreMap = map
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
maplibreMap.setMinZoomPreference(3.0)
maplibreMap.setMaxZoomPreference(5.0)
maplibreMap.addOnMapClickListener(clickListener)

View File

@@ -14,8 +14,8 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity showcasing using the scrollBy Camera API by moving x,y pixels above Grenada, Spain.
@@ -53,7 +53,7 @@ class ScrollByActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(map: MapLibreMap) {
maplibreMap = map
maplibreMap.setStyle(Style.getPredefinedStyle("Pastel"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Pastel"))
val uiSettings = maplibreMap.uiSettings
uiSettings.isLogoEnabled = false
uiSettings.isAttributionEnabled = false

View File

@@ -16,6 +16,7 @@ import org.maplibre.android.maps.Style
import org.maplibre.android.style.layers.CustomLayer
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.model.customlayer.ExampleCustomLayer
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity showcasing the Custom Layer API
@@ -43,7 +44,7 @@ class CustomLayerActivity : AppCompatActivity() {
10.0
)
)
maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? -> initFab() }
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style? -> initFab() }
}
)
}

View File

@@ -12,6 +12,7 @@ import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.NavUtils
import timber.log.Timber
@@ -33,7 +34,7 @@ class QueryRenderedFeaturesBoxCountActivity : AppCompatActivity() {
mapView.onCreate(savedInstanceState)
mapView.getMapAsync { maplibreMap: MapLibreMap ->
this@QueryRenderedFeaturesBoxCountActivity.maplibreMap = maplibreMap
maplibreMap.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Streets")))
maplibreMap.setStyle(Style.Builder().fromUri(TestStyles.AMERICANA))
selectionBox.setOnClickListener { view: View? ->
// Query
val top = selectionBox.top - mapView.top

View File

@@ -16,6 +16,7 @@ import org.maplibre.android.style.layers.Layer
import org.maplibre.android.style.layers.PropertyFactory
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
/**
@@ -70,7 +71,7 @@ class QueryRenderedFeaturesBoxHighlightActivity : AppCompatActivity() {
}
maplibreMap.setStyle(
Style.Builder()
.fromUri(Style.getPredefinedStyle("Streets"))
.fromUri(TestStyles.getPredefinedStyleWithFallback("Streets"))
.withSource(source)
.withLayer(layer)
)

View File

@@ -17,6 +17,7 @@ import org.maplibre.android.maps.MapLibreMap.InfoWindowAdapter
import org.maplibre.android.maps.MapLibreMap.OnMapClickListener
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
/**
@@ -61,7 +62,7 @@ class QueryRenderedFeaturesPropertiesActivity : AppCompatActivity() {
mapView = findViewById<View>(R.id.mapView) as MapView
mapView.onCreate(savedInstanceState)
mapView.getMapAsync { maplibreMap: MapLibreMap ->
maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? ->
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style? ->
this@QueryRenderedFeaturesPropertiesActivity.maplibreMap = maplibreMap
// Add custom window adapter

View File

@@ -18,6 +18,7 @@ import org.maplibre.android.style.expressions.Expression
import org.maplibre.android.style.layers.CircleLayer
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity showcasing using the query source features API to query feature counts
@@ -37,7 +38,7 @@ class QuerySourceFeaturesActivity : AppCompatActivity() {
maplibreMap = map
}
maplibreMap.getStyle { style: Style -> initStyle(style) }
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
}
}

View File

@@ -3,10 +3,10 @@ package org.maplibre.android.testapp.activity.fragment
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.maplibre.android.maps.SupportMapFragment
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.databinding.ActivityBackstackFragmentBinding
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.NavUtils
/**
@@ -45,8 +45,13 @@ class FragmentBackStackActivity : AppCompatActivity() {
}
private fun initMap(maplibreMap: MapLibreMap) {
maplibreMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid")) {
maplibreMap.setPadding(300, 300, 300, 300)
try {
val style = TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid")
maplibreMap.setStyle(style) {
maplibreMap.setPadding(300, 300, 300, 300)
}
} catch (e: IllegalArgumentException) {
// ignore style unavailable
}
}

View File

@@ -9,6 +9,7 @@ import org.maplibre.android.maps.* // ktlint-disable no-wildcard-imports
import org.maplibre.android.maps.MapFragment.OnMapViewReadyCallback
import org.maplibre.android.maps.MapView.OnDidFinishRenderingFrameListener
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity showcasing using the MapFragment API using SDK Fragments.
@@ -67,7 +68,7 @@ class MapFragmentActivity :
override fun onMapReady(map: MapLibreMap) {
maplibreMap = map
maplibreMap.setStyle(Style.getPredefinedStyle("Outdoor"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Outdoor"))
}
override fun onDestroy() {

View File

@@ -5,9 +5,9 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.FragmentManager
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.maps.SupportMapFragment
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test Activity showcasing using multiple static map fragments in one layout.
@@ -17,10 +17,10 @@ class MultiMapActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_multi_map)
val fragmentManager = supportFragmentManager
initFragmentStyle(fragmentManager, R.id.map1, Style.getPredefinedStyle("Streets"))
initFragmentStyle(fragmentManager, R.id.map2, Style.getPredefinedStyle("Bright"))
initFragmentStyle(fragmentManager, R.id.map3, Style.getPredefinedStyle("Satellite Hybrid"))
initFragmentStyle(fragmentManager, R.id.map4, Style.getPredefinedStyle("Pastel"))
initFragmentStyle(fragmentManager, R.id.map1, TestStyles.getPredefinedStyleWithFallback("Streets"))
initFragmentStyle(fragmentManager, R.id.map2, TestStyles.getPredefinedStyleWithFallback("Bright"))
initFragmentStyle(fragmentManager, R.id.map3, TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"))
initFragmentStyle(fragmentManager, R.id.map4, TestStyles.getPredefinedStyleWithFallback("Pastel"))
}
private fun initFragmentStyle(

View File

@@ -11,10 +11,10 @@ import androidx.appcompat.app.AppCompatActivity
import org.maplibre.android.camera.CameraPosition
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.MapLibreMapOptions
import org.maplibre.android.maps.Style
import org.maplibre.android.maps.SupportMapFragment
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.databinding.ActivityRecyclerviewBinding
import org.maplibre.android.testapp.styles.TestStyles
/**
* TestActivity showcasing how to integrate a MapView in a RecyclerView.
@@ -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 { maplibreMap -> maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) }
fragment.getMapAsync { maplibreMap -> maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("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 { maplibreMap -> maplibreMap.setStyle(Style.getPredefinedStyle("Pastel")) }
fragment.getMapAsync { maplibreMap -> maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("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 { maplibreMap -> maplibreMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid")) }
fragment.getMapAsync { maplibreMap -> maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid")) }
return fragment
}
5 -> {

View File

@@ -9,6 +9,7 @@ import org.maplibre.android.maps.* // ktlint-disable no-wildcard-imports
import org.maplibre.android.maps.MapFragment.OnMapViewReadyCallback
import org.maplibre.android.maps.MapView.OnDidFinishRenderingFrameListener
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity showcasing using the MapFragment API using Support Library Fragments.
@@ -67,7 +68,7 @@ class SupportMapFragmentActivity :
override fun onMapReady(map: MapLibreMap) {
maplibreMap = map
maplibreMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"))
}
override fun onDestroy() {

View File

@@ -6,9 +6,9 @@ import androidx.appcompat.app.AppCompatActivity
import org.maplibre.android.camera.CameraPosition
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.MapLibreMapOptions
import org.maplibre.android.maps.Style
import org.maplibre.android.maps.SupportMapFragment
import org.maplibre.android.testapp.databinding.ActivityViewpagerBinding
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity showcasing using the Android SDK ViewPager API to show MapFragments.
@@ -91,11 +91,11 @@ fun SupportMapFragment.getMapAsync(index: Int) {
this.getMapAsync {
it.setStyle(
when (index) {
0 -> Style.getPredefinedStyle("Streets")
1 -> Style.getPredefinedStyle("Pastel")
2 -> Style.getPredefinedStyle("Satellite Hybrid")
3 -> Style.getPredefinedStyle("Bright")
else -> Style.getPredefinedStyle("Streets")
0 -> TestStyles.getPredefinedStyleWithFallback("Streets")
1 -> TestStyles.getPredefinedStyleWithFallback("Pastel")
2 -> TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid")
3 -> TestStyles.getPredefinedStyleWithFallback("Bright")
else -> TestStyles.getPredefinedStyleWithFallback("Streets")
}
)
}

View File

@@ -8,8 +8,8 @@ import androidx.print.PrintHelper
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity showcasing using the Snaphot API to print a Map.
@@ -33,7 +33,7 @@ class PrintActivity : AppCompatActivity(), MapLibreMap.SnapshotReadyCallback {
private fun initMap(maplibreMap: MapLibreMap) {
this.maplibreMap = maplibreMap
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
}
override fun onSnapshotReady(snapshot: Bitmap) {

View File

@@ -8,6 +8,7 @@ import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.databinding.ActivitySnapshotBinding
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
/**
@@ -42,7 +43,7 @@ class SnapshotActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(map: MapLibreMap) {
maplibreMap = map
maplibreMap.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Outdoor"))) { binding.mapView.addOnDidFinishRenderingFrameListener(idleListener) }
maplibreMap.setStyle(Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Outdoor"))) { binding.mapView.addOnDidFinishRenderingFrameListener(idleListener) }
}
override fun onStart() {

View File

@@ -14,8 +14,8 @@ import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.MapLibreMap.InfoWindowAdapter
import org.maplibre.android.maps.MapLibreMap.OnMapClickListener
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.IconUtils
import java.util.*
@@ -58,7 +58,7 @@ class DynamicInfoWindowAdapterActivity : AppCompatActivity(), OnMapReadyCallback
override fun onMapReady(map: MapLibreMap) {
maplibreMap = map
map.setStyle(Style.getPredefinedStyle("Streets"))
map.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
// Add info window adapter
addCustomInfoWindowAdapter(maplibreMap!!)

View File

@@ -18,6 +18,7 @@ import org.maplibre.android.maps.MapLibreMap.OnMapLongClickListener
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import java.text.DecimalFormat
/**
@@ -66,7 +67,7 @@ class InfoWindowActivity :
override fun onMapReady(maplibreMap: MapLibreMap) {
this.maplibreMap = maplibreMap
maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? ->
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style? ->
addMarkers()
addInfoWindowListeners()
}

View File

@@ -15,6 +15,7 @@ import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.model.annotations.CityStateMarker
import org.maplibre.android.testapp.model.annotations.CityStateMarkerOptions
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.IconUtils
/**
@@ -31,7 +32,7 @@ class InfoWindowAdapterActivity : AppCompatActivity() {
mapView.getMapAsync(
OnMapReadyCallback { map: MapLibreMap ->
maplibreMap = map
map.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? ->
map.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style? ->
addMarkers()
addCustomInfoWindowAdapter()
}

View File

@@ -19,6 +19,7 @@ import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/* ANCHOR: top */
/**
@@ -47,7 +48,7 @@ class BasicLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyCallba
@SuppressLint("MissingPermission")
override fun onMapReady(maplibreMap: MapLibreMap) {
this.maplibreMap = maplibreMap
maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style ->
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style ->
locationComponent = maplibreMap.locationComponent
val locationComponentOptions =
LocationComponentOptions.builder(this@BasicLocationPulsingCircleActivity)

View File

@@ -27,6 +27,7 @@ import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* This activity shows how to customize the LocationComponent's pulsing circle.
@@ -87,7 +88,7 @@ class CustomizedLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyC
@SuppressLint("MissingPermission")
override fun onMapReady(maplibreMap: MapLibreMap) {
this.maplibreMap = maplibreMap
maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style ->
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style ->
locationComponent = maplibreMap.locationComponent
val locationComponentOptions = buildLocationComponentOptions(
LOCATION_CIRCLE_PULSE_COLOR,

View File

@@ -16,6 +16,7 @@ import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
class LocationComponentActivationActivity : AppCompatActivity(), OnMapReadyCallback {
private lateinit var mapView: MapView
@@ -62,7 +63,7 @@ class LocationComponentActivationActivity : AppCompatActivity(), OnMapReadyCallb
override fun onMapReady(maplibreMap: MapLibreMap) {
this.maplibreMap = maplibreMap
maplibreMap.setStyle(
Style.getPredefinedStyle("Bright")
TestStyles.getPredefinedStyleWithFallback("Bright")
) { style: Style -> activateLocationComponent(style) }
}

View File

@@ -17,9 +17,9 @@ import org.maplibre.android.location.permissions.PermissionsListener
import org.maplibre.android.location.permissions.PermissionsManager
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.databinding.ActivityLocationLayerFragmentBinding
import org.maplibre.android.testapp.styles.TestStyles
class LocationFragmentActivity : AppCompatActivity() {
@@ -107,7 +107,7 @@ class LocationFragmentActivity : AppCompatActivity() {
mapView.onCreate(savedInstanceState)
mapView.getMapAsync {
maplibreMap = it
it.setStyle(Style.getPredefinedStyle("Streets")) { style ->
it.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style ->
val component = maplibreMap.locationComponent
component.activateLocationComponent(

View File

@@ -31,6 +31,7 @@ import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import java.util.Random
class LocationModesActivity :
@@ -118,7 +119,7 @@ class LocationModesActivity :
@SuppressLint("MissingPermission")
override fun onMapReady(maplibreMap: MapLibreMap) {
this.maplibreMap = maplibreMap
maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? ->
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style? ->
locationComponent = maplibreMap.locationComponent
locationComponent!!.activateLocationComponent(
LocationComponentActivationOptions
@@ -249,8 +250,8 @@ class LocationModesActivity :
}
maplibreMap.getStyle { style: Style ->
val styleUrl =
Style.getPredefinedStyle(
if (Style.getPredefinedStyle("Bright") == style.uri) {
TestStyles.getPredefinedStyleWithFallback(
if (TestStyles.getPredefinedStyleWithFallback("Bright") == style.uri) {
"Bright"
} else {
"Pastel"

View File

@@ -20,6 +20,7 @@ import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
class ManualLocationUpdatesActivity : AppCompatActivity(), OnMapReadyCallback {
private lateinit var mapView: MapView
@@ -103,7 +104,7 @@ class ManualLocationUpdatesActivity : AppCompatActivity(), OnMapReadyCallback {
@SuppressLint("MissingPermission")
override fun onMapReady(maplibreMap: MapLibreMap) {
maplibreMap.setStyle(
Style.Builder().fromUri(Style.getPredefinedStyle("Streets"))
Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Streets"))
) { style: Style? ->
locationComponent = maplibreMap.locationComponent
locationComponent!!.activateLocationComponent(

View File

@@ -2,7 +2,7 @@ package org.maplibre.android.testapp.activity.location
import android.location.Location
import org.maplibre.android.geometry.LatLngBounds
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
import java.util.*
@@ -11,11 +11,11 @@ import java.util.*
*/
object Utils {
private val STYLES = arrayOf(
Style.getPredefinedStyle("Streets"),
Style.getPredefinedStyle("Outdoor"),
Style.getPredefinedStyle("Bright"),
Style.getPredefinedStyle("Pastel"),
Style.getPredefinedStyle("Satellite Hybrid")
TestStyles.getPredefinedStyleWithFallback("Streets"),
TestStyles.getPredefinedStyleWithFallback("Outdoor"),
TestStyles.getPredefinedStyleWithFallback("Bright"),
TestStyles.getPredefinedStyleWithFallback("Pastel"),
TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid")
)
private var index = 0

View File

@@ -11,6 +11,7 @@ import org.maplibre.android.camera.CameraUpdateFactory
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.*
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.utils.MapFragmentUtils
/**
@@ -169,12 +170,12 @@ class BottomSheetActivity : AppCompatActivity() {
companion object {
private val STYLES = arrayOf(
Style.getPredefinedStyle("Streets"),
Style.getPredefinedStyle("Satellite Hybrid"),
Style.getPredefinedStyle("Bright"),
Style.getPredefinedStyle("Pastel"),
Style.getPredefinedStyle("Satellite Hybrid"),
Style.getPredefinedStyle("Outdoor")
TestStyles.getPredefinedStyleWithFallback("Streets"),
TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"),
TestStyles.getPredefinedStyleWithFallback("Bright"),
TestStyles.getPredefinedStyleWithFallback("Pastel"),
TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"),
TestStyles.getPredefinedStyleWithFallback("Outdoor")
)
fun newInstance(context: Context?, mapCounter: Int): MainMapFragment {
@@ -216,7 +217,7 @@ class BottomSheetActivity : AppCompatActivity() {
15.0
)
)
maplibreMap.setStyle(Style.getPredefinedStyle("Bright"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Bright"))
}
override fun onStart() {

View File

@@ -15,6 +15,7 @@ import org.maplibre.android.style.layers.Layer
import org.maplibre.android.style.layers.Property
import org.maplibre.android.style.layers.PropertyFactory
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
import java.util.*
@@ -258,12 +259,12 @@ open class DebugModeActivity : AppCompatActivity(), OnMapReadyCallback, OnFpsCha
companion object {
private val STYLES = arrayOf(
Style.getPredefinedStyle("Streets"),
Style.getPredefinedStyle("Outdoor"),
Style.getPredefinedStyle("Bright"),
Style.getPredefinedStyle("Pastel"),
Style.getPredefinedStyle("Satellite Hybrid"),
Style.getPredefinedStyle("Satellite Hybrid")
TestStyles.getPredefinedStyleWithFallback("Streets"),
TestStyles.getPredefinedStyleWithFallback("Outdoor"),
TestStyles.getPredefinedStyleWithFallback("Bright"),
TestStyles.getPredefinedStyleWithFallback("Pastel"),
TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"),
TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid")
)
}
}

View File

@@ -13,6 +13,7 @@ import org.maplibre.android.camera.CameraUpdateFactory
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.*
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.utils.MapFragmentUtils
/**
@@ -64,7 +65,7 @@ class DoubleMapActivity : AppCompatActivity() {
mapView.onCreate(savedInstanceState)
mapView.getMapAsync { maplibreMap: MapLibreMap ->
maplibreMap.setStyle(
Style.getPredefinedStyle(
TestStyles.getPredefinedStyleWithFallback(
"Streets"
)
)
@@ -83,7 +84,7 @@ class DoubleMapActivity : AppCompatActivity() {
.build()
)
)
maplibreMap.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Bright")))
maplibreMap.setStyle(Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Bright")))
val uiSettings = maplibreMap.uiSettings
uiSettings.setAllGesturesEnabled(false)
uiSettings.isCompassEnabled = false

View File

@@ -50,7 +50,7 @@ open class GLSurfaceRecyclerViewActivity : AppCompatActivity() {
class ItemAdapter(private val activity: GLSurfaceRecyclerViewActivity, private val inflater: LayoutInflater) : androidx.recyclerview.widget.RecyclerView.Adapter<androidx.recyclerview.widget.RecyclerView.ViewHolder>() {
private val items = listOf(
"one", "two", "three", MapItem(Style.getPredefinedStyle("Streets")), "four", "five", MapItem(Style.getPredefinedStyle("Pastel")), "seven", "eight", "nine", "ten",
"one", "two", "three", "four", "five", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
"nineteen", "twenty", "twenty-one"
)

View File

@@ -10,6 +10,7 @@ import org.maplibre.android.geometry.LatLng
import org.maplibre.android.geometry.LatLngBounds
import org.maplibre.android.maps.*
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity showcasing restricting user gestures to a bounds around Iceland, almost worldview and IDL.
@@ -27,7 +28,7 @@ class LatLngBoundsForCameraActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(maplibreMap: MapLibreMap) {
this.maplibreMap = maplibreMap
maplibreMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"))
maplibreMap.setMinZoomPreference(2.0)
maplibreMap.uiSettings.isFlingVelocityAnimationEnabled = false
showCrosshair()

View File

@@ -7,6 +7,7 @@ import org.maplibre.android.camera.CameraUpdateFactory
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.*
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity that displays the city of Suzhou with a mixture of server-generated
@@ -21,7 +22,7 @@ class LocalGlyphActivity : AppCompatActivity() {
mapView.onCreate(savedInstanceState)
mapView.getMapAsync(
OnMapReadyCallback { maplibreMap: MapLibreMap ->
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
// Set initial position to Suzhou
maplibreMap.moveCamera(
CameraUpdateFactory.newCameraPosition(

View File

@@ -19,6 +19,7 @@ import org.maplibre.android.maps.MapView.OnWillStartLoadingMapListener
import org.maplibre.android.maps.MapView.OnWillStartRenderingFrameListener
import org.maplibre.android.maps.MapView.OnWillStartRenderingMapListener
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
/**
@@ -88,7 +89,7 @@ class MapChangeActivity : AppCompatActivity() {
mapView.onCreate(savedInstanceState)
mapView.getMapAsync(
OnMapReadyCallback { maplibreMap: MapLibreMap ->
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
maplibreMap.animateCamera(
CameraUpdateFactory.newLatLngZoom(
LatLng(55.754020, 37.620948),

View File

@@ -9,6 +9,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.DialogFragment
import org.maplibre.android.maps.*
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity showcasing showing a Map inside of a DialogFragment.
@@ -42,7 +43,7 @@ class MapInDialogActivity : AppCompatActivity() {
mapView.getMapAsync(
OnMapReadyCallback { maplibreMap: MapLibreMap ->
maplibreMap.setStyle(
Style.getPredefinedStyle("Outdoor")
TestStyles.getPredefinedStyleWithFallback("Outdoor")
)
}
)

View File

@@ -10,6 +10,7 @@ import org.maplibre.android.camera.CameraUpdateFactory
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.*
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity showcasing using the map padding API.
@@ -26,7 +27,7 @@ class MapPaddingActivity : AppCompatActivity() {
mapView.getMapAsync(
OnMapReadyCallback { maplibreMap: MapLibreMap ->
this@MapPaddingActivity.maplibreMap = maplibreMap
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
val paddingLeft = resources.getDimension(R.dimen.map_padding_left).toInt()
val paddingBottom = resources.getDimension(R.dimen.map_padding_bottom).toInt()
val paddingRight = resources.getDimension(R.dimen.map_padding_right).toInt()

View File

@@ -7,8 +7,8 @@ import android.os.Bundle
import android.os.PersistableBundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.databinding.ActivityOverlayBinding
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test overlaying a Map with a View that uses a radial gradient shader.
@@ -24,7 +24,7 @@ class OverlayMapActivity : AppCompatActivity() {
binding.mapView.onCreate(savedInstanceState)
binding.parentView.addView(OverlayView(this))
binding.mapView.getMapAsync {
it.setStyle(Style.getPredefinedStyle("Streets"))
it.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
}
}

View File

@@ -9,6 +9,7 @@ import org.maplibre.android.camera.CameraUpdateFactory
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.*
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity showcasing visibility changes to the mapview.
@@ -28,7 +29,7 @@ class VisibilityChangeActivity : AppCompatActivity() {
if (map != null) {
maplibreMap = map
}
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
maplibreMap.animateCamera(
CameraUpdateFactory.newLatLngZoom(
LatLng(55.754020, 37.620948),

View File

@@ -13,10 +13,10 @@ import androidx.appcompat.app.AppCompatActivity
import org.maplibre.android.constants.MapLibreConstants
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.geometry.LatLngBounds
import org.maplibre.android.maps.Style
import org.maplibre.android.offline.*
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.databinding.ActivityRegionDownloadBinding
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
import java.util.*
import java.util.concurrent.TimeUnit
@@ -253,10 +253,10 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
private fun initSpinner() {
val styles = ArrayList<String>()
styles.add(Style.getPredefinedStyle("Streets"))
styles.add(Style.getPredefinedStyle("Pastel"))
styles.add(Style.getPredefinedStyle("Bright"))
styles.add(Style.getPredefinedStyle("Outdoor"))
styles.add(TestStyles.getPredefinedStyleWithFallback("Streets"))
styles.add(TestStyles.getPredefinedStyleWithFallback("Pastel"))
styles.add(TestStyles.getPredefinedStyleWithFallback("Bright"))
styles.add(TestStyles.getPredefinedStyleWithFallback("Outdoor"))
val spinnerArrayAdapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, styles)
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
binding.spinnerStyleUrl.adapter = spinnerArrayAdapter

View File

@@ -10,6 +10,7 @@ import org.maplibre.android.offline.OfflineManager
import org.maplibre.android.offline.OfflineRegion
import org.maplibre.android.storage.FileSource
import org.maplibre.android.testapp.databinding.ActivityMergeOfflineRegionsBinding
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.FileUtils
class MergeOfflineRegionsActivity : AppCompatActivity() {
@@ -19,7 +20,7 @@ class MergeOfflineRegionsActivity : AppCompatActivity() {
companion object {
private const val LOG_TAG = "Mbgl-MergeOfflineRegionsActivity"
private const val TEST_DB_FILE_NAME = "offline_test.db"
private var TEST_STYLE = Style.getPredefinedStyle("Satellite Hybrid")
private var TEST_STYLE = TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid")
}
private val onFileCopiedListener = object : FileUtils.OnFileCopiedFromAssetsListener {

View File

@@ -24,6 +24,7 @@ import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.model.other.OfflineDownloadRegionDialog
import org.maplibre.android.testapp.model.other.OfflineDownloadRegionDialog.DownloadRegionDialogListener
import org.maplibre.android.testapp.model.other.OfflineListRegionsDialog
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.OfflineUtils
import timber.log.Timber
import java.util.ArrayList
@@ -46,7 +47,7 @@ class OfflineActivity : AppCompatActivity(), DownloadRegionDialogListener {
private var listRegions: Button? = null
private var isEndNotified = false
val STYLE_URL: String
get() = Style.getPredefinedStyle("Streets")
get() = TestStyles.getPredefinedStyleWithFallback("Streets")
/*
* Offline objects

View File

@@ -44,9 +44,7 @@ class RenderTestActivity : AppCompatActivity() {
override fun onStop() {
super.onStop()
if (mapSnapshotter != null) {
mapSnapshotter!!.cancel()
}
mapSnapshotter.cancel()
}
//

View File

@@ -28,6 +28,7 @@ import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.style.sources.RasterSource
import org.maplibre.android.style.sources.Source
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.utils.BitmapUtils
import timber.log.Timber
import java.util.Objects
@@ -68,7 +69,7 @@ class MapSnapshotterActivity : AppCompatActivity() {
// Optionally the style
val builder = Style.Builder()
.fromUri(
Style.getPredefinedStyle(
TestStyles.getPredefinedStyleWithFallback(
if ((column + row) % 2 == 0) {
"Streets"
} else {

View File

@@ -18,6 +18,7 @@ import org.maplibre.android.maps.Style
import org.maplibre.android.snapshotter.MapSnapshot
import org.maplibre.android.snapshotter.MapSnapshotter
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
/**
@@ -49,7 +50,7 @@ class MapSnapshotterBitMapOverlayActivity :
Math.min(container.measuredHeight, 1024)
)
.withStyleBuilder(
Style.Builder().fromUri(Style.getPredefinedStyle("Outdoor"))
Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Outdoor"))
)
.withCameraPosition(
CameraPosition.Builder().target(LatLng(52.090737, 5.121420))

View File

@@ -17,6 +17,7 @@ import org.maplibre.android.style.layers.PropertyFactory
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.style.sources.Source
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
import java.net.URI
import java.net.URISyntaxException
@@ -35,7 +36,7 @@ class MapSnapshotterHeatMapActivity : AppCompatActivity(), MapSnapshotter.Snapsh
override fun onGlobalLayout() {
container.viewTreeObserver.removeOnGlobalLayoutListener(this)
Timber.i("Starting snapshot")
val builder = Style.Builder().fromUri(Style.getPredefinedStyle("Outdoor"))
val builder = Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Outdoor"))
.withSource(earthquakeSource!!)
.withLayerAbove(heatmapLayer, "water_intermittent")
mapSnapshotter = MapSnapshotter(

View File

@@ -11,6 +11,7 @@ import org.maplibre.android.maps.Style
import org.maplibre.android.snapshotter.MapSnapshot
import org.maplibre.android.snapshotter.MapSnapshotter
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import java.util.*
/**
@@ -89,12 +90,12 @@ class MapSnapshotterReuseActivity : AppCompatActivity(), MapSnapshotter.Snapshot
.build()
val randomStyle: String
get() = when (random.nextInt(5)) {
0 -> Style.getPredefinedStyle("Pastel")
1 -> Style.getPredefinedStyle("Bright")
2 -> Style.getPredefinedStyle("Streets")
3 -> Style.getPredefinedStyle("Outdoor")
4 -> Style.getPredefinedStyle("Satellite Hybrid")
else -> Style.getPredefinedStyle("Streets")
0 -> TestStyles.getPredefinedStyleWithFallback("Pastel")
1 -> TestStyles.getPredefinedStyleWithFallback("Bright")
2 -> TestStyles.getPredefinedStyleWithFallback("Streets")
3 -> TestStyles.getPredefinedStyleWithFallback("Outdoor")
4 -> TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid")
else -> TestStyles.getPredefinedStyleWithFallback("Streets")
}
companion object {

View File

@@ -5,11 +5,11 @@ import android.view.View
import androidx.appcompat.app.AppCompatActivity
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.maplibre.android.storage.FileSource
import org.maplibre.android.storage.FileSource.ResourceTransformCallback
import org.maplibre.android.storage.Resource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
/**
@@ -44,7 +44,7 @@ class UrlTransformActivity : AppCompatActivity() {
FileSource.getInstance(this@UrlTransformActivity).setResourceTransform(Transform())
mapView.getMapAsync { map: MapLibreMap ->
Timber.i("Map loaded")
map.setStyle(Style.getPredefinedStyle("Streets"))
map.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
}
}

View File

@@ -16,6 +16,7 @@ import org.maplibre.android.maps.Style
import org.maplibre.android.style.layers.RasterLayer
import org.maplibre.android.style.sources.ImageSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.utils.BitmapUtils
/**
@@ -49,7 +50,7 @@ class AnimatedImageSourceActivity : AppCompatActivity(), OnMapReadyCallback {
val layer = RasterLayer(ID_IMAGE_LAYER, ID_IMAGE_SOURCE)
map.setStyle(
Style.Builder()
.fromUri(Style.getPredefinedStyle("Streets"))
.fromUri(TestStyles.getPredefinedStyleWithFallback("Streets"))
.withSource(imageSource)
.withLayer(layer)
) { style: Style? ->

View File

@@ -25,6 +25,7 @@ import org.maplibre.android.style.layers.PropertyFactory
import org.maplibre.android.style.layers.SymbolLayer
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.turf.TurfMeasurement
import java.util.*
@@ -50,7 +51,7 @@ class AnimatedSymbolLayerActivity : AppCompatActivity() {
mapView.getMapAsync(
OnMapReadyCallback { map: MapLibreMap ->
maplibreMap = map
map.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? ->
map.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style? ->
this.style = style
setupCars()
animateRandomRoutes()

View File

@@ -17,6 +17,7 @@ import org.maplibre.android.style.layers.PropertyFactory
import org.maplibre.android.style.light.Light
import org.maplibre.android.style.light.Position
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.utils.ColorUtils
/**
@@ -40,7 +41,7 @@ class BuildingFillExtrusionActivity : AppCompatActivity() {
if (map != null) {
maplibreMap = map
}
maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style ->
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style ->
setupBuildings(style)
setupLight()
}

View File

@@ -19,6 +19,7 @@ import org.maplibre.android.style.layers.SymbolLayer
import org.maplibre.android.style.sources.GeoJsonOptions
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
import java.net.URI
import java.net.URISyntaxException
@@ -49,7 +50,7 @@ class CircleLayerActivity : AppCompatActivity(), View.OnClickListener {
if (map != null) {
maplibreMap = map
}
maplibreMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"))
mapView.addOnDidFinishLoadingStyleListener(
OnDidFinishLoadingStyleListener {
val style = maplibreMap.style
@@ -276,12 +277,12 @@ class CircleLayerActivity : AppCompatActivity(), View.OnClickListener {
private object Data {
val STYLES = arrayOf(
Style.getPredefinedStyle("Streets"),
Style.getPredefinedStyle("Outdoor"),
Style.getPredefinedStyle("Bright"),
Style.getPredefinedStyle("Pastel"),
Style.getPredefinedStyle("Satellite Hybrid"),
Style.getPredefinedStyle("Satellite Hybrid")
TestStyles.getPredefinedStyleWithFallback("Streets"),
TestStyles.getPredefinedStyleWithFallback("Outdoor"),
TestStyles.getPredefinedStyleWithFallback("Bright"),
TestStyles.getPredefinedStyleWithFallback("Pastel"),
TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"),
TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid")
)
}

View File

@@ -19,6 +19,7 @@ import org.maplibre.android.style.layers.PropertyFactory
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.databinding.ActivityCollectionUpdateOnStyleChangeBinding
import org.maplibre.android.testapp.styles.TestStyles
import java.util.*
/**
@@ -114,7 +115,13 @@ class CollectionUpdateOnStyleChange : AppCompatActivity(), OnMapReadyCallback, S
companion object {
private val STYLES = arrayOf(Style.getPredefinedStyle("Streets"), Style.getPredefinedStyle("Outdoor"), Style.getPredefinedStyle("Bright"), Style.getPredefinedStyle("Pastel"), Style.getPredefinedStyle("Satellite Hybrid"), Style.getPredefinedStyle("Satellite Hybrid"))
private val STYLES = arrayOf(
TestStyles.getPredefinedStyleWithFallback("Streets"),
TestStyles.getPredefinedStyleWithFallback("Outdoor"),
TestStyles.getPredefinedStyleWithFallback("Bright"),
TestStyles.getPredefinedStyleWithFallback("Pastel"),
TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"),
TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"))
private val featureCollection: FeatureCollection

View File

@@ -20,6 +20,7 @@ import org.maplibre.android.style.layers.PropertyFactory
import org.maplibre.android.style.layers.SymbolLayer
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
/**
@@ -38,7 +39,7 @@ class CustomSpriteActivity : AppCompatActivity() {
mapView.getMapAsync(
OnMapReadyCallback { map: MapLibreMap ->
maplibreMap = map
map.setStyle(Style.getPredefinedStyle("Streets")) { style: Style ->
map.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style ->
val fab = findViewById<FloatingActionButton>(R.id.fab)
fab.setColorFilter(
ContextCompat.getColor(

View File

@@ -20,6 +20,7 @@ import org.maplibre.android.style.layers.PropertyFactory
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.style.sources.Source
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.IdleZoomListener
import org.maplibre.android.testapp.utils.ResourceUtils
import timber.log.Timber
@@ -45,7 +46,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
if (map != null) {
maplibreMap = map
}
maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? ->
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style? ->
// Add a parks layer
addParksLayer()

View File

@@ -17,6 +17,7 @@ import org.maplibre.android.style.layers.PropertyFactory.*
import org.maplibre.android.style.layers.SymbolLayer
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.databinding.ActivityWithinExpressionBinding
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.turf.TurfConstants
import org.maplibre.turf.TurfTransformation
@@ -56,7 +57,7 @@ class DistanceExpressionActivity : AppCompatActivity() {
// using Streets as a base style
maplibreMap.setStyle(
Style.Builder()
.fromUri(Style.getPredefinedStyle("Streets"))
.fromUri(TestStyles.getPredefinedStyleWithFallback("Streets"))
.withSources(
GeoJsonSource(
POINT_ID,

View File

@@ -22,6 +22,7 @@ import org.maplibre.android.style.layers.PropertyFactory.*
import org.maplibre.android.style.layers.SymbolLayer
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.databinding.ActivityDraggableMarkerBinding
import org.maplibre.android.testapp.styles.TestStyles
/**
* An Activity that showcases how to make symbols draggable.
@@ -71,7 +72,7 @@ class DraggableMarkerActivity : AppCompatActivity() {
maplibreMap.setStyle(
Style.Builder()
.fromUri(Style.getPredefinedStyle("Streets"))
.fromUri(TestStyles.getPredefinedStyleWithFallback("Streets"))
.withImage(markerImageId, IconFactory.getInstance(this).defaultMarker().bitmap)
.withSource(source)
.withLayer(layer)

View File

@@ -15,6 +15,7 @@ import org.maplibre.android.maps.Style
import org.maplibre.android.style.layers.*
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import java.util.*
/**
@@ -29,7 +30,7 @@ class FillExtrusionActivity : AppCompatActivity() {
mapView.onCreate(savedInstanceState)
mapView.getMapAsync(
OnMapReadyCallback { maplibreMap: MapLibreMap ->
maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style ->
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style ->
val lngLats = listOf(
Arrays.asList(
Point.fromLngLat(5.12112557888031, 52.09071040847704),

View File

@@ -7,6 +7,7 @@ import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity used for instrumentation tests of fill extrusion.
@@ -25,7 +26,7 @@ class FillExtrusionStyleTestActivity : AppCompatActivity() {
mapView.onCreate(savedInstanceState)
mapView.getMapAsync { maplibreMap: MapLibreMap ->
maplibreMap.setStyle(
Style.Builder().fromUri(Style.getPredefinedStyle("Streets"))
Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Streets"))
) { style: Style? -> this@FillExtrusionStyleTestActivity.maplibreMap = maplibreMap }
}
}

View File

@@ -22,6 +22,7 @@ import org.maplibre.android.style.layers.SymbolLayer
import org.maplibre.android.style.sources.GeoJsonOptions
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.utils.BitmapUtils
import timber.log.Timber
import java.net.URI
@@ -77,7 +78,7 @@ class GeoJsonClusteringActivity : AppCompatActivity() {
try {
maplibreMap.setStyle(
Style.Builder()
.fromUri(Style.getPredefinedStyle("Bright"))
.fromUri(TestStyles.getPredefinedStyleWithFallback("Bright"))
.withSource(createClusterSource().also { clusterSource = it })
.withLayer(createSymbolLayer())
.withLayer(createClusterLevelLayer(0, clusterLayers))

View File

@@ -10,6 +10,7 @@ import org.maplibre.android.style.expressions.Expression
import org.maplibre.android.style.layers.*
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
import java.net.URI
import java.net.URISyntaxException
@@ -33,7 +34,7 @@ class HeatmapLayerActivity : AppCompatActivity() {
try {
maplibreMap.setStyle(
Style.Builder()
.fromUri(Style.getPredefinedStyle("Pastel"))
.fromUri(TestStyles.getPredefinedStyleWithFallback("Pastel"))
.withSource(createEarthquakeSource())
.withLayerAbove(createHeatmapLayer(), "country_label")
.withLayerBelow(createCircleLayer(), HEATMAP_LAYER_ID)

View File

@@ -6,6 +6,7 @@ import org.maplibre.android.maps.*
import org.maplibre.android.style.layers.HillshadeLayer
import org.maplibre.android.style.sources.RasterDemSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity showcasing using HillshadeLayer.
@@ -27,7 +28,7 @@ class HillshadeLayerActivity : AppCompatActivity() {
val hillshadeLayer = HillshadeLayer(LAYER_ID, SOURCE_ID)
maplibreMap.setStyle(
Style.Builder()
.fromUri(Style.getPredefinedStyle("Streets"))
.fromUri(TestStyles.getPredefinedStyleWithFallback("Streets"))
.withLayerBelow(hillshadeLayer, LAYER_BELOW_ID)
.withSource(rasterDemSource)
)

View File

@@ -16,6 +16,7 @@ import org.maplibre.android.style.layers.PropertyFactory
import org.maplibre.android.style.layers.SymbolLayer
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.utils.BitmapUtils
/**
@@ -32,7 +33,7 @@ class ImageInLabelActivity : AppCompatActivity(), OnMapReadyCallback {
}
override fun onMapReady(maplibreMap: MapLibreMap) {
maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style ->
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style ->
val us = BitmapUtils.getBitmapFromDrawable(
resources.getDrawable(R.drawable.ic_us)
)

View File

@@ -9,6 +9,7 @@ import org.maplibre.android.maps.*
import org.maplibre.android.style.layers.*
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
import java.net.URI
import java.net.URISyntaxException
@@ -35,7 +36,7 @@ class RealTimeGeoJsonActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(map: MapLibreMap) {
maplibreMap = map
maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) { style -> // add source
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style -> // add source
try {
style.addSource(GeoJsonSource(ID_GEOJSON_SOURCE, URI(URL_GEOJSON_SOURCE)))
} catch (malformedUriException: URISyntaxException) {

View File

@@ -34,6 +34,7 @@ import org.maplibre.android.style.sources.Source
import org.maplibre.android.style.sources.TileSet
import org.maplibre.android.style.sources.VectorSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.ResourceUtils
import timber.log.Timber
import java.io.IOException
@@ -95,7 +96,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
)
maplibreMap.setStyle(
Style.Builder()
.fromUri(Style.getPredefinedStyle("Streets")) // set custom transition
.fromUri(TestStyles.getPredefinedStyleWithFallback("Streets")) // set custom transition
.withTransition(TransitionOptions(250, 50))
) { style: Style ->
styleLoaded = true

View File

@@ -8,6 +8,7 @@ import org.maplibre.android.maps.*
import org.maplibre.android.style.layers.*
import org.maplibre.android.style.sources.VectorSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test activity for unit test execution
@@ -39,7 +40,7 @@ class RuntimeStyleTimingTestActivity : AppCompatActivity() {
)
maplibreMap.setStyle(
Style.Builder()
.fromUri(Style.getPredefinedStyle("Streets"))
.fromUri(TestStyles.getPredefinedStyleWithFallback("Streets"))
.withSource(parks)
.withLayer(parksLayer)
)

View File

@@ -11,6 +11,7 @@ import org.maplibre.android.style.expressions.Expression
import org.maplibre.android.style.layers.*
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.GeoParseUtil
import org.maplibre.android.utils.BitmapUtils
import timber.log.Timber
@@ -34,7 +35,7 @@ class StretchableImageActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(maplibreMap: MapLibreMap) {
this.maplibreMap = maplibreMap
maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style ->
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style ->
val popup = BitmapUtils.getBitmapFromDrawable(
resources.getDrawable(R.drawable.popup)
)

View File

@@ -13,6 +13,7 @@ import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.OnMapReadyCallback
import org.maplibre.android.maps.Style
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.ResourceUtils
import timber.log.Timber
import java.io.BufferedWriter
@@ -36,7 +37,7 @@ class StyleFileActivity : AppCompatActivity() {
if (map != null) {
maplibreMap = map
}
maplibreMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? ->
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style? ->
val fab = findViewById<FloatingActionButton>(R.id.fab_file)
fab.setColorFilter(ContextCompat.getColor(this@StyleFileActivity, R.color.primary))
fab.setOnClickListener { view: View ->

View File

@@ -25,6 +25,7 @@ import org.maplibre.android.style.layers.SymbolLayer
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.style.sources.Source
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.android.testapp.utils.ResourceUtils.readRawResource
import timber.log.Timber
import java.lang.ref.WeakReference
@@ -45,7 +46,7 @@ class SymbolGeneratorActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(map: MapLibreMap) {
maplibreMap = map
map.setStyle(Style.getPredefinedStyle("Outdoor")) { style: Style? ->
map.setStyle(TestStyles.getPredefinedStyleWithFallback("Outdoor")) { style: Style? ->
addSymbolClickListener()
LoadDataTask(this@SymbolGeneratorActivity).execute()
}

View File

@@ -19,6 +19,7 @@ import org.maplibre.android.style.layers.PropertyFactory
import org.maplibre.android.style.layers.SymbolLayer
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
/**
@@ -54,7 +55,7 @@ class ZoomFunctionSymbolLayerActivity : AppCompatActivity() {
mapView.getMapAsync(
OnMapReadyCallback { map: MapLibreMap ->
maplibreMap = map
map.setStyle(Style.getPredefinedStyle("Streets")) { style: Style ->
map.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets")) { style: Style ->
updateSource(style)
addLayer(style)
map.addOnMapClickListener(mapClickListener)

View File

@@ -18,6 +18,7 @@ import org.maplibre.android.testapp.R
import okhttp3.Call
import okhttp3.OkHttpClient
import okhttp3.OkHttpClient.Builder
import org.maplibre.android.testapp.styles.TestStyles
import timber.log.Timber
import java.util.*
@@ -39,7 +40,7 @@ class PerformanceMeasurementActivity : AppCompatActivity() {
mapView.getMapAsync(
OnMapReadyCallback { maplibreMap: MapLibreMap ->
maplibreMap.setStyle(
Style.Builder().fromUri(Style.getPredefinedStyle("Streets"))
Style.Builder().fromUri(TestStyles.getPredefinedStyleWithFallback("Streets"))
)
}
)

View File

@@ -11,6 +11,7 @@ import org.maplibre.android.geometry.LatLng
import org.maplibre.android.maps.*
import org.maplibre.android.maps.MapLibreMap.CancelableCallback
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
import java.util.*
/**
@@ -41,7 +42,7 @@ class TextureViewAnimationActivity : AppCompatActivity() {
mapView = findViewById<View>(R.id.mapView) as MapView
mapView.getMapAsync { maplibreMap: MapLibreMap ->
this@TextureViewAnimationActivity.maplibreMap = maplibreMap
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
setFpsView(maplibreMap)
// Animate the map view

View File

@@ -7,6 +7,7 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout
import com.google.android.material.floatingactionbutton.FloatingActionButton
import org.maplibre.android.maps.*
import org.maplibre.android.testapp.R
import org.maplibre.android.testapp.styles.TestStyles
/**
* Test resizing a [android.view.TextureView] backed map on the fly.
@@ -36,7 +37,7 @@ class TextureViewResizeActivity : AppCompatActivity() {
}
private fun setupMap(maplibreMap: MapLibreMap) {
maplibreMap.setStyle(Style.getPredefinedStyle("Streets"))
maplibreMap.setStyle(TestStyles.getPredefinedStyleWithFallback("Streets"))
}
private fun setupFab() {

View File

@@ -23,6 +23,7 @@ import org.maplibre.android.style.layers.SymbolLayer
import org.maplibre.android.style.sources.GeoJsonOptions
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.databinding.ActivityMapsnapshotterWithinExpressionBinding
import org.maplibre.android.testapp.styles.TestStyles.getPredefinedStyleWithFallback
/**
* An Activity that showcases the use of MapSnapshotter with 'within' expression
@@ -107,7 +108,7 @@ class MapSnapshotterWithinExpression : AppCompatActivity() {
// Setup style with additional layers,
// using streets as a base style
maplibreMap.setStyle(
Style.Builder().fromUri(Style.getPredefinedStyle("Streets"))
Style.Builder().fromUri(getPredefinedStyleWithFallback("Streets"))
) {
binding.mapView.addOnCameraDidChangeListener(cameraListener)
}
@@ -115,7 +116,7 @@ class MapSnapshotterWithinExpression : AppCompatActivity() {
val options = MapSnapshotter.Options(binding.imageView.measuredWidth / 2, binding.imageView.measuredHeight / 2)
.withCameraPosition(maplibreMap.cameraPosition)
.withPixelRatio(2.0f).withStyleBuilder(
Style.Builder().fromUri(Style.getPredefinedStyle("Streets")).withSources(
Style.Builder().fromUri(getPredefinedStyleWithFallback("Streets")).withSources(
GeoJsonSource(
POINT_ID,
LineString.fromLngLats(coordinates)

View File

@@ -14,6 +14,7 @@ import org.maplibre.android.style.layers.FillLayer
import org.maplibre.android.style.layers.PropertyFactory.fillColor
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.databinding.ActivityPhysicalCircleBinding
import org.maplibre.android.testapp.styles.TestStyles
import org.maplibre.turf.TurfTransformation
/**
@@ -61,7 +62,7 @@ class PhysicalUnitCircleActivity : AppCompatActivity(), SeekBar.OnSeekBarChangeL
maplibreMap.setStyle(
Style.Builder()
.fromUri(Style.getPredefinedStyle("Satellite Hybrid"))
.fromUri(TestStyles.getPredefinedStyleWithFallback("Satellite Hybrid"))
.withLayer(
FillLayer(LAYER_ID, SOURCE_ID).withProperties(
fillColor(

View File

@@ -23,6 +23,7 @@ import org.maplibre.android.style.layers.SymbolLayer
import org.maplibre.android.style.sources.GeoJsonOptions
import org.maplibre.android.style.sources.GeoJsonSource
import org.maplibre.android.testapp.databinding.ActivityWithinExpressionBinding
import org.maplibre.android.testapp.styles.TestStyles
/**
* An Activity that showcases the within expression to filter features outside a geometry
@@ -98,7 +99,7 @@ class WithinExpressionActivity : AppCompatActivity() {
// using streets as a base style
maplibreMap.setStyle(
Style.Builder()
.fromUri(Style.getPredefinedStyle("Streets"))
.fromUri(TestStyles.getPredefinedStyleWithFallback("Streets"))
.withSources(
GeoJsonSource(
POINT_ID,

View File

@@ -0,0 +1,18 @@
package org.maplibre.android.testapp.styles
import org.maplibre.android.maps.Style
object TestStyles {
val VERSATILES = "https://tiles.versatiles.org/assets/styles/colorful.json"
val AMERICANA = "https://zelonewolf.github.io/openstreetmap-americana/style.json"
fun getPredefinedStyleWithFallback(name: String): String {
try {
val style = Style.getPredefinedStyle(name)
return style
} catch (e: Exception) {
return VERSATILES
}
}
}

Some files were not shown because too many files have changed in this diff Show More