Replacing hardcoded configuration with configurable API and removing Mapbox assets (#90)

* Refactoring online file source so that tile server configuration is not hardcoded - part 1

* Added default templates

* Update from master

* Renaming MGLAccountManager to MGLSettings. Passing ResourceOptions and TileServerOptions to relevant classes and method in order to remove mapbox hardocded configuration

* Fixing build

* Addedm missing theme

* Unit tests fixes

* Fixing unit tests, adding factory methods for creating predefined configuration.

* Fixing mapbox unit tests

* Additional unit test fixes

* Making MapboxConfiguration default

* Making get/set resource options available in all classes that inherits from FileSource

* Making get/set resource options available in all classes that inherits from FileSource - part 2

* Fixes for Android

* Disable test coverage reports

* Disable test coverage reports

* Disable test coverage reports

* Disable test coverage reports

* Removing hardcoded configuration in iOS project - part 1

* Fixing wrong file extension, making use of tile server options.

* Use apiKey and MGL_API_KEY everywhere

* Just a rename

* Re-enabling tests and improving MGLSettings init

* Removing mapbox hardcoded configuration, using api key everywhere, implementing JNI conversion for TileServerOptions

* Lint issues.

* Integrating configurable tile server properties into Android SDK - part 2

* Removing mabox accounts

* Exposing multiple configurations to Android SDK - bug fixes

* Removing TileServerOptions from public interface - native methods dont work before mapbox-gl library is loaded

* Adding support for configurable predefined styles

* Migrating predefined styles in test app + cleanup

* Parameter fix

* Bug fixes

* Fixing render test build

* Fixing offline tester

* Fixing benchmark tool

* Fix: typo in method name

* Adding code for public access to TileServerOptions

* Bug fixes and debug code removal

* Fixes for macOS, adding unit tests from MapLibre, removing redundant members from OnlineFileSource

* Unit test fixes

* MacOS test app - migrating to configurable tile server options, part 1

* Fixing offline maps

* Migrating macOS test app to MapTiler

* Minor improvements

* Putting back apiKey test

* Added unit tests for MapTiler configuration

* Migrating test resources to MapTiler

* minor fix

* A few fixes

* Fixing macOS tests, removing feedback functionality

* Migrating ios test app to MapTiler

* Migrating ui tests

* UI tests fix

* Benchmarking app fix

* Cleanup and strings updates

* Migrating benchmark app to maptiler

* API key injection in benchmark app

* Putting back release configuration

* Additional tests and fixing issues identified by thread sanitizer.

* Removing test filters

* Fixes and addressing lint issues

* More Maptiler tests + minro fix

* Android instrumentation test migration to MapTiler. Exposing missing TileServerOptions in Android SDK. Minor fixes.

* No requirements on API key format.

* Fixing offline cache test tool

* Adding configurable domain name for sources, adding source domain int MapTiler configuration, cleanup

* Migrating tests to MapTiler, adding code for canonicalizing URLs, removing mapbox stuff from comments, cleanup

* More tests

* Updated database size

* Lint issues

* Fixed test

* Updating developer config API key

* Fixes for Android, propagaing updated tileServerOptions to native file sources, more tests

* Just a few more fixes

* Propagating updated settings to file sources + additional unit test

* Lint issues

* Removing test filter and fixing incorrect uri

* Release preparation

* macos release notes
This commit is contained in:
Petr Pokorny
2021-06-29 12:44:51 +02:00
committed by GitHub
parent 9a49fa16c9
commit d62ff400c6
398 changed files with 107907 additions and 184517 deletions

View File

@@ -190,7 +190,7 @@ class LocationComponentTest : EspressoTest() {
uiController: UiController,
context: Context
) {
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
mapboxMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
component.activateLocationComponent(
LocationComponentActivationOptions
@@ -675,7 +675,7 @@ class LocationComponentTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
component.isLocationComponentEnabled = false
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
mapboxMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
component.isLocationComponentEnabled = true
TestingAsyncUtils.waitForLayer(uiController, mapView)
@@ -796,7 +796,7 @@ class LocationComponentTest : EspressoTest() {
component.onStop()
component.onStart()
mapboxMap.setStyle(Style.Builder().fromUrl(Style.DARK))
mapboxMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
TestingAsyncUtils.waitForLayer(uiController, mapView)
}
}
@@ -821,7 +821,7 @@ class LocationComponentTest : EspressoTest() {
.build()
)
component.isLocationComponentEnabled = true
mapboxMap.setStyle(Style.Builder().fromUrl(Style.DARK))
mapboxMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
component.onStop()
component.onStart()
TestingAsyncUtils.waitForLayer(uiController, mapView)
@@ -908,7 +908,7 @@ class LocationComponentTest : EspressoTest() {
)
component.isLocationComponentEnabled = true
component.forceLocationUpdate(location)
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
mapboxMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
component.onStop()
TestingAsyncUtils.waitForLayer(uiController, mapView)
component.onStart()

View File

@@ -154,7 +154,7 @@ class LocationLayerControllerTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
styleChangeIdlingResource.waitForStyle(mapboxMap, Style.LIGHT)
styleChangeIdlingResource.waitForStyle(mapboxMap, Style.getPredefinedStyle("Bright"))
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL)))
@@ -456,7 +456,7 @@ class LocationLayerControllerTest : EspressoTest() {
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
component.forceLocationUpdate(location)
styleChangeIdlingResource.waitForStyle(mapboxMap, Style.LIGHT)
styleChangeIdlingResource.waitForStyle(mapboxMap, Style.getPredefinedStyle("Bright"))
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL)))
@@ -503,7 +503,7 @@ class LocationLayerControllerTest : EspressoTest() {
`is`(true)
)
mapboxMap.setStyle(Style.Builder().fromUrl(Style.LIGHT))
mapboxMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Bright")))
TestingAsyncUtils.waitForLayer(uiController, mapView)
assertThat(

View File

@@ -0,0 +1,96 @@
package com.mapbox.mapboxsdk.maps
import androidx.test.annotation.UiThreadTest
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.Mapbox
import com.mapbox.mapboxsdk.WellKnownTileServer
import com.mapbox.mapboxsdk.storage.FileSource
import com.mapbox.mapboxsdk.testapp.MapboxApplication
import com.mapbox.mapboxsdk.util.TileServerOptions
import org.junit.*
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class BootstrapTest : AppCenter() {
var apiKeyBackup: String? = null
@Before
@UiThreadTest
fun before() {
apiKeyBackup = Mapbox.getApiKey()
}
@After
@UiThreadTest
fun after() {
val context = InstrumentationRegistry.getInstrumentation().context
Mapbox.getInstance(context, apiKeyBackup, MapboxApplication.TILE_SERVER)
}
@Test
@UiThreadTest
fun defaultBootstrap() {
val context = InstrumentationRegistry.getInstrumentation().context
Mapbox.getInstance(context)
val tileServerOptions = TileServerOptions.get(WellKnownTileServer.MapLibre)
Assert.assertTrue(
Style.getPredefinedStyles().count() == tileServerOptions.defaultStyles.count()
)
Assert.assertTrue(
Style.getPredefinedStyles().first().url == tileServerOptions.defaultStyles.first().url
)
val fileSource = FileSource.getInstance(context)
Assert.assertEquals(fileSource.apiBaseUrl, tileServerOptions.baseURL)
}
@Test
@UiThreadTest
fun maptilerBootstrap() {
val context = InstrumentationRegistry.getInstrumentation().context
val key = "abcdef"
Mapbox.getInstance(context, key, WellKnownTileServer.MapTiler)
val tileServerOptions = TileServerOptions.get(WellKnownTileServer.MapTiler)
Assert.assertTrue(
Style.getPredefinedStyles().count() == tileServerOptions.defaultStyles.count()
)
Assert.assertTrue(
Style.getPredefinedStyles().first().url == tileServerOptions.defaultStyles.first().url
)
val fileSource = FileSource.getInstance(context)
Assert.assertEquals(fileSource.apiBaseUrl, tileServerOptions.baseURL)
Assert.assertEquals(fileSource.apiKey, key)
}
@Test
@UiThreadTest
fun duplicateBootstrap() {
val context = InstrumentationRegistry.getInstrumentation().context
val key = "pk.abcdef"
Mapbox.getInstance(context, key, WellKnownTileServer.MapTiler)
Mapbox.getInstance(context)
Mapbox.getInstance(context, key, WellKnownTileServer.Mapbox)
val tileServerOptions = TileServerOptions.get(WellKnownTileServer.Mapbox)
Assert.assertTrue(
Style.getPredefinedStyles().count() == tileServerOptions.defaultStyles.count()
)
Assert.assertTrue(
Style.getPredefinedStyles().first().url == tileServerOptions.defaultStyles.first().url
)
val fileSource = FileSource.getInstance(context)
Assert.assertEquals(fileSource.apiBaseUrl, tileServerOptions.baseURL)
Assert.assertEquals(fileSource.apiKey, key)
}
}

View File

@@ -21,8 +21,8 @@ import static junit.framework.Assert.assertTrue;
@RunWith(AndroidJUnit4.class)
public class MapboxTest extends AppCenter {
private static final String ACCESS_TOKEN = "pk.0000000001";
private static final String ACCESS_TOKEN_2 = "pk.0000000002";
private static final String API_KEY = "pk.0000000001";
private static final String API_KEY_2 = "pk.0000000002";
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -31,7 +31,7 @@ public class MapboxTest extends AppCenter {
@Before
public void setup() {
realToken = Mapbox.getAccessToken();
realToken = Mapbox.getApiKey();
}
@Test
@@ -52,44 +52,26 @@ public class MapboxTest extends AppCenter {
@Test
@UiThreadTest
public void setAccessToken() {
Mapbox.setAccessToken(ACCESS_TOKEN);
assertSame(ACCESS_TOKEN, Mapbox.getAccessToken());
Mapbox.setAccessToken(ACCESS_TOKEN_2);
assertSame(ACCESS_TOKEN_2, Mapbox.getAccessToken());
public void setApiKey() {
Mapbox.setApiKey(API_KEY);
assertSame(API_KEY, Mapbox.getApiKey());
Mapbox.setApiKey(API_KEY_2);
assertSame(API_KEY_2, Mapbox.getApiKey());
}
@Test
@UiThreadTest
public void setInvalidAccessToken() {
final String invalidAccessToken = "xyz";
public void setNullApiKey() {
expectedException.expect(MapboxConfigurationException.class);
expectedException.expectMessage(
"A valid access token parameter is required when using a Mapbox service."
+ "\nPlease see https://www.mapbox.com/help/create-api-access-token/ to learn how to create one."
+ "\nMore information in this guide https://www.mapbox.com/help/first-steps-android-sdk/#access-tokens."
+ "Currently provided token is: " + invalidAccessToken
"A valid API key is required, currently provided key is: " + null
);
Mapbox.setAccessToken(invalidAccessToken);
}
@Test
@UiThreadTest
public void setNullAccessToken() {
expectedException.expect(MapboxConfigurationException.class);
expectedException.expectMessage(
"A valid access token parameter is required when using a Mapbox service."
+ "\nPlease see https://www.mapbox.com/help/create-api-access-token/ to learn how to create one."
+ "\nMore information in this guide https://www.mapbox.com/help/first-steps-android-sdk/#access-tokens."
+ "Currently provided token is: " + null
);
Mapbox.setAccessToken(null);
Mapbox.setApiKey(null);
}
@After
public void tearDown() {
Mapbox.setAccessToken(realToken);
Mapbox.setApiKey(realToken);
}
}

View File

@@ -6,12 +6,15 @@ import androidx.test.annotation.UiThreadTest
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.mapbox.mapboxsdk.AppCenter
import com.mapbox.mapboxsdk.Mapbox
import com.mapbox.mapboxsdk.WellKnownTileServer
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.geometry.LatLngBounds
import com.mapbox.mapboxsdk.geometry.ProjectedMeters
import com.mapbox.mapboxsdk.maps.renderer.MapRenderer
import com.mapbox.mapboxsdk.style.layers.TransitionOptions
import com.mapbox.mapboxsdk.testapp.MapboxApplication
import com.mapbox.mapboxsdk.testapp.utils.TestConstants
import junit.framework.Assert.*
import org.junit.After
@@ -41,6 +44,8 @@ class NativeMapViewTest : AppCenter() {
@UiThreadTest
fun before() {
val context = InstrumentationRegistry.getInstrumentation().context
val apiKey = Mapbox.getApiKey()
Mapbox.getInstance(context, apiKey, WellKnownTileServer.MapTiler)
nativeMapView = NativeMapView(context, 2.0f, false, null, null, DummyRenderer(context))
nativeMapView.resizeView(WIDTH, HEIGHT)
}
@@ -48,13 +53,16 @@ class NativeMapViewTest : AppCenter() {
@After
@UiThreadTest
fun after() {
val context = InstrumentationRegistry.getInstrumentation().context
val apiKey = Mapbox.getApiKey()
Mapbox.getInstance(context, apiKey, MapboxApplication.TILE_SERVER)
nativeMapView.destroy()
}
@Test
@UiThreadTest
fun testSetStyleUrl() {
val expected = Style.DARK
val expected = Style.getPredefinedStyle("Pastel")
nativeMapView.styleUri = expected
val actual = nativeMapView.styleUri
assertEquals("Style URL should match", expected, actual)

View File

@@ -69,7 +69,7 @@ class OfflineDownloadTest : OfflineRegion.OfflineRegionObserver {
private fun createTestRegionDefinition(): OfflineRegionDefinition {
return OfflineGeometryRegionDefinition(
Style.MAPBOX_STREETS,
Style.getPredefinedStyle("Streets"),
Point.fromLngLat(50.847857, 4.360137),
17.0,
17.0,

View File

@@ -38,7 +38,7 @@ class MapSnapshotterTest {
val options = MapSnapshotter.Options(512, 512)
.withPixelRatio(1.0f)
.withStyleBuilder(
Style.Builder().fromUri(Style.SATELLITE_STREETS)
Style.Builder().fromUri(Style.getPredefinedStyle("Satellite Hybrid"))
.withLayerAbove(bg, "country-label")
)
.withCameraPosition(

View File

@@ -70,9 +70,9 @@ class ImageMissingTest : AppCenter() {
"""
{
"version": 8,
"name": "Mapbox Streets",
"sprite": "mapbox://sprites/mapbox/streets-v8",
"glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
"name": "Streets",
"sprite": "maptiler://sprites/streets/sprite",
"glyphs": "maptiler://fonts/{fontstack}/{range}.pbf",
"sources": {
"point": {
"type": "geojson",
@@ -114,9 +114,9 @@ class ImageMissingTest : AppCenter() {
"""
{
"version": 8,
"name": "Mapbox Streets",
"sprite": "asset://sprites/mapbox/invalid",
"glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
"name": "Streets",
"sprite": "maptiler://sprites/streets/sprite",
"glyphs": "maptiler://fonts/{fontstack}/{range}.pbf",
"sources": {
"point": {
"type": "geojson",

View File

@@ -23,7 +23,7 @@ class StyleLoadTest : EspressoTest() {
val layer = SymbolLayer("id", "id")
mapboxMap.setStyle(Style.Builder().withSource(source).withLayer(layer))
TestingAsyncUtils.waitForLayer(uiController, mapView)
mapboxMap.setStyle(Style.Builder().fromUrl(Style.MAPBOX_STREETS))
mapboxMap.setStyle(Style.Builder().fromUrl(Style.getPredefinedStyle("Streets")))
TestingAsyncUtils.waitForLayer(uiController, mapView)
source.setGeoJson("{}")
}

View File

@@ -184,11 +184,11 @@ public class RuntimeStyleTests extends EspressoTest {
public void testAddRemoveSource() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
mapboxMap.getStyle().addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
mapboxMap.getStyle().addSource(new VectorSource("my-source", "maptiler://sources/hillshades"));
mapboxMap.getStyle().removeSource("my-source");
// Add initial source
mapboxMap.getStyle().addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
mapboxMap.getStyle().addSource(new VectorSource("my-source", "maptiler://sources/hillshades"));
// Remove
boolean removeOk = mapboxMap.getStyle().removeSource("my-source");
@@ -196,7 +196,7 @@ public class RuntimeStyleTests extends EspressoTest {
assertNull(mapboxMap.getStyle().getLayer("my-source"));
// Add
Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
Source source = new VectorSource("my-source", "maptiler://sources/hillshades");
mapboxMap.getStyle().addSource(source);
// Remove, preserving the reference
@@ -210,7 +210,7 @@ public class RuntimeStyleTests extends EspressoTest {
// Test adding a duplicate source
try {
Source source2 = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
Source source2 = new VectorSource("my-source", "maptiler://sources/hillshades");
mapboxMap.getStyle().addSource(source2);
fail("Should not have been allowed to add a source with a duplicate id");
} catch (CannotAddSourceException cannotAddSourceException) {
@@ -224,9 +224,9 @@ public class RuntimeStyleTests extends EspressoTest {
public void testVectorSourceUrlGetter() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
VectorSource source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
VectorSource source = new VectorSource("my-source", "maptiler://sources/hillshades");
mapboxMap.getStyle().addSource(source);
assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUri());
assertEquals("maptiler://sources/hillshades", source.getUri());
});
}
@@ -234,9 +234,9 @@ public class RuntimeStyleTests extends EspressoTest {
public void testRasterSourceUrlGetter() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
RasterSource source = new RasterSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
RasterSource source = new RasterSource("my-source", "maptiler://sources/hillshades");
mapboxMap.getStyle().addSource(source);
assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUri());
assertEquals("maptiler://sources/hillshades", source.getUri());
});
}
@@ -260,7 +260,7 @@ public class RuntimeStyleTests extends EspressoTest {
@Override
public void perform(UiController uiController, View view) {
mapboxMap.getStyle().addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
mapboxMap.getStyle().addSource(new VectorSource("my-source", "maptiler://sources/hillshades"));
mapboxMap.getStyle().addLayer(new LineLayer("my-layer", "my-source"));
mapboxMap.getStyle().removeSource("my-source");
assertNotNull(mapboxMap.getStyle().getSource("my-source"));

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,766 @@
{
"id": "hybrid",
"name": "Satellite Hybrid",
"zoom": 1,
"pitch": 0,
"center": [
0,
0
],
"glyphs": "https://api.maptiler.com/fonts/{fontstack}/{range}.pbf?key=uwvyvzaF2P7UWbyOEvjU",
"layers": [
{
"id": "satellite",
"type": "raster",
"paint": {
"raster-opacity": 1
},
"filter": [
"all"
],
"layout": {
"visibility": "visible"
},
"source": "satellite",
"minzoom": 0
},
{
"id": "tunnel",
"type": "line",
"paint": {
"line-color": "rgba(255, 255, 255, 0.2)",
"line-width": [
"interpolate",
[
"exponential",
1.5
],
[
"zoom"
],
6,
0.5,
20,
30
],
"line-dasharray": [
0.28,
0.14
]
},
"filter": [
"all",
[
"==",
"$type",
"LineString"
],
[
"==",
"brunnel",
"tunnel"
],
[
"in",
"class",
"motorway",
"primary",
"secondary",
"tertiary",
"trunk"
]
],
"layout": {
"line-cap": "butt",
"line-join": "miter"
},
"source": "openmaptiles",
"source-layer": "transportation"
},
{
"id": "path",
"type": "line",
"paint": {
"line-color": "rgba(247, 247, 247, 0.33)",
"line-width": [
"interpolate",
[
"exponential",
1.5
],
[
"zoom"
],
14,
0.5,
20,
4
],
"line-dasharray": [
1,
1
]
},
"filter": [
"all",
[
"==",
"$type",
"LineString"
],
[
"in",
"class",
"path",
"track"
]
],
"layout": {
"line-cap": "square",
"line-join": "bevel"
},
"source": "openmaptiles",
"source-layer": "transportation"
},
{
"id": "road",
"type": "line",
"paint": {
"line-color": [
"interpolate",
[
"linear"
],
[
"zoom"
],
8,
"rgba(255, 255, 255, 0.2)",
14,
"rgba(255, 255, 255, 0.3)"
],
"line-width": [
"interpolate",
[
"linear"
],
[
"zoom"
],
5,
[
"match",
[
"get",
"class"
],
[
"motorway",
"motorway_link"
],
1,
0
],
7,
[
"match",
[
"get",
"class"
],
[
"motorway",
"motorway_link"
],
1.4,
0
],
8,
[
"match",
[
"get",
"class"
],
[
"motorway",
"motorway_link",
"primary",
"trunk"
],
0.75,
0
],
9,
[
"match",
[
"get",
"class"
],
[
"secondary",
"tertiary"
],
0.7,
1
],
10,
[
"match",
[
"get",
"class"
],
[
"motorway",
"motorway_link"
],
1.3,
1.3
],
14,
[
"match",
[
"get",
"class"
],
[
"minor",
"service"
],
0.5,
2.4
]
]
},
"filter": [
"all",
[
"==",
"$type",
"LineString"
],
[
"!in",
"class",
"rail",
"ferry",
"path",
"track"
],
[
"!=",
"brunnel",
"tunnel"
]
],
"layout": {
"line-cap": "butt",
"line-join": "round"
},
"source": "openmaptiles",
"minzoom": 6,
"source-layer": "transportation"
},
{
"id": "railway",
"type": "line",
"paint": {
"line-color": "rgba(179, 170, 158, 0.2)",
"line-opacity": [
"interpolate",
[
"linear"
],
[
"zoom"
],
11,
0.5,
16,
1.3
]
},
"filter": [
"==",
"class",
"rail"
],
"layout": {
"visibility": "visible"
},
"source": "openmaptiles",
"minzoom": 11,
"source-layer": "transportation"
},
{
"id": "admin_sub",
"type": "line",
"paint": {
"line-color": "rgba(194, 194, 194, 0.5)",
"line-dasharray": [
2,
1
]
},
"filter": [
"in",
"admin_level",
4,
6,
8
],
"layout": {
"visibility": "visible"
},
"source": "openmaptiles",
"minzoom": 3,
"source-layer": "boundary"
},
{
"id": "admin_country-dark",
"type": "line",
"paint": {
"line-color": "rgba(0, 0, 0, 0.51)",
"line-width": [
"interpolate",
[
"exponential",
1.5
],
[
"zoom"
],
3,
0.5,
21,
32
],
"line-offset": 1
},
"filter": [
"all",
[
"<=",
"admin_level",
2
],
[
"==",
"$type",
"LineString"
]
],
"layout": {
"line-cap": "butt",
"line-join": "round",
"visibility": "visible"
},
"source": "openmaptiles",
"source-layer": "boundary"
},
{
"id": "admin_country",
"type": "line",
"paint": {
"line-color": "rgba(226, 226, 226, 1)",
"line-width": [
"interpolate",
[
"exponential",
1.5
],
[
"zoom"
],
3,
0.5,
21,
32
]
},
"filter": [
"all",
[
"<=",
"admin_level",
2
],
[
"==",
"$type",
"LineString"
]
],
"layout": {
"line-cap": "round",
"line-join": "round",
"visibility": "visible"
},
"source": "openmaptiles",
"source-layer": "boundary"
},
{
"id": "road_label",
"type": "symbol",
"paint": {
"text-color": "rgba(255, 255, 255, 1)",
"text-halo-color": "rgba(43, 43, 43, 1)",
"text-halo-width": 1
},
"filter": [
"==",
"$type",
"LineString"
],
"layout": {
"text-font": [
"Noto Sans Regular"
],
"text-size": [
"interpolate",
[
"cubic-bezier",
0.75,
1,
0.75,
1
],
[
"zoom"
],
10,
8,
15,
9
],
"text-field": "{name:latin} {name:nonlatin}",
"text-transform": "none",
"symbol-placement": "line",
"text-letter-spacing": 0.1,
"text-rotation-alignment": "map"
},
"source": "openmaptiles",
"source-layer": "transportation_name"
},
{
"id": "place_label",
"type": "symbol",
"paint": {
"text-color": "rgba(255, 255, 255, 1)",
"text-halo-blur": 0.5,
"text-halo-color": [
"match",
[
"get",
"class"
],
[
"city"
],
"rgba(0, 0, 0, 0.75)",
"rgba(43, 43, 43, 1)"
],
"text-halo-width": 1
},
"filter": [
"all",
[
"==",
"$type",
"Point"
],
[
"!in",
"class",
"country",
"state"
]
],
"layout": {
"text-font": [
"Noto Sans Regular"
],
"text-size": [
"interpolate",
[
"cubic-bezier",
0.5,
1,
0.5,
1
],
[
"zoom"
],
3,
[
"match",
[
"get",
"class"
],
"city",
11,
10
],
6,
[
"match",
[
"get",
"class"
],
"city",
14.5,
11
],
8,
[
"match",
[
"get",
"class"
],
"city",
16,
12
],
10,
[
"match",
[
"get",
"class"
],
"city",
20,
13
]
],
"text-field": "{name:latin}\n{name:nonlatin}",
"text-max-width": 10
},
"source": "openmaptiles",
"maxzoom": 16,
"minzoom": 3,
"source-layer": "place"
},
{
"id": "state_label",
"type": "symbol",
"paint": {
"text-color": "rgba(255, 255, 255, 1)",
"text-halo-blur": 1,
"text-halo-color": "rgba(0, 0, 0, 1)",
"text-halo-width": 1
},
"filter": [
"all",
[
"==",
"$type",
"Point"
],
[
"in",
"class",
"state"
]
],
"layout": {
"text-font": [
"Noto Sans Italic"
],
"text-size": [
"interpolate",
[
"cubic-bezier",
0.75,
1,
0.75,
1
],
[
"zoom"
],
1,
[
"step",
[
"get",
"rank"
],
13,
1,
12,
2,
12
],
4,
[
"step",
[
"get",
"rank"
],
15,
1,
14,
2,
14
],
6,
[
"step",
[
"get",
"rank"
],
23,
1,
18,
2,
18
],
9,
[
"step",
[
"get",
"rank"
],
27,
1,
22,
2,
22
]
],
"text-field": "{name:latin}",
"text-max-width": 10
},
"source": "openmaptiles",
"maxzoom": 12,
"minzoom": 3,
"source-layer": "place"
},
{
"id": "country_label",
"type": "symbol",
"paint": {
"text-color": "rgba(255, 255, 255, 1)",
"text-halo-blur": 1,
"text-halo-color": "rgba(0, 0, 0, 1)",
"text-halo-width": 1
},
"filter": [
"all",
[
"==",
"$type",
"Point"
],
[
"in",
"class",
"country"
]
],
"layout": {
"text-font": [
"Noto Sans Bold"
],
"text-size": [
"interpolate",
[
"cubic-bezier",
0.75,
1,
0.75,
1
],
[
"zoom"
],
1,
[
"step",
[
"get",
"rank"
],
13,
1,
12,
2,
12
],
4,
[
"step",
[
"get",
"rank"
],
15,
1,
14,
2,
14
],
6,
[
"step",
[
"get",
"rank"
],
23,
1,
18,
2,
18
],
9,
[
"step",
[
"get",
"rank"
],
27,
1,
22,
2,
22
]
],
"text-field": "{name:latin}",
"text-max-width": 10
},
"source": "openmaptiles",
"maxzoom": 12,
"source-layer": "place"
}
],
"bearing": 0,
"sources": {
"satellite": {
"url": "https://api.maptiler.com/tiles/satellite/tiles.json?key=uwvyvzaF2P7UWbyOEvjU",
"type": "raster",
"tileSize": 256
},
"openmaptiles": {
"url": "https://api.maptiler.com/tiles/v3/tiles.json?key=uwvyvzaF2P7UWbyOEvjU",
"type": "vector"
}
},
"version": 8,
"metadata": {
"maputnik:renderer": "mbgljs",
"openmaptiles:version": "3.x"
}
}

View File

@@ -6,10 +6,11 @@ import android.text.TextUtils;
import com.mapbox.mapboxsdk.MapStrictMode;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.WellKnownTileServer;
import com.mapbox.mapboxsdk.log.Logger;
import com.mapbox.mapboxsdk.testapp.utils.TileLoadingMeasurementUtils;
import com.mapbox.mapboxsdk.testapp.utils.TimberLogger;
import com.mapbox.mapboxsdk.testapp.utils.TokenUtils;
import com.mapbox.mapboxsdk.testapp.utils.ApiKeyUtils;
import com.squareup.leakcanary.LeakCanary;
import timber.log.Timber;
@@ -24,9 +25,11 @@ import static timber.log.Timber.DebugTree;
*/
public class MapboxApplication extends Application {
private static final String DEFAULT_MAPBOX_ACCESS_TOKEN = "YOUR_MAPBOX_ACCESS_TOKEN_GOES_HERE";
private static final String ACCESS_TOKEN_NOT_SET_MESSAGE = "In order to run the Test App you need to set a valid "
+ "access token. During development, you can set the MAPBOX_ACCESS_TOKEN environment variable for the SDK to "
public static final WellKnownTileServer TILE_SERVER = WellKnownTileServer.MapTiler;
private static final String DEFAULT_API_KEY = "YOUR_API_KEY_GOES_HERE";
private static final String API_KEY_NOT_SET_MESSAGE = "In order to run the Test App you need to set a valid "
+ "API key. During development, you can set the MGL_API_KEY environment variable for the SDK to "
+ "automatically include it in the Test App. Otherwise, you can manually include it in the "
+ "res/values/developer-config.xml file in the MapboxGLAndroidSDKTestApp folder.";
@@ -73,17 +76,19 @@ public class MapboxApplication extends Application {
}
private void initializeMapbox() {
String accessToken = TokenUtils.getMapboxAccessToken(getApplicationContext());
validateAccessToken(accessToken);
Mapbox.getInstance(getApplicationContext(), accessToken);
String apiKey = ApiKeyUtils.getApiKey(getApplicationContext());
validateApiKey(apiKey);
Mapbox.getInstance(getApplicationContext(), apiKey, TILE_SERVER);
TileLoadingMeasurementUtils.setUpTileLoadingMeasurement();
MapStrictMode.setStrictModeEnabled(true);
}
private static void validateAccessToken(String accessToken) {
if (TextUtils.isEmpty(accessToken) || accessToken.equals(DEFAULT_MAPBOX_ACCESS_TOKEN)) {
Timber.e(ACCESS_TOKEN_NOT_SET_MESSAGE);
private static void validateApiKey(String apiKey) {
if (TextUtils.isEmpty(apiKey) || apiKey.equals(DEFAULT_API_KEY)) {
Timber.e(API_KEY_NOT_SET_MESSAGE);
}
}
}

View File

@@ -50,7 +50,7 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
private static final String RANDOM_CAR_SOURCE = "random-car-source";
private static final String RANDOM_CAR_IMAGE_ID = "random-car";
private static final String PROPERTY_BEARING = "bearing";
private static final String WATERWAY_LAYER_ID = "waterway-label";
private static final String WATERWAY_LAYER_ID = "water_intermittent";
private static final int DURATION_RANDOM_MAX = 1500;
private static final int DURATION_BASE = 3000;
@@ -77,7 +77,7 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
this.mapboxMap = map;
map.setStyle(Style.MAPBOX_STREETS, style -> {
map.setStyle(Style.getPredefinedStyle("Streets"), style -> {
this.style = style;
setupCars();
animateRandomRoutes();

View File

@@ -52,7 +52,7 @@ public class BulkMarkerActivity extends AppCompatActivity implements AdapterView
private void initMap(MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"));
}
@Override

View File

@@ -37,7 +37,7 @@ public class DynamicMarkerChangeActivity extends AppCompatActivity {
mapView.setTag(false);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"));
DynamicMarkerChangeActivity.this.mapboxMap = mapboxMap;
// Create marker

View File

@@ -77,7 +77,7 @@ public class PolygonActivity extends AppCompatActivity implements OnMapReadyCall
@Override
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
map.setStyle(Style.MAPBOX_STREETS);
map.setStyle(Style.getPredefinedStyle("Streets"));
map.setOnPolygonClickListener(polygon -> Toast.makeText(
PolygonActivity.this,

View File

@@ -67,7 +67,7 @@ public class PolylineActivity extends AppCompatActivity {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
PolylineActivity.this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.SATELLITE_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid"));
mapboxMap.setOnPolylineClickListener(polyline -> Toast.makeText(
PolylineActivity.this,
"You clicked on polyline with id = " + polyline.getId(),

View File

@@ -55,7 +55,7 @@ public class PressForMarkerActivity extends AppCompatActivity {
return false;
});
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"));
if (savedInstanceState != null) {
markerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST);

View File

@@ -74,7 +74,7 @@ public class CameraAnimationTypeActivity extends AppCompatActivity implements On
@Override
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
mapboxMap.setStyle(new Style.Builder().fromUri(Style.MAPBOX_STREETS));
mapboxMap.setStyle(new Style.Builder().fromUri(Style.getPredefinedStyle("Streets")));
mapboxMap.getUiSettings().setAttributionEnabled(false);
mapboxMap.getUiSettings().setLogoEnabled(false);
mapboxMap.addOnCameraIdleListener(cameraIdleListener);

View File

@@ -79,7 +79,7 @@ public class CameraAnimatorActivity extends AppCompatActivity implements OnMapRe
@Override
public void onMapReady(@NonNull final MapboxMap map) {
mapboxMap = map;
map.setStyle(Style.MAPBOX_STREETS);
map.setStyle(Style.getPredefinedStyle("Streets"));
initFab();
}

View File

@@ -60,7 +60,7 @@ public class CameraPositionActivity extends FragmentActivity implements OnMapRea
@Override
public void onMapReady(@NonNull final MapboxMap map) {
mapboxMap = map;
map.setStyle(Style.SATELLITE_STREETS, style -> {
map.setStyle(Style.getPredefinedStyle("Satellite Hybrid"), style -> {
// add a listener to FAB
fab = findViewById(R.id.fab);
fab.setColorFilter(ContextCompat.getColor(CameraPositionActivity.this, R.color.primary));

View File

@@ -71,7 +71,7 @@ public class GestureDetectorActivity extends AppCompatActivity {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
GestureDetectorActivity.this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"));
initializeMap();
});

View File

@@ -68,7 +68,7 @@ class LatLngBoundsActivity : AppCompatActivity() {
private fun loadStyle(featureCollection: FeatureCollection) {
mapboxMap.setStyle(
Style.Builder()
.fromUri(Style.MAPBOX_STREETS)
.fromUri(Style.getPredefinedStyle("Streets"))
.withLayer(
SymbolLayer("symbol", "symbol")
.withProperties(

View File

@@ -35,7 +35,7 @@ public class ManualZoomActivity extends AppCompatActivity {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
ManualZoomActivity.this.mapboxMap = mapboxMap;
mapboxMap.setStyle(new Style.Builder().fromUri(Style.SATELLITE));
mapboxMap.setStyle(new Style.Builder().fromUri(Style.getPredefinedStyle("Satellite Hybrid")));
UiSettings uiSettings = ManualZoomActivity.this.mapboxMap.getUiSettings();
uiSettings.setAllGesturesEnabled(false);
});

View File

@@ -26,7 +26,7 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC
@Override
public boolean onMapClick(@NonNull LatLng point) {
if (mapboxMap != null) {
mapboxMap.setStyle(new Style.Builder().fromUri(Style.OUTDOORS));
mapboxMap.setStyle(new Style.Builder().fromUri(Style.getPredefinedStyle("Outdoor")));
}
return true;
}
@@ -47,7 +47,7 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC
@Override
public void onMapReady(@NonNull final MapboxMap map) {
mapboxMap = map;
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"));
mapboxMap.setMinZoomPreference(3);
mapboxMap.setMaxZoomPreference(5);
mapboxMap.addOnMapClickListener(clickListener);

View File

@@ -63,7 +63,7 @@ public class ScrollByActivity extends AppCompatActivity implements OnMapReadyCal
@Override
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
mapboxMap.setStyle(Style.DARK);
mapboxMap.setStyle(Style.getPredefinedStyle("Pastel"));
UiSettings uiSettings = mapboxMap.getUiSettings();
uiSettings.setLogoEnabled(false);

View File

@@ -41,7 +41,7 @@ public class CustomLayerActivity extends AppCompatActivity {
mapView.getMapAsync(map -> {
mapboxMap = map;
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(39.91448, -243.60947), 10));
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> initFab());
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), style -> initFab());
});
}

View File

@@ -30,7 +30,7 @@ public class DeviceIndependentTestActivity extends AppCompatActivity implements
@Override
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"));
}
public MapboxMap getMapboxMap() {

View File

@@ -26,7 +26,7 @@ class PixelTestActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(map: MapboxMap) {
mapboxMap = map
mapboxMap.setStyle(Style.MAPBOX_STREETS)
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"))
}
public override fun onResume() {

View File

@@ -43,7 +43,7 @@ public class QueryRenderedFeaturesBoxCountActivity extends AppCompatActivity {
mapView.getMapAsync(mapboxMap -> {
QueryRenderedFeaturesBoxCountActivity.this.mapboxMap = mapboxMap;
mapboxMap.setStyle(new Style.Builder().fromUri(Style.MAPBOX_STREETS));
mapboxMap.setStyle(new Style.Builder().fromUri(Style.getPredefinedStyle("Streets")));
selectionBox.setOnClickListener(view -> {
// Query

View File

@@ -76,7 +76,7 @@ public class QueryRenderedFeaturesBoxHighlightActivity extends AppCompatActivity
});
mapboxMap.setStyle(new Style.Builder()
.fromUri(Style.MAPBOX_STREETS)
.fromUri(Style.getPredefinedStyle("Streets"))
.withSource(source)
.withLayer(layer)
);

View File

@@ -71,7 +71,7 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity {
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), style -> {
QueryRenderedFeaturesPropertiesActivity.this.mapboxMap = mapboxMap;
// Add custom window adapter

View File

@@ -45,7 +45,7 @@ public class QuerySourceFeaturesActivity extends AppCompatActivity {
mapView.getMapAsync(map -> {
this.mapboxMap = map;
mapboxMap.getStyle(this::initStyle);
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"));
});
}

View File

@@ -43,7 +43,7 @@ class FragmentBackStackActivity : AppCompatActivity() {
}
private fun initMap(mapboxMap: MapboxMap) {
mapboxMap.setStyle(Style.SATELLITE) {
mapboxMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid")) {
mapboxMap.setPadding(300, 300, 300, 300)
}
}

View File

@@ -77,7 +77,7 @@ public class MapFragmentActivity extends AppCompatActivity implements MapFragmen
@Override
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
mapboxMap.setStyle(Style.OUTDOORS);
mapboxMap.setStyle(Style.getPredefinedStyle("Outdoor"));
}
@Override

View File

@@ -20,10 +20,10 @@ public class MultiMapActivity extends AppCompatActivity {
setContentView(R.layout.activity_multi_map);
FragmentManager fragmentManager = getSupportFragmentManager();
initFragmentStyle(fragmentManager, R.id.map1, Style.MAPBOX_STREETS);
initFragmentStyle(fragmentManager, R.id.map2, Style.LIGHT);
initFragmentStyle(fragmentManager, R.id.map3, Style.SATELLITE_STREETS);
initFragmentStyle(fragmentManager, R.id.map4, Style.DARK);
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"));
}
private void initFragmentStyle(FragmentManager fragmentManager, int fragmentId, String styleId) {

View File

@@ -110,7 +110,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.MAPBOX_STREETS) }
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.getPredefinedStyle("Streets")) }
return fragment
}
1 -> {
@@ -119,7 +119,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.DARK) }
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.getPredefinedStyle("Pastel")) }
return fragment
}
3 -> {
@@ -128,7 +128,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.SATELLITE) }
fragment.getMapAsync { mapboxMap -> mapboxMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid")) }
return fragment
}
5 -> {

View File

@@ -78,7 +78,7 @@ public class SupportMapFragmentActivity extends AppCompatActivity implements Map
@Override
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
mapboxMap.setStyle(Style.SATELLITE);
mapboxMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid"));
}
@Override

View File

@@ -88,12 +88,11 @@ fun SupportMapFragment.getMapAsync(index: Int) {
this.getMapAsync {
it.setStyle(
when (index) {
0 -> Style.MAPBOX_STREETS
1 -> Style.DARK
2 -> Style.SATELLITE
3 -> Style.LIGHT
4 -> Style.TRAFFIC_NIGHT
else -> Style.MAPBOX_STREETS
0 -> Style.getPredefinedStyle("Streets")
1 -> Style.getPredefinedStyle("Pastel")
2 -> Style.getPredefinedStyle("Satellite Hybrid")
3 -> Style.getPredefinedStyle("Bright")
else -> Style.getPredefinedStyle("Streets")
}
)
}

View File

@@ -41,7 +41,7 @@ public class PrintActivity extends AppCompatActivity implements MapboxMap.Snapsh
private void initMap(MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"));
}
@Override

View File

@@ -40,7 +40,7 @@ class SnapshotActivity : AppCompatActivity(), OnMapReadyCallback {
override fun onMapReady(map: MapboxMap) {
mapboxMap = map
mapboxMap.setStyle(Style.Builder().fromUri(Style.OUTDOORS)) { mapView.addOnDidFinishRenderingFrameListener(idleListener) }
mapboxMap.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Outdoor"))) { mapView.addOnDidFinishRenderingFrameListener(idleListener) }
}
override fun onStart() {

View File

@@ -72,7 +72,7 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
map.setStyle(Style.MAPBOX_STREETS);
map.setStyle(Style.getPredefinedStyle("Streets"));
// Add info window adapter
addCustomInfoWindowAdapter(mapboxMap);

View File

@@ -65,7 +65,7 @@ public class InfoWindowActivity extends AppCompatActivity
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), style -> {
addMarkers();
addInfoWindowListeners();
});

View File

@@ -36,7 +36,7 @@ public class InfoWindowAdapterActivity extends AppCompatActivity {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;
map.setStyle(Style.MAPBOX_STREETS, style -> {
map.setStyle(Style.getPredefinedStyle("Streets"), style -> {
addMarkers();
addCustomInfoWindowAdapter();
});

View File

@@ -62,7 +62,7 @@ public class BasicLocationPulsingCircleActivity extends AppCompatActivity implem
public void onMapReady(@NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), style -> {
locationComponent = mapboxMap.getLocationComponent();
LocationComponentOptions locationComponentOptions =

View File

@@ -58,7 +58,7 @@ public class CustomizedLocationPulsingCircleActivity extends AppCompatActivity i
private static final String SAVED_STATE_LOCATION = "saved_state_location";
private static final String SAVED_STATE_LOCATION_CIRCLE_PULSE_COLOR = "saved_state_color";
private static final String SAVED_STATE_LOCATION_CIRCLE_PULSE_DURATION = "saved_state_duration";
private static final String LAYER_BELOW_ID = "waterway-label";
private static final String LAYER_BELOW_ID = "poi_transit";
private Location lastLocation;
private MapView mapView;
@@ -113,7 +113,7 @@ public class CustomizedLocationPulsingCircleActivity extends AppCompatActivity i
public void onMapReady(@NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), style -> {
locationComponent = mapboxMap.getLocationComponent();
LocationComponentOptions locationComponentOptions =

View File

@@ -70,7 +70,7 @@ public class LocationComponentActivationActivity extends AppCompatActivity imple
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.DARK,
mapboxMap.setStyle(Style.getPredefinedStyle("Bright"),
style -> activateLocationComponent(style));
}

View File

@@ -103,7 +103,7 @@ class LocationFragmentActivity : AppCompatActivity() {
mapView.onCreate(savedInstanceState)
mapView.getMapAsync {
mapboxMap = it
it.setStyle(Style.MAPBOX_STREETS) { style ->
it.setStyle(Style.getPredefinedStyle("Streets")) { style ->
val component = mapboxMap.locationComponent
component.activateLocationComponent(

View File

@@ -129,7 +129,7 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
public void onMapReady(@NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), style -> {
locationComponent = mapboxMap.getLocationComponent();
locationComponent.activateLocationComponent(
LocationComponentActivationOptions
@@ -240,7 +240,9 @@ public class LocationModesActivity extends AppCompatActivity implements OnMapRea
}
mapboxMap.getStyle(style -> {
String styleUrl = Style.DARK.equals(style.getUri()) ? Style.LIGHT : Style.DARK;
String styleUrl = Style.getPredefinedStyle("Bright").equals(style.getUri())
? Style.getPredefinedStyle("Bright")
: Style.getPredefinedStyle("Pastel");
mapboxMap.setStyle(new Style.Builder().fromUri(styleUrl));
});
}

View File

@@ -110,7 +110,7 @@ public class ManualLocationUpdatesActivity extends AppCompatActivity implements
@SuppressLint("MissingPermission")
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
mapboxMap.setStyle(new Style.Builder().fromUri(Style.MAPBOX_STREETS), style -> {
mapboxMap.setStyle(new Style.Builder().fromUri(Style.getPredefinedStyle("Streets")), style -> {
locationComponent = mapboxMap.getLocationComponent();
locationComponent.activateLocationComponent(

View File

@@ -15,11 +15,11 @@ import timber.log.Timber;
public class Utils {
private static final String[] STYLES = new String[] {
Style.MAPBOX_STREETS,
Style.OUTDOORS,
Style.LIGHT,
Style.DARK,
Style.SATELLITE_STREETS
Style.getPredefinedStyle("Streets"),
Style.getPredefinedStyle("Outdoor"),
Style.getPredefinedStyle("Bright"),
Style.getPredefinedStyle("Pastel"),
Style.getPredefinedStyle("Satellite Hybrid")
};
private static int index;

View File

@@ -120,12 +120,12 @@ public class BottomSheetActivity extends AppCompatActivity {
public static class MainMapFragment extends Fragment implements OnMapReadyCallback {
private static final String[] STYLES = new String[] {
Style.MAPBOX_STREETS,
Style.SATELLITE_STREETS,
Style.LIGHT,
Style.DARK,
Style.SATELLITE,
Style.OUTDOORS
Style.getPredefinedStyle("Streets"),
Style.getPredefinedStyle("Satellite Hybrid"),
Style.getPredefinedStyle("Bright"),
Style.getPredefinedStyle("Pastel"),
Style.getPredefinedStyle("Satellite Hybrid"),
Style.getPredefinedStyle("Outdoor")
};
private MapView map;
@@ -236,7 +236,7 @@ public class BottomSheetActivity extends AppCompatActivity {
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.760545, -122.436055), 15));
mapboxMap.setStyle(Style.LIGHT);
mapboxMap.setStyle(Style.getPredefinedStyle("Bright"));
}
@Override

View File

@@ -47,15 +47,12 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
private boolean isReportFps = true;
private static final String[] STYLES = new String[] {
Style.MAPBOX_STREETS,
Style.OUTDOORS,
Style.LIGHT,
Style.DARK,
Style.SATELLITE,
Style.SATELLITE_STREETS,
Style.TRAFFIC_DAY,
Style.TRAFFIC_NIGHT
};
Style.getPredefinedStyle("Streets"),
Style.getPredefinedStyle("Outdoor"),
Style.getPredefinedStyle("Bright"),
Style.getPredefinedStyle("Pastel"),
Style.getPredefinedStyle("Satellite Hybrid"),
Style.getPredefinedStyle("Satellite Hybrid") };
private TextView fpsView;
@Override

View File

@@ -77,7 +77,7 @@ public class DoubleMapActivity extends AppCompatActivity {
// MapView large
mapView = new MapView(view.getContext(), MapFragmentUtils.resolveArgs(view.getContext(), getArguments()));
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(Style.MAPBOX_STREETS));
mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(Style.getPredefinedStyle("Streets")));
((ViewGroup) view.findViewById(R.id.container)).addView(mapView, 0);
// MapView mini
@@ -90,7 +90,7 @@ public class DoubleMapActivity extends AppCompatActivity {
.build()
)
);
mapboxMap.setStyle(new Style.Builder().fromUri(Style.LIGHT));
mapboxMap.setStyle(new Style.Builder().fromUri(Style.getPredefinedStyle("Bright")));
UiSettings uiSettings = mapboxMap.getUiSettings();
uiSettings.setAllGesturesEnabled(false);

View File

@@ -47,7 +47,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.MAPBOX_STREETS), "four", "five", MapItem(Style.DARK), "seven", "eight", "nine", "ten",
"one", "two", "three", MapItem(Style.getPredefinedStyle("Streets")), "four", "five", MapItem(Style.getPredefinedStyle("Pastel")), "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen",
"nineteen", "twenty", "twenty-one"
)

View File

@@ -57,7 +57,7 @@ public class LatLngBoundsForCameraActivity extends AppCompatActivity implements
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.SATELLITE_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid"));
mapboxMap.setMinZoomPreference(2);
mapboxMap.getUiSettings().setFlingVelocityAnimationEnabled(false);
showCrosshair();

View File

@@ -26,7 +26,7 @@ public class LocalGlyphActivity extends AppCompatActivity {
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"));
// Set initial position to Suzhou
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(
new CameraPosition.Builder()

View File

@@ -40,7 +40,7 @@ public class MapChangeActivity extends AppCompatActivity {
mapView.addOnWillStartRenderingMapListener(() -> Timber.v("OnWillStartRenderingMap"));
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"));
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(55.754020, 37.620948), 12), 9000);
});

View File

@@ -59,7 +59,7 @@ public class MapInDialogActivity extends AppCompatActivity {
super.onViewCreated(view, savedInstanceState);
mapView = view.findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(Style.OUTDOORS));
mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(Style.getPredefinedStyle("Outdoor")));
}
@Override

View File

@@ -35,7 +35,7 @@ public class MapPaddingActivity extends AppCompatActivity {
mapView.getMapAsync(mapboxMap -> {
MapPaddingActivity.this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"));
int paddingLeft = (int) getResources().getDimension(R.dimen.map_padding_left);
int paddingBottom = (int) getResources().getDimension(R.dimen.map_padding_bottom);

View File

@@ -22,7 +22,7 @@ class OverlayMapActivity : AppCompatActivity() {
mapView.onCreate(savedInstanceState)
parentView.addView(OverlayView(this))
mapView.getMapAsync {
it.setStyle(Style.MAPBOX_STREETS)
it.setStyle(Style.getPredefinedStyle("Streets"))
}
}

View File

@@ -24,7 +24,7 @@ public class SimpleMapActivity extends AppCompatActivity {
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(
new Style.Builder().fromUri(Style.MAPBOX_STREETS)
new Style.Builder().fromUri(Style.getPredefinedStyle("Streets"))
));
}

View File

@@ -32,7 +32,7 @@ public class VisibilityChangeActivity extends AppCompatActivity {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;
mapboxMap.setStyle(Style.MAPBOX_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"));
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(55.754020, 37.620948), 12), 9000);
});

View File

@@ -248,10 +248,10 @@ class DownloadRegionActivity : AppCompatActivity(), OfflineRegion.OfflineRegionO
private fun initSpinner() {
val styles = ArrayList<String>()
styles.add(Style.MAPBOX_STREETS)
styles.add(Style.DARK)
styles.add(Style.LIGHT)
styles.add(Style.OUTDOORS)
styles.add(Style.getPredefinedStyle("Streets"))
styles.add(Style.getPredefinedStyle("Pastel"))
styles.add(Style.getPredefinedStyle("Bright"))
styles.add(Style.getPredefinedStyle("Outdoor"))
val spinnerArrayAdapter = ArrayAdapter(this, android.R.layout.simple_spinner_item, styles)
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
spinnerStyleUrl.adapter = spinnerArrayAdapter

View File

@@ -17,7 +17,7 @@ class MergeOfflineRegionsActivity : AppCompatActivity() {
companion object {
private const val LOG_TAG = "Mbgl-MergeOfflineRegionsActivity"
private const val TEST_DB_FILE_NAME = "offline_test.db"
private const val TEST_STYLE = Style.SATELLITE
private var TEST_STYLE = Style.getPredefinedStyle("Satellite Hybrid")
}
private val onFileCopiedListener = object : FileUtils.OnFileCopiedFromAssetsListener {

View File

@@ -45,7 +45,7 @@ public class OfflineActivity extends AppCompatActivity
public static final String JSON_FIELD_REGION_NAME = "FIELD_REGION_NAME";
// Style URL
public static final String STYLE_URL = Style.MAPBOX_STREETS;
public static final String STYLE_URL = Style.getPredefinedStyle("Streets");
/*
* UI elements

View File

@@ -94,7 +94,7 @@ public class MapSnapshotterActivity extends AppCompatActivity {
private void startSnapShot(final int row, final int column) {
// Optionally the style
Style.Builder builder = new Style.Builder()
.fromUri((column + row) % 2 == 0 ? Style.MAPBOX_STREETS : Style.DARK);
.fromUri((column + row) % 2 == 0 ? Style.getPredefinedStyle("Streets") : Style.getPredefinedStyle("Pastel"));
// Define the dimensions
MapSnapshotter.Options options = new MapSnapshotter.Options(
@@ -129,8 +129,10 @@ public class MapSnapshotterActivity extends AppCompatActivity {
}
if (row == 0 && column == 0) {
// Add a source
Source source = new RasterSource("my-raster-source", "mapbox://mapbox.satellite", 512);
builder.withLayerAbove(new RasterLayer("satellite-layer", "my-raster-source"), "country-label");
Source source = new RasterSource("my-raster-source", "maptiler://sources/satellite", 512);
builder.withLayerAbove(
new RasterLayer("satellite-layer", "my-raster-source"),
(column + row) % 2 == 0 ? "country_1" : "country_label");
builder.withSource(source);
} else if (row == 0 && column == 2) {

View File

@@ -53,7 +53,7 @@ public class MapSnapshotterBitMapOverlayActivity extends AppCompatActivity
getApplicationContext(),
new MapSnapshotter
.Options(Math.min(container.getMeasuredWidth(), 1024), Math.min(container.getMeasuredHeight(), 1024))
.withStyleBuilder(new Style.Builder().fromUri(Style.OUTDOORS))
.withStyleBuilder(new Style.Builder().fromUri(Style.getPredefinedStyle("Outdoor")))
.withCameraPosition(new CameraPosition.Builder().target(new LatLng(52.090737, 5.121420)).zoom(15).build())
);
mapSnapshotter.start(MapSnapshotterBitMapOverlayActivity.this);

View File

@@ -65,9 +65,9 @@ public class MapSnapshotterHeatMapActivity extends AppCompatActivity implements
Timber.i("Starting snapshot");
Style.Builder builder = new Style.Builder().fromUri(Style.OUTDOORS)
Style.Builder builder = new Style.Builder().fromUri(Style.getPredefinedStyle("Outdoor"))
.withSource(getEarthquakeSource())
.withLayerAbove(getHeatmapLayer(), "waterway-label");
.withLayerAbove(getHeatmapLayer(), "water_intermittent");
mapSnapshotter = new MapSnapshotter(
getApplicationContext(),

View File

@@ -81,17 +81,17 @@ public class MapSnapshotterReuseActivity extends AppCompatActivity implements Ma
public String getRandomStyle() {
switch (random.nextInt(5)) {
case 0:
return Style.DARK;
return Style.getPredefinedStyle("Pastel");
case 1:
return Style.LIGHT;
return Style.getPredefinedStyle("Bright");
case 2:
return Style.MAPBOX_STREETS;
return Style.getPredefinedStyle("Streets");
case 3:
return Style.OUTDOORS;
return Style.getPredefinedStyle("Outdoor");
case 4:
return Style.SATELLITE_STREETS;
return Style.getPredefinedStyle("Satellite Hybrid");
default:
return Style.TRAFFIC_DAY;
return Style.getPredefinedStyle("Streets");
}
}

View File

@@ -48,7 +48,7 @@ public class UrlTransformActivity extends AppCompatActivity {
mapView.getMapAsync(map -> {
Timber.i("Map loaded");
map.setStyle(Style.MAPBOX_STREETS);
map.setStyle(Style.getPredefinedStyle("Streets"));
});
}

View File

@@ -58,7 +58,7 @@ public class AnimatedImageSourceActivity extends AppCompatActivity implements On
final ImageSource imageSource = new ImageSource(ID_IMAGE_SOURCE, quad, R.drawable.southeast_radar_0);
final RasterLayer layer = new RasterLayer(ID_IMAGE_LAYER, ID_IMAGE_SOURCE);
map.setStyle(new Style.Builder()
.fromUri(Style.MAPBOX_STREETS)
.fromUri(Style.getPredefinedStyle("Streets"))
.withSource(imageSource)
.withLayer(layer), style -> {
runnable = new RefreshImageRunnable(imageSource, handler);

View File

@@ -48,7 +48,7 @@ public class BuildingFillExtrusionActivity extends AppCompatActivity {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), style -> {
setupBuildings(style);
setupLight();
});

View File

@@ -75,7 +75,7 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;
mapboxMap.setStyle(Style.SATELLITE_STREETS);
mapboxMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid"));
mapView.addOnDidFinishLoadingStyleListener(() -> {
Style style = mapboxMap.getStyle();
addBusStopSource(style);
@@ -101,7 +101,7 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
circleColor(Color.parseColor("#FF9800")),
circleRadius(2.0f)
);
style.addLayerBelow(layer, "waterway-label");
style.addLayerBelow(layer, "water_intermittent");
}
private void initFloatingActionButtons() {
@@ -276,12 +276,12 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
private static class Data {
private static final String[] STYLES = new String[] {
Style.MAPBOX_STREETS,
Style.OUTDOORS,
Style.LIGHT,
Style.DARK,
Style.SATELLITE,
Style.SATELLITE_STREETS
Style.getPredefinedStyle("Streets"),
Style.getPredefinedStyle("Outdoor"),
Style.getPredefinedStyle("Bright"),
Style.getPredefinedStyle("Pastel"),
Style.getPredefinedStyle("Satellite Hybrid"),
Style.getPredefinedStyle("Satellite Hybrid")
};
}
}

View File

@@ -112,7 +112,7 @@ class CollectionUpdateOnStyleChange : AppCompatActivity(), OnMapReadyCallback, S
companion object {
private val STYLES = arrayOf(Style.MAPBOX_STREETS, Style.OUTDOORS, Style.LIGHT, Style.DARK, Style.SATELLITE, Style.SATELLITE_STREETS, Style.TRAFFIC_DAY, Style.TRAFFIC_NIGHT)
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 featureCollection: FeatureCollection

View File

@@ -49,7 +49,7 @@ public class CustomSpriteActivity extends AppCompatActivity {
mapView.getMapAsync(map -> {
mapboxMap = map;
map.setStyle(Style.MAPBOX_STREETS, style -> {
map.setStyle(Style.getPredefinedStyle("Streets"), style -> {
final FloatingActionButton fab = findViewById(R.id.fab);
fab.setColorFilter(ContextCompat.getColor(CustomSpriteActivity.this, R.color.primary));
fab.setOnClickListener(new View.OnClickListener() {
@@ -81,7 +81,7 @@ public class CustomSpriteActivity extends AppCompatActivity {
);
// lets add a circle below labels!
mapboxMap.getStyle().addLayerBelow(layer, "waterway-label");
mapboxMap.getStyle().addLayerBelow(layer, "water_intermittent");
fab.setImageResource(R.drawable.ic_directions_car_black);
} else {

View File

@@ -65,7 +65,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
// Store for later
mapboxMap = map;
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), style -> {
// Add a parks layer
addParksLayer();

View File

@@ -52,10 +52,10 @@ class DistanceExpressionActivity : AppCompatActivity() {
val center = Point.fromLngLat(lon, lat)
val circle = TurfTransformation.circle(center, 150.0, TurfConstants.UNIT_METRES)
// Setup style with additional layers,
// using Style.MAPBOX_STREETS as a base style
// using Streets as a base style
mapboxMap.setStyle(
Style.Builder()
.fromUri(Style.MAPBOX_STREETS)
.fromUri(Style.getPredefinedStyle("Streets"))
.withSources(
GeoJsonSource(
POINT_ID,
@@ -73,7 +73,7 @@ class DistanceExpressionActivity : AppCompatActivity() {
)
) { style ->
// Show only POI labels inside circle radius using distance expression
val symbolLayer = style.getLayer("poi-label") as SymbolLayer
val symbolLayer = style.getLayer("poi_z16") as SymbolLayer
symbolLayer.setFilter(
lt(
distance(
@@ -84,9 +84,9 @@ class DistanceExpressionActivity : AppCompatActivity() {
)
// Hide other types of labels to highlight POI labels
(style.getLayer("road-label") as SymbolLayer).setProperties(visibility(NONE))
(style.getLayer("transit-label") as SymbolLayer).setProperties(visibility(NONE))
(style.getLayer("road-number-shield") as SymbolLayer).setProperties(visibility(NONE))
(style.getLayer("road_label") as SymbolLayer).setProperties(visibility(NONE))
(style.getLayer("airport-label-major") as SymbolLayer).setProperties(visibility(NONE))
(style.getLayer("poi_transit") as SymbolLayer).setProperties(visibility(NONE))
}
}

View File

@@ -72,7 +72,7 @@ class DraggableMarkerActivity : AppCompatActivity() {
mapboxMap.setStyle(
Style.Builder()
.fromUri(Style.MAPBOX_STREETS)
.fromUri(Style.getPredefinedStyle("Streets"))
.withImage(markerImageId, IconFactory.getInstance(this).defaultMarker().bitmap)
.withSource(source)
.withLayer(layer)

View File

@@ -39,7 +39,7 @@ public class FillExtrusionActivity extends AppCompatActivity {
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> {
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), style -> {
List<List<Point>> lngLats = Collections.singletonList(
Arrays.asList(
Point.fromLngLat(5.12112557888031, 52.09071040847704),

View File

@@ -26,7 +26,7 @@ public class FillExtrusionStyleTestActivity extends AppCompatActivity {
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap ->
mapboxMap.setStyle(new Style.Builder().fromUri(Style.MAPBOX_STREETS),
mapboxMap.setStyle(new Style.Builder().fromUri(Style.getPredefinedStyle("Streets")),
style -> FillExtrusionStyleTestActivity.this.mapboxMap = mapboxMap
)
);

View File

@@ -94,7 +94,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity {
try {
mapboxMap.setStyle(new Style.Builder()
.fromUri(Style.LIGHT)
.fromUri(Style.getPredefinedStyle("Bright"))
.withSource(clusterSource = createClusterSource())
.withLayer(createSymbolLayer())
.withLayer(createClusterLevelLayer(0, clusterLayers))

View File

@@ -109,7 +109,7 @@ public class GridSourceActivity extends AppCompatActivity implements OnMapReadyC
);
map.setStyle(new Style.Builder()
.fromUri(Style.MAPBOX_STREETS)
.fromUri(Style.getPredefinedStyle("Streets"))
.withLayer(layer)
.withSource(source)
);

View File

@@ -62,9 +62,9 @@ public class HeatmapLayerActivity extends AppCompatActivity {
try {
mapboxMap.setStyle(new Style.Builder()
.fromUri(Style.DARK)
.fromUri(Style.getPredefinedStyle("Pastel"))
.withSource(createEarthquakeSource())
.withLayerAbove(createHeatmapLayer(), "waterway-label")
.withLayerAbove(createHeatmapLayer(), "country_label")
.withLayerBelow(createCircleLayer(), HEATMAP_LAYER_ID)
);
} catch (URISyntaxException exception) {

View File

@@ -16,10 +16,10 @@ import com.mapbox.mapboxsdk.testapp.R;
*/
public class HillshadeLayerActivity extends AppCompatActivity {
private static final String LAYER_ID = "hillshade-layer";
private static final String LAYER_BELOW_ID = "waterway-river-canal";
private static final String SOURCE_ID = "hillshade-source";
private static final String SOURCE_URL = "mapbox://mapbox.terrain-rgb";
private static final String LAYER_ID = "hillshade";
private static final String LAYER_BELOW_ID = "water_intermittent";
private static final String SOURCE_ID = "terrain-rgb";
private static final String SOURCE_URL = "maptiler://sources/terrain-rgb";
private MapView mapView;
private MapboxMap mapboxMap;
@@ -37,7 +37,7 @@ public class HillshadeLayerActivity extends AppCompatActivity {
RasterDemSource rasterDemSource = new RasterDemSource(SOURCE_ID, SOURCE_URL);
HillshadeLayer hillshadeLayer = new HillshadeLayer(LAYER_ID, SOURCE_ID);
mapboxMap.setStyle(new Style.Builder()
.fromUri(Style.MAPBOX_STREETS)
.fromUri(Style.getPredefinedStyle("Streets"))
.withLayerBelow(hillshadeLayer, LAYER_BELOW_ID)
.withSource(rasterDemSource)
);

View File

@@ -48,7 +48,7 @@ public class ImageInLabelActivity extends AppCompatActivity implements OnMapRead
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), style -> {
Bitmap us = BitmapUtils.getBitmapFromDrawable(getResources().getDrawable(R.drawable.ic_us));
Bitmap android = BitmapUtils.getBitmapFromDrawable(getResources().getDrawable(R.drawable.ic_android));

View File

@@ -53,7 +53,7 @@ public class RealTimeGeoJsonActivity extends AppCompatActivity implements OnMapR
public void onMapReady(@NonNull final MapboxMap map) {
mapboxMap = map;
mapboxMap.setStyle(Style.MAPBOX_STREETS, new Style.OnStyleLoaded() {
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), new Style.OnStyleLoaded() {
@Override
public void onStyleLoaded(@NonNull Style style) {
// add source

View File

@@ -121,11 +121,11 @@ public class RuntimeStyleActivity extends AppCompatActivity {
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(52.379189, 4.899431), 1));
mapboxMap.setStyle(
new Style.Builder()
.fromUri(Style.MAPBOX_STREETS)
.fromUri(Style.getPredefinedStyle("Streets"))
// set custom transition
.withTransition(new TransitionOptions(250, 50)), style -> {
styleLoaded = true;
SymbolLayer laber = (SymbolLayer) style.getLayer("country-label");
SymbolLayer laber = (SymbolLayer) style.getLayer("country_1");
laber.setProperties(
textOpacity(switchCase(within(polygon), literal(1.0f), literal(0.5f)))
);
@@ -437,7 +437,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
private void addTerrainLayer() {
// Add a source
Source source = new VectorSource("my-terrain-source", "mapbox://mapbox.mapbox-terrain-v2");
Source source = new VectorSource("my-terrain-source", "maptiler://sources/hillshades");
mapboxMap.getStyle().addSource(source);
LineLayer layer = new LineLayer("terrainLayer", "my-terrain-source");
@@ -483,7 +483,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
private void addSatelliteLayer() {
// Add a source
Source source = new RasterSource("my-raster-source", "mapbox://mapbox.satellite", 512);
Source source = new RasterSource("my-raster-source", "maptiler://sources/satellite", 512);
mapboxMap.getStyle().addSource(source);
// Add a layer
@@ -515,6 +515,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
}
private void addCustomTileSource() {
//TODO: migrate
// Add a source
TileSet tileSet = new TileSet("2.1.0", "https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt");
tileSet.setMinZoom(0);

View File

@@ -36,19 +36,19 @@ public class RuntimeStyleTimingTestActivity extends AppCompatActivity {
mapView.getMapAsync(mapboxMap -> {
RuntimeStyleTimingTestActivity.this.mapboxMap = mapboxMap;
CircleLayer museumsLayer = new CircleLayer("museums", "museums_source");
museumsLayer.setSourceLayer("museum-cusco");
museumsLayer.setProperties(
CircleLayer parksLayer = new CircleLayer("parks", "parks_source");
parksLayer.setSourceLayer("parks");
parksLayer.setProperties(
visibility(VISIBLE),
circleRadius(8f),
circleColor(Color.argb(1, 55, 148, 179))
);
VectorSource museums = new VectorSource("museums_source", "mapbox://mapbox.2opop9hr");
VectorSource parks = new VectorSource("parks_source", "maptiler://sources/7ac429c7-c96e-46dd-8c3e-13d48988986a");
mapboxMap.setStyle(new Style.Builder()
.fromUri(Style.MAPBOX_STREETS)
.withSource(museums)
.withLayer(museumsLayer));
.fromUri(Style.getPredefinedStyle("Streets"))
.withSource(parks)
.withLayer(parksLayer));
});
}

View File

@@ -62,7 +62,7 @@ public class StretchableImageActivity extends AppCompatActivity implements OnMap
@Override
public void onMapReady(@NonNull MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), style -> {
Bitmap popup = BitmapUtils.getBitmapFromDrawable(getResources().getDrawable(R.drawable.popup));
Bitmap popupDebug = BitmapUtils.getBitmapFromDrawable(getResources().getDrawable(R.drawable.popup_debug));

View File

@@ -40,7 +40,7 @@ public class StyleFileActivity extends AppCompatActivity {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;
mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), style -> {
FloatingActionButton fab = findViewById(R.id.fab_file);
fab.setColorFilter(ContextCompat.getColor(StyleFileActivity.this, R.color.primary));
fab.setOnClickListener(view -> new CreateStyleFileTask(view.getContext(), mapboxMap).execute());

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