Skip to content

Commit

Permalink
brb
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Jan 22, 2021
1 parent a2ad867 commit 4263239
Show file tree
Hide file tree
Showing 64 changed files with 1,332 additions and 1,045 deletions.
15 changes: 8 additions & 7 deletions app/src/androidTest/java/com/mapbox/maps/testapp/BaseMapTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,16 @@ abstract class BaseMapTest {

protected open fun loadMap() {
val latch = CountDownLatch(1)
rule.scenario.onActivity {
it.runOnUiThread {
rule.scenario.onActivity { activity ->
activity.runOnUiThread {
mapboxMap = mapView.getMapboxMap()
mapboxMap.loadStyleUri(
Style.MAPBOX_STREETS
) { style ->
this@BaseMapTest.style = style
latch.countDown()
}
Style.MAPBOX_STREETS,
{
this@BaseMapTest.style = it
latch.countDown()
}
)
mapView.onStart()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,37 +53,43 @@ class LocationComponentTest {
fun modelSourceTest() {
rule.scenario.onActivity { activity ->
activity.runOnUiThread {
mapboxMap.loadStyleUri(Style.MAPBOX_STREETS) {
val locationComponent = mapView.getLocationPlugin()
locationComponent.activateLocationComponent(
LocationComponentActivationOptions
.builder(activity, it)
.useDefaultLocationEngine(false)
.locationModelLayerOptions(LocationModelLayerOptions("asset://race_car_model.gltf"))
.build()
)
locationComponent.enabled = true
locationComponent.randomLocationUpdates()
Handler().postDelayed(
{
locationComponent.randomLocationUpdates()
mapboxMap.loadStyleUri(Style.DARK) {
mapboxMap.loadStyleUri(
Style.MAPBOX_STREETS,
{
val locationComponent = mapView.getLocationPlugin()
locationComponent.activateLocationComponent(
LocationComponentActivationOptions
.builder(activity, it)
.useDefaultLocationEngine(false)
.locationModelLayerOptions(LocationModelLayerOptions("asset://race_car_model.gltf"))
.build()
)
locationComponent.enabled = true
locationComponent.randomLocationUpdates()
Handler().postDelayed(
{
locationComponent.randomLocationUpdates()
Handler().postDelayed(
mapboxMap.loadStyleUri(
Style.DARK,
{
locationComponent.randomLocationUpdates()
countDownLatch.countDown()
},
500
Handler().postDelayed(
{
locationComponent.randomLocationUpdates()
countDownLatch.countDown()
},
500
)
locationComponent.randomLocationUpdates()
}
)
locationComponent.randomLocationUpdates()
}
locationComponent.randomLocationUpdates()
},
500
)
locationComponent.randomLocationUpdates()
}
},
500
)
locationComponent.randomLocationUpdates()
}
)
}
}
countDownLatch = CountDownLatch(1)
Expand All @@ -96,36 +102,42 @@ class LocationComponentTest {
fun locationLayerTest() {
rule.scenario.onActivity { activity ->
activity.runOnUiThread {
mapboxMap.loadStyleUri(Style.MAPBOX_STREETS) {
val locationComponent = mapView.getLocationPlugin()
locationComponent.activateLocationComponent(
LocationComponentActivationOptions
.builder(activity, it)
.useDefaultLocationEngine(false)
.build()
)
locationComponent.enabled = true
locationComponent.randomLocationUpdates()
Handler().postDelayed(
{
locationComponent.randomLocationUpdates()
mapboxMap.loadStyleUri(Style.DARK) {
mapboxMap.loadStyleUri(
Style.MAPBOX_STREETS,
{
val locationComponent = mapView.getLocationPlugin()
locationComponent.activateLocationComponent(
LocationComponentActivationOptions
.builder(activity, it)
.useDefaultLocationEngine(false)
.build()
)
locationComponent.enabled = true
locationComponent.randomLocationUpdates()
Handler().postDelayed(
{
locationComponent.randomLocationUpdates()
Handler().postDelayed(
mapboxMap.loadStyleUri(
Style.DARK,
{
locationComponent.randomLocationUpdates()
countDownLatch.countDown()
},
500
Handler().postDelayed(
{
locationComponent.randomLocationUpdates()
countDownLatch.countDown()
},
500
)
locationComponent.randomLocationUpdates()
}
)
locationComponent.randomLocationUpdates()
}
locationComponent.randomLocationUpdates()
},
500
)
locationComponent.randomLocationUpdates()
}
},
500
)
locationComponent.randomLocationUpdates()
}
)
}
}
countDownLatch = CountDownLatch(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ class AnimateMapCameraActivity : AppCompatActivity(), OnMapClickListener {
setContentView(R.layout.activity_camera_animate)
mapboxMap = mapView.getMapboxMap()
mapboxMap.loadStyleUri(
Style.MAPBOX_STREETS
) { // Toast instructing user to tap on the map
Toast.makeText(
this@AnimateMapCameraActivity,
getString(R.string.tap_on_map_instruction),
Toast.LENGTH_LONG
).show()
mapboxMap.addOnMapClickListener(this@AnimateMapCameraActivity)
}
Style.MAPBOX_STREETS,
{
// Toast instructing user to tap on the map
Toast.makeText(
this@AnimateMapCameraActivity,
getString(R.string.tap_on_map_instruction),
Toast.LENGTH_LONG
).show()
mapboxMap.addOnMapClickListener(this@AnimateMapCameraActivity)
}
)
}

override fun onMapClick(point: Point): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ class BasicLocationPulsingCircleActivity : AppCompatActivity() {

private fun onMapReady() {
mapboxMap.loadStyleUri(
Style.MAPBOX_STREETS
) {
initLocationComponent(it)
lastStyleUri = it.styleURI
}
Style.MAPBOX_STREETS,
{
initLocationComponent(it)
lastStyleUri = it.styleURI
}
)
}

private fun initLocationComponent(style: Style) {
Expand Down Expand Up @@ -131,8 +132,8 @@ class BasicLocationPulsingCircleActivity : AppCompatActivity() {
private fun loadNewStyle() {
val styleUrl = if (lastStyleUri == Style.DARK) Style.LIGHT else Style.DARK
mapboxMap.loadStyleUri(
styleUrl
) { lastStyleUri = styleUrl }
styleUrl, { lastStyleUri = styleUrl }
)
}

override fun onRequestPermissionsResult(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,39 +35,40 @@ class CircleLayerClusteringActivity : AppCompatActivity() {
val mapboxMap = mapView.getMapboxMap()

mapboxMap.loadStyleUri(
Style.LIGHT
) {
// Disable any type of fading transition when icons collide on the map. This enhances the visual
// look of the data clustering together and breaking apart.
it.styleTransition = TransitionOptions.Builder()
.duration(0)
.delay(0)
.enablePlacementTransitions(false)
.build()

mapboxMap.flyTo(
CameraOptions.Builder()
.center(Point.fromLngLat(-79.045, 12.099))
.zoom(3.0)
Style.LIGHT,
{
// Disable any type of fading transition when icons collide on the map. This enhances the visual
// look of the data clustering together and breaking apart.
it.styleTransition = TransitionOptions.Builder()
.duration(0)
.delay(0)
.enablePlacementTransitions(false)
.build()
)

addClusteredGeoJsonSource(it)
mapboxMap.flyTo(
CameraOptions.Builder()
.center(Point.fromLngLat(-79.045, 12.099))
.zoom(3.0)
.build()
)

val drawable = ContextCompat.getDrawable(
this@CircleLayerClusteringActivity,
R.drawable.ic_cross
)
BitmapUtils.getBitmapFromDrawable(drawable)?.let { bitmap ->
it.addImage(CROSS_ICON_ID, bitmap, true)
}
addClusteredGeoJsonSource(it)

Toast.makeText(
this@CircleLayerClusteringActivity,
R.string.zoom_map_in_and_out_instruction,
Toast.LENGTH_SHORT
).show()
}
val drawable = ContextCompat.getDrawable(
this@CircleLayerClusteringActivity,
R.drawable.ic_cross
)
BitmapUtils.getBitmapFromDrawable(drawable)?.let { bitmap ->
it.addImage(CROSS_ICON_ID, bitmap, true)
}

Toast.makeText(
this@CircleLayerClusteringActivity,
R.string.zoom_map_in_and_out_instruction,
Toast.LENGTH_SHORT
).show()
}
)
}

private fun addClusteredGeoJsonSource(style: Style) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ class FillExtrusionActivity : AppCompatActivity() {
)

mapboxMap.loadStyleUri(
Style.MAPBOX_STREETS
) { style ->
setupBuildings(style)
setupLight(style)
}
Style.MAPBOX_STREETS,
{
setupBuildings(it)
setupLight(it)
}
)
}

private fun setupBuildings(style: Style) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class HeatmapLayerActivity : AppCompatActivity() {

mapboxMap = mapView.getMapboxMap()
mapboxMap.loadStyleUri(
styleUri = Style.DARK
) { style -> addRuntimeLayers(style) }
styleUri = Style.DARK, { style -> addRuntimeLayers(style) }
)
}

private fun addRuntimeLayers(style: Style) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import com.mapbox.maps.extension.style.sources.addSource
import com.mapbox.maps.extension.style.sources.generated.GeoJsonSource
import com.mapbox.maps.extension.style.sources.generated.geoJsonSource
import com.mapbox.maps.extension.style.sources.getSource
import com.mapbox.maps.listener.OnCameraChangeListener
import com.mapbox.maps.plugin.animation.MapAnimationOptions.Companion.mapAnimationOptions
import com.mapbox.maps.plugin.animation.flyTo
import com.mapbox.maps.plugin.attribution.getAttributionPlugin
import com.mapbox.maps.plugin.compass.getCompassPlugin
import com.mapbox.maps.plugin.delegates.listeners.OnCameraChangeListener
import com.mapbox.maps.plugin.gestures.getGesturesPlugin
import com.mapbox.maps.plugin.logo.getLogoPlugin
import com.mapbox.maps.plugin.scalebar.getScaleBarPlugin
Expand All @@ -41,8 +41,8 @@ class InsetMapActivity : AppCompatActivity(), OnCameraChangeListener {
mainMapView = findViewById(R.id.mapView)
mainMapboxMap = mainMapView.getMapboxMap()
mainMapboxMap.loadStyleUri(
styleUri = STYLE_URL
) { mainMapboxMap.addOnCameraChangeListener(this@InsetMapActivity) }
styleUri = STYLE_URL, { mainMapboxMap.addOnCameraChangeListener(this@InsetMapActivity) }
)

var insetMapFragment: MapFragment? =
supportFragmentManager.findFragmentByTag(INSET_FRAGMENT_TAG) as? MapFragment
Expand All @@ -54,24 +54,25 @@ class InsetMapActivity : AppCompatActivity(), OnCameraChangeListener {
insetMapFragment.getMapAsync {
insetMapboxMap = it
insetMapboxMap.loadStyleUri(
styleUri = STYLE_URL
) { style ->
val source = geoJsonSource(BOUNDS_LINE_LAYER_SOURCE_ID) {
feature(Feature.fromGeometry(LineString.fromLngLats(getRectanglePoints())))
}
style.addSource(source)

// The layer properties for our line. This is where we make the line dotted, set the color, etc.
val layer = lineLayer(BOUNDS_LINE_LAYER_LAYER_ID, BOUNDS_LINE_LAYER_SOURCE_ID) {
lineCap(LineCap.ROUND)
lineJoin(LineJoin.ROUND)
lineWidth(3.0)
lineColor(Color.YELLOW)
visibility(Visibility.VISIBLE)
styleUri = STYLE_URL,
{ style ->
val source = geoJsonSource(BOUNDS_LINE_LAYER_SOURCE_ID) {
feature(Feature.fromGeometry(LineString.fromLngLats(getRectanglePoints())))
}
style.addSource(source)

// The layer properties for our line. This is where we make the line dotted, set the color, etc.
val layer = lineLayer(BOUNDS_LINE_LAYER_LAYER_ID, BOUNDS_LINE_LAYER_SOURCE_ID) {
lineCap(LineCap.ROUND)
lineJoin(LineJoin.ROUND)
lineWidth(3.0)
lineColor(Color.YELLOW)
visibility(Visibility.VISIBLE)
}
style.addLayer(layer)
updateInsetMapLineLayerBounds(style)
}
style.addLayer(layer)
updateInsetMapLineLayerBounds(style)
}
)
insetMapFragment.getMapView()?.apply {
getLogoPlugin().enabled = false
getScaleBarPlugin().enabled = false
Expand Down Expand Up @@ -100,7 +101,7 @@ class InsetMapActivity : AppCompatActivity(), OnCameraChangeListener {
}
}

override fun onCameraChange(changeEvent: CameraChange, mode: CameraChangeMode) {
override fun onCameraChange(changeEvent: CameraChange) {
if (changeEvent != CameraChange.CAMERA_WILL_CHANGE) {
val mainCameraPosition = mainMapboxMap.getCameraOptions(null)
val insetCameraPosition = CameraOptions.Builder()
Expand Down
Loading

0 comments on commit 4263239

Please sign in to comment.