Use Kotlins Null safety to cleanup code (#667)
This commit is contained in:
@@ -22,8 +22,8 @@ import java.util.ArrayList
|
||||
*
|
||||
*/
|
||||
class PolygonActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
private var mapView: MapView? = null
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapView: MapView
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var polygon: Polygon? = null
|
||||
private var fullAlpha = true
|
||||
private var polygonIsVisible = true
|
||||
@@ -47,9 +47,9 @@ class PolygonActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
// create map
|
||||
mapView = MapView(this, options)
|
||||
mapView!!.id = R.id.mapView
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync(this)
|
||||
mapView.id = R.id.mapView
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(this)
|
||||
setContentView(mapView)
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class PolygonActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
polygon = mapboxMap!!.addPolygon(
|
||||
polygon = mapboxMap.addPolygon(
|
||||
PolygonOptions()
|
||||
.addAll(Config.STAR_SHAPE_POINTS)
|
||||
.fillColor(Config.BLUE_COLOR)
|
||||
@@ -72,37 +72,37 @@ class PolygonActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
@@ -50,7 +50,7 @@ class CameraAnimationTypeActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
private var cameraState = false
|
||||
private val cameraIdleListener = OnCameraIdleListener {
|
||||
if (mapboxMap != null) {
|
||||
Timber.w(mapboxMap!!.cameraPosition.toString())
|
||||
Timber.w(mapboxMap.cameraPosition.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,10 +64,10 @@ class CameraAnimationTypeActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
override fun onMapReady(map: MapboxMap) {
|
||||
mapboxMap = map
|
||||
mapboxMap!!.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Streets")))
|
||||
mapboxMap!!.uiSettings.isAttributionEnabled = false
|
||||
mapboxMap!!.uiSettings.isLogoEnabled = false
|
||||
mapboxMap!!.addOnCameraIdleListener(cameraIdleListener)
|
||||
mapboxMap.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Streets")))
|
||||
mapboxMap.uiSettings.isAttributionEnabled = false
|
||||
mapboxMap.uiSettings.isLogoEnabled = false
|
||||
mapboxMap.addOnCameraIdleListener(cameraIdleListener)
|
||||
|
||||
// handle move button clicks
|
||||
val moveButton = findViewById<View>(R.id.cameraMoveButton)
|
||||
@@ -79,7 +79,7 @@ class CameraAnimationTypeActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
.tilt(30.0)
|
||||
.tilt(0.0)
|
||||
.build()
|
||||
mapboxMap!!.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
|
||||
}
|
||||
|
||||
// handle ease button clicks
|
||||
@@ -92,7 +92,7 @@ class CameraAnimationTypeActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
.bearing(180.0)
|
||||
.tilt(30.0)
|
||||
.build()
|
||||
mapboxMap!!.easeCamera(
|
||||
mapboxMap.easeCamera(
|
||||
CameraUpdateFactory.newCameraPosition(cameraPosition),
|
||||
7500,
|
||||
callback
|
||||
@@ -104,7 +104,7 @@ class CameraAnimationTypeActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
animateButton?.setOnClickListener { view: View? ->
|
||||
val cameraPosition =
|
||||
CameraPosition.Builder().target(nextLatLng).bearing(270.0).tilt(20.0).build()
|
||||
mapboxMap!!.animateCamera(
|
||||
mapboxMap.animateCamera(
|
||||
CameraUpdateFactory.newCameraPosition(cameraPosition),
|
||||
7500,
|
||||
callback
|
||||
@@ -120,40 +120,40 @@ class CameraAnimationTypeActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap!!.removeOnCameraIdleListener(cameraIdleListener)
|
||||
mapboxMap.removeOnCameraIdleListener(cameraIdleListener)
|
||||
}
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -204,7 +204,7 @@ class CameraPositionActivity : FragmentActivity(), OnMapReadyCallback, View.OnCl
|
||||
|
||||
val cameraPosition = CameraPosition.Builder().target(LatLng(latitude, longitude)).zoom(zoom).bearing(bearing).tilt(tilt).build()
|
||||
|
||||
mapboxMap!!.animateCamera(
|
||||
mapboxMap?.animateCamera(
|
||||
CameraUpdateFactory.newCameraPosition(cameraPosition),
|
||||
5000,
|
||||
object : CancelableCallback {
|
||||
|
||||
@@ -57,52 +57,52 @@ class GestureDetectorActivity : AppCompatActivity() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
gestureAlertsAdapter!!.cancelUpdates()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
private fun initializeMap() {
|
||||
gesturesManager = mapboxMap!!.gesturesManager
|
||||
gesturesManager = mapboxMap.gesturesManager
|
||||
val layoutParams = recyclerView!!.layoutParams as RelativeLayout.LayoutParams
|
||||
layoutParams.height = (mapView!!.height / 1.75).toInt()
|
||||
layoutParams.width = mapView!!.width / 3
|
||||
layoutParams.height = (mapView.height / 1.75).toInt()
|
||||
layoutParams.width = mapView.width / 3
|
||||
recyclerView!!.layoutParams = layoutParams
|
||||
attachListeners()
|
||||
fixedFocalPointEnabled(mapboxMap!!.uiSettings.focalPoint != null)
|
||||
fixedFocalPointEnabled(mapboxMap.uiSettings.focalPoint != null)
|
||||
}
|
||||
|
||||
fun attachListeners() {
|
||||
mapboxMap!!.addOnMoveListener(
|
||||
mapboxMap.addOnMoveListener(
|
||||
object : OnMoveListener {
|
||||
override fun onMoveBegin(detector: MoveGestureDetector) {
|
||||
gestureAlertsAdapter!!.addAlert(
|
||||
@@ -124,7 +124,7 @@ class GestureDetectorActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
)
|
||||
mapboxMap!!.addOnRotateListener(
|
||||
mapboxMap.addOnRotateListener(
|
||||
object : OnRotateListener {
|
||||
override fun onRotateBegin(detector: RotateGestureDetector) {
|
||||
gestureAlertsAdapter!!.addAlert(
|
||||
@@ -146,7 +146,7 @@ class GestureDetectorActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
)
|
||||
mapboxMap!!.addOnScaleListener(
|
||||
mapboxMap.addOnScaleListener(
|
||||
object : OnScaleListener {
|
||||
override fun onScaleBegin(detector: StandardScaleGestureDetector) {
|
||||
gestureAlertsAdapter!!.addAlert(
|
||||
@@ -194,7 +194,7 @@ class GestureDetectorActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
)
|
||||
mapboxMap!!.addOnShoveListener(
|
||||
mapboxMap.addOnShoveListener(
|
||||
object : OnShoveListener {
|
||||
override fun onShoveBegin(detector: ShoveGestureDetector) {
|
||||
gestureAlertsAdapter!!.addAlert(
|
||||
@@ -223,7 +223,7 @@ class GestureDetectorActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
val uiSettings = mapboxMap!!.uiSettings
|
||||
val uiSettings = mapboxMap.uiSettings
|
||||
when (item.itemId) {
|
||||
R.id.menu_gesture_focus_point -> {
|
||||
fixedFocalPointEnabled(focalPointLatLng == null)
|
||||
@@ -274,8 +274,8 @@ class GestureDetectorActivity : AppCompatActivity() {
|
||||
private fun fixedFocalPointEnabled(enabled: Boolean) {
|
||||
if (enabled) {
|
||||
focalPointLatLng = LatLng(51.50325, -0.12968)
|
||||
marker = mapboxMap!!.addMarker(MarkerOptions().position(focalPointLatLng))
|
||||
mapboxMap!!.easeCamera(
|
||||
marker = mapboxMap.addMarker(MarkerOptions().position(focalPointLatLng))
|
||||
mapboxMap.easeCamera(
|
||||
CameraUpdateFactory.newLatLngZoom(focalPointLatLng!!, 16.0),
|
||||
object : CancelableCallback {
|
||||
override fun onCancel() {
|
||||
@@ -289,18 +289,18 @@ class GestureDetectorActivity : AppCompatActivity() {
|
||||
)
|
||||
} else {
|
||||
if (marker != null) {
|
||||
mapboxMap!!.removeMarker(marker!!)
|
||||
mapboxMap.removeMarker(marker!!)
|
||||
marker = null
|
||||
}
|
||||
focalPointLatLng = null
|
||||
mapboxMap!!.uiSettings.focalPoint = null
|
||||
mapboxMap.uiSettings.focalPoint = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun recalculateFocalPoint() {
|
||||
if (focalPointLatLng != null) {
|
||||
mapboxMap!!.uiSettings.focalPoint =
|
||||
mapboxMap!!.projection.toScreenLocation(focalPointLatLng!!)
|
||||
mapboxMap.uiSettings.focalPoint =
|
||||
mapboxMap.projection.toScreenLocation(focalPointLatLng!!)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,13 @@ class ManualZoomActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_manual_zoom)
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync { mapboxMap: MapboxMap ->
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { mapboxMap: MapboxMap ->
|
||||
this@ManualZoomActivity.mapboxMap = mapboxMap
|
||||
mapboxMap.setStyle(
|
||||
Style.Builder().fromUri(Style.getPredefinedStyle("Satellite Hybrid"))
|
||||
)
|
||||
val uiSettings = this@ManualZoomActivity.mapboxMap!!.uiSettings
|
||||
val uiSettings = this@ManualZoomActivity.mapboxMap.uiSettings
|
||||
uiSettings.setAllGesturesEnabled(false)
|
||||
}
|
||||
}
|
||||
@@ -43,24 +43,24 @@ class ManualZoomActivity : AppCompatActivity() {
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.action_zoom_in -> {
|
||||
mapboxMap!!.animateCamera(CameraUpdateFactory.zoomIn())
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomIn())
|
||||
true
|
||||
}
|
||||
R.id.action_zoom_out -> {
|
||||
mapboxMap!!.animateCamera(CameraUpdateFactory.zoomOut())
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomOut())
|
||||
true
|
||||
}
|
||||
R.id.action_zoom_by -> {
|
||||
mapboxMap!!.animateCamera(CameraUpdateFactory.zoomBy(2.0))
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomBy(2.0))
|
||||
true
|
||||
}
|
||||
R.id.action_zoom_to -> {
|
||||
mapboxMap!!.animateCamera(CameraUpdateFactory.zoomTo(2.0))
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(2.0))
|
||||
true
|
||||
}
|
||||
R.id.action_zoom_to_point -> {
|
||||
val view = window.decorView
|
||||
mapboxMap!!.animateCamera(
|
||||
mapboxMap.animateCamera(
|
||||
CameraUpdateFactory.zoomBy(
|
||||
1.0,
|
||||
Point(view.measuredWidth / 4, view.measuredHeight / 4)
|
||||
@@ -74,36 +74,36 @@ class ManualZoomActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ class MaxMinZoomActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private val clickListener = OnMapClickListener {
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap!!.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Outdoor")))
|
||||
mapboxMap.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Outdoor")))
|
||||
}
|
||||
true
|
||||
}
|
||||
@@ -35,47 +35,47 @@ class MaxMinZoomActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
override fun onMapReady(map: MapboxMap) {
|
||||
mapboxMap = map
|
||||
mapboxMap!!.setStyle(Style.getPredefinedStyle("Streets"))
|
||||
mapboxMap!!.setMinZoomPreference(3.0)
|
||||
mapboxMap!!.setMaxZoomPreference(5.0)
|
||||
mapboxMap!!.addOnMapClickListener(clickListener)
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"))
|
||||
mapboxMap.setMinZoomPreference(3.0)
|
||||
mapboxMap.setMaxZoomPreference(5.0)
|
||||
mapboxMap.addOnMapClickListener(clickListener)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap!!.removeOnMapClickListener(clickListener)
|
||||
mapboxMap.removeOnMapClickListener(clickListener)
|
||||
}
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,14 +53,14 @@ class ScrollByActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
override fun onMapReady(map: MapboxMap) {
|
||||
mapboxMap = map
|
||||
mapboxMap!!.setStyle(Style.getPredefinedStyle("Pastel"))
|
||||
val uiSettings = mapboxMap!!.uiSettings
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Pastel"))
|
||||
val uiSettings = mapboxMap.uiSettings
|
||||
uiSettings.isLogoEnabled = false
|
||||
uiSettings.isAttributionEnabled = false
|
||||
val fab = findViewById<FloatingActionButton>(R.id.fab)
|
||||
fab.setColorFilter(ContextCompat.getColor(this@ScrollByActivity, R.color.primary))
|
||||
fab.setOnClickListener { view: View? ->
|
||||
mapboxMap!!.scrollBy(
|
||||
mapboxMap.scrollBy(
|
||||
(seekBarX!!.progress * MULTIPLIER_PER_PIXEL).toFloat(),
|
||||
(seekBarY!!.progress * MULTIPLIER_PER_PIXEL).toFloat()
|
||||
)
|
||||
@@ -69,37 +69,37 @@ class ScrollByActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
@@ -37,13 +37,13 @@ class CustomLayerActivity : AppCompatActivity() {
|
||||
mapView.getMapAsync(
|
||||
OnMapReadyCallback { map: MapboxMap? ->
|
||||
mapboxMap = map!!
|
||||
mapboxMap!!.moveCamera(
|
||||
mapboxMap.moveCamera(
|
||||
CameraUpdateFactory.newLatLngZoom(
|
||||
LatLng(39.91448, -243.60947),
|
||||
10.0
|
||||
)
|
||||
)
|
||||
mapboxMap!!.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? -> initFab() }
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? -> initFab() }
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class CustomLayerActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun swapCustomLayer() {
|
||||
val style = mapboxMap!!.style
|
||||
val style = mapboxMap.style
|
||||
if (customLayer != null) {
|
||||
style!!.removeLayer(customLayer!!)
|
||||
customLayer = null
|
||||
@@ -78,43 +78,43 @@ class CustomLayerActivity : AppCompatActivity() {
|
||||
|
||||
private fun updateLayer() {
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap!!.triggerRepaint()
|
||||
mapboxMap.triggerRepaint()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
||||
@@ -19,8 +19,8 @@ import timber.log.Timber
|
||||
* Test activity showcasing using the query rendered features API to count features in a rectangle.
|
||||
*/
|
||||
class QueryRenderedFeaturesBoxCountActivity : AppCompatActivity() {
|
||||
var mapView: MapView? = null
|
||||
var mapboxMap: MapboxMap? = null
|
||||
lateinit var mapView: MapView
|
||||
lateinit var mapboxMap: MapboxMap
|
||||
private set
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -30,14 +30,14 @@ class QueryRenderedFeaturesBoxCountActivity : AppCompatActivity() {
|
||||
|
||||
// Initialize map as normal
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync { mapboxMap: MapboxMap ->
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { mapboxMap: MapboxMap ->
|
||||
this@QueryRenderedFeaturesBoxCountActivity.mapboxMap = mapboxMap
|
||||
mapboxMap.setStyle(Style.Builder().fromUri(Style.getPredefinedStyle("Streets")))
|
||||
selectionBox.setOnClickListener { view: View? ->
|
||||
// Query
|
||||
val top = selectionBox.top - mapView!!.top
|
||||
val left = selectionBox.left - mapView!!.left
|
||||
val top = selectionBox.top - mapView.top
|
||||
val left = selectionBox.left - mapView.left
|
||||
val box = RectF(
|
||||
left.toFloat(),
|
||||
top.toFloat(),
|
||||
@@ -88,41 +88,41 @@ class QueryRenderedFeaturesBoxCountActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
if (mapboxMap != null) {
|
||||
// Regression test for #14394
|
||||
mapboxMap!!.queryRenderedFeatures(PointF(0F, 0F))
|
||||
mapboxMap.queryRenderedFeatures(PointF(0F, 0F))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
@@ -22,8 +22,8 @@ import timber.log.Timber
|
||||
* Demo's query rendered features
|
||||
*/
|
||||
class QueryRenderedFeaturesBoxHighlightActivity : AppCompatActivity() {
|
||||
var mapView: MapView? = null
|
||||
var mapboxMap: MapboxMap? = null
|
||||
lateinit var mapView: MapView
|
||||
lateinit var mapboxMap: MapboxMap
|
||||
private set
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -33,8 +33,8 @@ class QueryRenderedFeaturesBoxHighlightActivity : AppCompatActivity() {
|
||||
|
||||
// Initialize map as normal
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync { mapboxMap: MapboxMap ->
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { mapboxMap: MapboxMap ->
|
||||
this@QueryRenderedFeaturesBoxHighlightActivity.mapboxMap = mapboxMap
|
||||
|
||||
// Add layer / source
|
||||
@@ -43,8 +43,8 @@ class QueryRenderedFeaturesBoxHighlightActivity : AppCompatActivity() {
|
||||
.withProperties(PropertyFactory.fillColor(Color.RED))
|
||||
selectionBox.setOnClickListener { view: View? ->
|
||||
// Query
|
||||
val top = selectionBox.top - mapView!!.top
|
||||
val left = selectionBox.left - mapView!!.left
|
||||
val top = selectionBox.top - mapView.top
|
||||
val left = selectionBox.left - mapView.left
|
||||
val box = RectF(
|
||||
left.toFloat(),
|
||||
top.toFloat(),
|
||||
@@ -79,36 +79,36 @@ class QueryRenderedFeaturesBoxHighlightActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ import java.io.IOException
|
||||
* Test activity showcasing using the query rendered features API to count Symbols in a rectangle.
|
||||
*/
|
||||
class QueryRenderedFeaturesBoxSymbolCountActivity : AppCompatActivity() {
|
||||
var mapView: MapView? = null
|
||||
var mapboxMap: MapboxMap? = null
|
||||
lateinit var mapView: MapView
|
||||
lateinit var mapboxMap: MapboxMap
|
||||
private set
|
||||
private lateinit var toast: Toast
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -34,12 +34,12 @@ class QueryRenderedFeaturesBoxSymbolCountActivity : AppCompatActivity() {
|
||||
|
||||
// Initialize map as normal
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync { mapboxMap: MapboxMap ->
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { mapboxMap: MapboxMap ->
|
||||
this@QueryRenderedFeaturesBoxSymbolCountActivity.mapboxMap = mapboxMap
|
||||
try {
|
||||
val testPoints = ResourceUtils.readRawResource(
|
||||
mapView!!.context,
|
||||
mapView.context,
|
||||
R.raw.test_points_utrecht
|
||||
)
|
||||
val markerImage =
|
||||
@@ -68,8 +68,8 @@ class QueryRenderedFeaturesBoxSymbolCountActivity : AppCompatActivity() {
|
||||
}
|
||||
selectionBox.setOnClickListener { view: View? ->
|
||||
// Query
|
||||
val top = selectionBox.top - mapView!!.top
|
||||
val left = selectionBox.left - mapView!!.left
|
||||
val top = selectionBox.top - mapView.top
|
||||
val left = selectionBox.left - mapView.left
|
||||
val box = RectF(
|
||||
left.toFloat(),
|
||||
top.toFloat(),
|
||||
@@ -95,36 +95,36 @@ class QueryRenderedFeaturesBoxSymbolCountActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ import timber.log.Timber
|
||||
* Test activity showcasing using the query rendered features API to query feature properties on Map click.
|
||||
*/
|
||||
class QueryRenderedFeaturesPropertiesActivity : AppCompatActivity() {
|
||||
var mapView: MapView? = null
|
||||
var mapboxMap: MapboxMap? = null
|
||||
lateinit var mapView: MapView
|
||||
lateinit var mapboxMap: MapboxMap
|
||||
private set
|
||||
private var marker: Marker? = null
|
||||
private val mapClickListener = OnMapClickListener { point ->
|
||||
val density = resources.displayMetrics.density
|
||||
val pixel = mapboxMap!!.projection.toScreenLocation(point)
|
||||
val pixel = mapboxMap.projection.toScreenLocation(point)
|
||||
Timber.i(
|
||||
"Requesting features for %sx%s (%sx%s adjusted for density)",
|
||||
pixel.x,
|
||||
@@ -37,19 +37,19 @@ class QueryRenderedFeaturesPropertiesActivity : AppCompatActivity() {
|
||||
pixel.x / density,
|
||||
pixel.y / density
|
||||
)
|
||||
val features = mapboxMap!!.queryRenderedFeatures(pixel)
|
||||
val features = mapboxMap.queryRenderedFeatures(pixel)
|
||||
|
||||
// Debug output
|
||||
debugOutput(features)
|
||||
|
||||
// Remove any previous markers
|
||||
if (marker != null) {
|
||||
mapboxMap!!.removeMarker(marker!!)
|
||||
mapboxMap.removeMarker(marker!!)
|
||||
}
|
||||
|
||||
// Add a marker on the clicked point
|
||||
marker = mapboxMap!!.addMarker(CustomMarkerOptions().position(point)!!.features(features))
|
||||
mapboxMap!!.selectMarker(marker!!)
|
||||
marker = mapboxMap.addMarker(CustomMarkerOptions().position(point)!!.features(features))
|
||||
mapboxMap.selectMarker(marker!!)
|
||||
true
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ class QueryRenderedFeaturesPropertiesActivity : AppCompatActivity() {
|
||||
|
||||
// Initialize map as normal
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync { mapboxMap: MapboxMap ->
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { mapboxMap: MapboxMap ->
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? ->
|
||||
this@QueryRenderedFeaturesPropertiesActivity.mapboxMap = mapboxMap
|
||||
|
||||
@@ -135,40 +135,40 @@ class QueryRenderedFeaturesPropertiesActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap!!.removeOnMapClickListener(mapClickListener)
|
||||
mapboxMap.removeOnMapClickListener(mapClickListener)
|
||||
}
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
private class CustomMarker internal constructor(
|
||||
|
||||
@@ -23,19 +23,21 @@ import com.mapbox.mapboxsdk.testapp.R
|
||||
* Test activity showcasing using the query source features API to query feature counts
|
||||
*/
|
||||
class QuerySourceFeaturesActivity : AppCompatActivity() {
|
||||
var mapView: MapView? = null
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
lateinit var mapView: MapView
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_query_source_features)
|
||||
|
||||
// Initialize map as normal
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync { map: MapboxMap? ->
|
||||
mapboxMap = map
|
||||
mapboxMap!!.getStyle { style: Style -> initStyle(style) }
|
||||
mapboxMap!!.setStyle(Style.getPredefinedStyle("Streets"))
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { map: MapboxMap? ->
|
||||
if (map != null) {
|
||||
mapboxMap = map
|
||||
}
|
||||
mapboxMap.getStyle { style: Style -> initStyle(style) }
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +63,7 @@ class QuerySourceFeaturesActivity : AppCompatActivity() {
|
||||
style.addLayer(layer)
|
||||
|
||||
// Add a click listener
|
||||
mapboxMap!!.addOnMapClickListener { point: LatLng? ->
|
||||
mapboxMap.addOnMapClickListener { point: LatLng? ->
|
||||
// Query
|
||||
val features = source.querySourceFeatures(
|
||||
Expression.eq(
|
||||
@@ -95,36 +97,36 @@ class QuerySourceFeaturesActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ class MapFragmentActivity :
|
||||
OnMapViewReadyCallback,
|
||||
OnMapReadyCallback,
|
||||
OnDidFinishRenderingFrameListener {
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private var mapView: MapView? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var mapView: MapView
|
||||
private var initialCameraAnimation = true
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -62,24 +62,24 @@ class MapFragmentActivity :
|
||||
|
||||
override fun onMapViewReady(map: MapView) {
|
||||
mapView = map
|
||||
mapView!!.addOnDidFinishRenderingFrameListener(this)
|
||||
mapView.addOnDidFinishRenderingFrameListener(this)
|
||||
}
|
||||
|
||||
override fun onMapReady(map: MapboxMap) {
|
||||
mapboxMap = map
|
||||
mapboxMap!!.setStyle(Style.getPredefinedStyle("Outdoor"))
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Outdoor"))
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (mapView != null) {
|
||||
mapView!!.removeOnDidFinishRenderingFrameListener(this)
|
||||
mapView.removeOnDidFinishRenderingFrameListener(this)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDidFinishRenderingFrame(fully: Boolean) {
|
||||
if (initialCameraAnimation && fully && mapboxMap != null) {
|
||||
mapboxMap!!.animateCamera(
|
||||
mapboxMap.animateCamera(
|
||||
CameraUpdateFactory.newCameraPosition(CameraPosition.Builder().tilt(45.0).build()),
|
||||
5000
|
||||
)
|
||||
|
||||
@@ -22,8 +22,8 @@ class SupportMapFragmentActivity :
|
||||
OnMapViewReadyCallback,
|
||||
OnMapReadyCallback,
|
||||
OnDidFinishRenderingFrameListener {
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private var mapView: MapView? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var mapView: MapView
|
||||
private var initialCameraAnimation = true
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -62,22 +62,22 @@ class SupportMapFragmentActivity :
|
||||
|
||||
override fun onMapViewReady(map: MapView) {
|
||||
mapView = map
|
||||
mapView!!.addOnDidFinishRenderingFrameListener(this)
|
||||
mapView.addOnDidFinishRenderingFrameListener(this)
|
||||
}
|
||||
|
||||
override fun onMapReady(map: MapboxMap) {
|
||||
mapboxMap = map
|
||||
mapboxMap!!.setStyle(Style.getPredefinedStyle("Satellite Hybrid"))
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid"))
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.removeOnDidFinishRenderingFrameListener(this)
|
||||
mapView.removeOnDidFinishRenderingFrameListener(this)
|
||||
}
|
||||
|
||||
override fun onDidFinishRenderingFrame(fully: Boolean) {
|
||||
if (initialCameraAnimation && fully && mapboxMap != null) {
|
||||
mapboxMap!!.animateCamera(
|
||||
mapboxMap.animateCamera(
|
||||
CameraUpdateFactory.newCameraPosition(CameraPosition.Builder().tilt(45.0).build()),
|
||||
5000
|
||||
)
|
||||
|
||||
@@ -25,8 +25,8 @@ class PrintActivity : AppCompatActivity(), MapboxMap.SnapshotReadyCallback {
|
||||
mapView.getMapAsync(OnMapReadyCallback { mapboxMap: MapboxMap -> initMap(mapboxMap) })
|
||||
val fab = findViewById<View>(R.id.fab)
|
||||
fab?.setOnClickListener { view: View? ->
|
||||
if (mapboxMap != null && mapboxMap!!.style != null) {
|
||||
mapboxMap!!.snapshot(this@PrintActivity)
|
||||
if (mapboxMap != null && mapboxMap.style != null) {
|
||||
mapboxMap.snapshot(this@PrintActivity)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,36 +44,36 @@ class PrintActivity : AppCompatActivity(), MapboxMap.SnapshotReadyCallback {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,17 +64,17 @@ class DynamicInfoWindowAdapterActivity : AppCompatActivity(), OnMapReadyCallback
|
||||
addCustomInfoWindowAdapter(mapboxMap!!)
|
||||
|
||||
// Keep info windows open on click
|
||||
mapboxMap!!.uiSettings.isDeselectMarkersOnTap = false
|
||||
mapboxMap.uiSettings.isDeselectMarkersOnTap = false
|
||||
|
||||
// Add a marker
|
||||
marker = addMarker(mapboxMap!!)
|
||||
mapboxMap!!.selectMarker(marker!!)
|
||||
mapboxMap.selectMarker(marker!!)
|
||||
|
||||
// On map click, change the info window contents
|
||||
mapboxMap!!.addOnMapClickListener(mapClickListener)
|
||||
mapboxMap.addOnMapClickListener(mapClickListener)
|
||||
|
||||
// Focus on Paris
|
||||
mapboxMap!!.animateCamera(CameraUpdateFactory.newLatLng(PARIS))
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(PARIS))
|
||||
}
|
||||
|
||||
private fun addMarker(mapboxMap: MapboxMap): Marker {
|
||||
@@ -105,40 +105,40 @@ class DynamicInfoWindowAdapterActivity : AppCompatActivity(), OnMapReadyCallback
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap!!.removeOnMapClickListener(mapClickListener)
|
||||
mapboxMap.removeOnMapClickListener(mapClickListener)
|
||||
}
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -33,18 +33,18 @@ class InfoWindowActivity :
|
||||
OnInfoWindowCloseListener,
|
||||
OnInfoWindowClickListener,
|
||||
OnInfoWindowLongClickListener {
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private var mapView: MapView? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var mapView: MapView
|
||||
private var customMarker: Marker? = null
|
||||
private val mapLongClickListener = OnMapLongClickListener { point ->
|
||||
if (customMarker != null) {
|
||||
// Remove previous added marker
|
||||
mapboxMap!!.removeAnnotation(customMarker!!)
|
||||
mapboxMap.removeAnnotation(customMarker!!)
|
||||
customMarker = null
|
||||
}
|
||||
|
||||
// Add marker on long click location with default marker image
|
||||
customMarker = mapboxMap!!.addMarker(
|
||||
customMarker = mapboxMap.addMarker(
|
||||
MarkerOptions()
|
||||
.title("Custom Marker")
|
||||
.snippet(
|
||||
@@ -60,8 +60,8 @@ class InfoWindowActivity :
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_infowindow)
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync(this)
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(this)
|
||||
}
|
||||
|
||||
override fun onMapReady(mapboxMap: MapboxMap) {
|
||||
@@ -73,25 +73,25 @@ class InfoWindowActivity :
|
||||
}
|
||||
|
||||
private fun addMarkers() {
|
||||
mapboxMap!!.addMarker(
|
||||
mapboxMap.addMarker(
|
||||
MarkerOptions()
|
||||
.title("Intersection")
|
||||
.snippet("H St NW with 15th St NW")
|
||||
.position(LatLng(38.9002073, -77.03364419))
|
||||
)
|
||||
mapboxMap!!.addMarker(
|
||||
mapboxMap.addMarker(
|
||||
MarkerOptions().title("Intersection")
|
||||
.snippet("E St NW with 17th St NW")
|
||||
.position(LatLng(38.8954236, -77.0394623))
|
||||
)
|
||||
mapboxMap!!.addMarker(
|
||||
mapboxMap.addMarker(
|
||||
MarkerOptions().title("The Ellipse").position(LatLng(38.89393, -77.03654))
|
||||
)
|
||||
mapboxMap!!.addMarker(MarkerOptions().position(LatLng(38.89596, -77.03434)))
|
||||
mapboxMap!!.addMarker(
|
||||
mapboxMap.addMarker(MarkerOptions().position(LatLng(38.89596, -77.03434)))
|
||||
mapboxMap.addMarker(
|
||||
MarkerOptions().snippet("Lafayette Square").position(LatLng(38.89949, -77.03656))
|
||||
)
|
||||
val marker = mapboxMap!!.addMarker(
|
||||
val marker = mapboxMap.addMarker(
|
||||
MarkerOptions()
|
||||
.title("White House")
|
||||
.snippet(
|
||||
@@ -103,23 +103,23 @@ class InfoWindowActivity :
|
||||
)
|
||||
|
||||
// open InfoWindow at startup
|
||||
mapboxMap!!.selectMarker(marker)
|
||||
mapboxMap.selectMarker(marker)
|
||||
}
|
||||
|
||||
private fun addInfoWindowListeners() {
|
||||
mapboxMap!!.onInfoWindowCloseListener = this
|
||||
mapboxMap!!.addOnMapLongClickListener(mapLongClickListener)
|
||||
mapboxMap!!.onInfoWindowClickListener = this
|
||||
mapboxMap!!.onInfoWindowLongClickListener = this
|
||||
mapboxMap.onInfoWindowCloseListener = this
|
||||
mapboxMap.addOnMapLongClickListener(mapLongClickListener)
|
||||
mapboxMap.onInfoWindowClickListener = this
|
||||
mapboxMap.onInfoWindowLongClickListener = this
|
||||
}
|
||||
|
||||
private fun toggleConcurrentInfoWindow(allowConcurrentInfoWindow: Boolean) {
|
||||
mapboxMap!!.deselectMarkers()
|
||||
mapboxMap!!.isAllowConcurrentMultipleOpenInfoWindows = allowConcurrentInfoWindow
|
||||
mapboxMap.deselectMarkers()
|
||||
mapboxMap.isAllowConcurrentMultipleOpenInfoWindows = allowConcurrentInfoWindow
|
||||
}
|
||||
|
||||
private fun toggleDeselectMarkersOnTap(deselectMarkersOnTap: Boolean) {
|
||||
mapboxMap!!.uiSettings.isDeselectMarkersOnTap = deselectMarkersOnTap
|
||||
mapboxMap.uiSettings.isDeselectMarkersOnTap = deselectMarkersOnTap
|
||||
}
|
||||
|
||||
override fun onInfoWindowClick(marker: Marker): Boolean {
|
||||
@@ -138,40 +138,40 @@ class InfoWindowActivity :
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap!!.removeOnMapLongClickListener(mapLongClickListener)
|
||||
mapboxMap.removeOnMapLongClickListener(mapLongClickListener)
|
||||
}
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
||||
@@ -40,10 +40,10 @@ class InfoWindowAdapterActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun addMarkers() {
|
||||
mapboxMap!!.addMarker(generateCityStateMarker("Andorra", 42.505777, 1.52529, "#F44336"))
|
||||
mapboxMap!!.addMarker(generateCityStateMarker("Luxembourg", 49.815273, 6.129583, "#3F51B5"))
|
||||
mapboxMap!!.addMarker(generateCityStateMarker("Monaco", 43.738418, 7.424616, "#673AB7"))
|
||||
mapboxMap!!.addMarker(
|
||||
mapboxMap.addMarker(generateCityStateMarker("Andorra", 42.505777, 1.52529, "#F44336"))
|
||||
mapboxMap.addMarker(generateCityStateMarker("Luxembourg", 49.815273, 6.129583, "#3F51B5"))
|
||||
mapboxMap.addMarker(generateCityStateMarker("Monaco", 43.738418, 7.424616, "#673AB7"))
|
||||
mapboxMap.addMarker(
|
||||
generateCityStateMarker(
|
||||
"Vatican City",
|
||||
41.902916,
|
||||
@@ -51,7 +51,7 @@ class InfoWindowAdapterActivity : AppCompatActivity() {
|
||||
"#009688"
|
||||
)
|
||||
)
|
||||
mapboxMap!!.addMarker(
|
||||
mapboxMap.addMarker(
|
||||
generateCityStateMarker(
|
||||
"San Marino",
|
||||
43.942360,
|
||||
@@ -59,7 +59,7 @@ class InfoWindowAdapterActivity : AppCompatActivity() {
|
||||
"#795548"
|
||||
)
|
||||
)
|
||||
mapboxMap!!.addMarker(
|
||||
mapboxMap.addMarker(
|
||||
generateCityStateMarker(
|
||||
"Liechtenstein",
|
||||
47.166000,
|
||||
@@ -86,7 +86,7 @@ class InfoWindowAdapterActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun addCustomInfoWindowAdapter() {
|
||||
mapboxMap!!.infoWindowAdapter = object : InfoWindowAdapter {
|
||||
mapboxMap.infoWindowAdapter = object : InfoWindowAdapter {
|
||||
private val tenDp = resources.getDimension(R.dimen.attr_margin).toInt()
|
||||
override fun getInfoWindow(marker: Marker): View? {
|
||||
val textView = TextView(this@InfoWindowAdapterActivity)
|
||||
@@ -103,36 +103,36 @@ class InfoWindowAdapterActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class BasicLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyCallba
|
||||
private lateinit var mapView: MapView
|
||||
private var permissionsManager: PermissionsManager? = null
|
||||
private var locationComponent: LocationComponent? = null
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_location_layer_basic_pulsing_circle)
|
||||
@@ -119,12 +119,12 @@ class BasicLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyCallba
|
||||
}
|
||||
|
||||
private fun loadNewStyle() {
|
||||
mapboxMap!!.setStyle(Style.Builder().fromUri(Utils.nextStyle()))
|
||||
mapboxMap.setStyle(Style.Builder().fromUri(Utils.nextStyle()))
|
||||
}
|
||||
|
||||
private fun checkPermissions() {
|
||||
if (PermissionsManager.areLocationPermissionsGranted(this)) {
|
||||
mapView!!.getMapAsync(this)
|
||||
mapView.getMapAsync(this)
|
||||
} else {
|
||||
permissionsManager = PermissionsManager(object : PermissionsListener {
|
||||
override fun onExplanationNeeded(permissionsToExplain: List<String>) {
|
||||
@@ -137,7 +137,7 @@ class BasicLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyCallba
|
||||
|
||||
override fun onPermissionResult(granted: Boolean) {
|
||||
if (granted) {
|
||||
mapView!!.getMapAsync(this@BasicLocationPulsingCircleActivity)
|
||||
mapView.getMapAsync(this@BasicLocationPulsingCircleActivity)
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
@@ -158,28 +158,28 @@ class BasicLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyCallba
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
if (locationComponent != null) {
|
||||
outState.putParcelable(SAVED_STATE_LOCATION, locationComponent!!.lastKnownLocation)
|
||||
}
|
||||
@@ -187,12 +187,12 @@ class BasicLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyCallba
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -38,7 +38,7 @@ class CustomizedLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyC
|
||||
private lateinit var pulsingCircleColorButton: Button
|
||||
private var permissionsManager: PermissionsManager? = null
|
||||
private var locationComponent: LocationComponent? = null
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var currentPulseDuration = 0f
|
||||
|
||||
//endregion
|
||||
@@ -124,7 +124,7 @@ class CustomizedLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyC
|
||||
newPulsingDuration: Float,
|
||||
newPulsingColor: Int
|
||||
) {
|
||||
mapboxMap!!.getStyle { style: Style? ->
|
||||
mapboxMap.getStyle { style: Style? ->
|
||||
locationComponent!!.applyStyle(
|
||||
buildLocationComponentOptions(
|
||||
newPulsingColor,
|
||||
@@ -197,12 +197,12 @@ class CustomizedLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyC
|
||||
}
|
||||
|
||||
private fun loadNewStyle() {
|
||||
mapboxMap!!.setStyle(Style.Builder().fromUri(Utils.nextStyle()))
|
||||
mapboxMap.setStyle(Style.Builder().fromUri(Utils.nextStyle()))
|
||||
}
|
||||
|
||||
private fun checkPermissions() {
|
||||
if (PermissionsManager.areLocationPermissionsGranted(this)) {
|
||||
mapView!!.getMapAsync(this)
|
||||
mapView.getMapAsync(this)
|
||||
} else {
|
||||
permissionsManager = PermissionsManager(object : PermissionsListener {
|
||||
override fun onExplanationNeeded(permissionsToExplain: List<String>) {
|
||||
@@ -215,7 +215,7 @@ class CustomizedLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyC
|
||||
|
||||
override fun onPermissionResult(granted: Boolean) {
|
||||
if (granted) {
|
||||
mapView!!.getMapAsync(this@CustomizedLocationPulsingCircleActivity)
|
||||
mapView.getMapAsync(this@CustomizedLocationPulsingCircleActivity)
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
@@ -329,28 +329,28 @@ class CustomizedLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyC
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
if (locationComponent != null) {
|
||||
outState.putParcelable(SAVED_STATE_LOCATION, locationComponent!!.lastKnownLocation)
|
||||
outState.putInt(SAVED_STATE_LOCATION_CIRCLE_PULSE_COLOR, LOCATION_CIRCLE_PULSE_COLOR)
|
||||
@@ -363,12 +363,12 @@ class CustomizedLocationPulsingCircleActivity : AppCompatActivity(), OnMapReadyC
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -19,7 +19,7 @@ import com.mapbox.mapboxsdk.testapp.R
|
||||
|
||||
class LocationComponentActivationActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var permissionsManager: PermissionsManager? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -68,7 +68,7 @@ class LocationComponentActivationActivity : AppCompatActivity(), OnMapReadyCallb
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private fun activateLocationComponent(style: Style) {
|
||||
val locationComponent = mapboxMap!!.locationComponent
|
||||
val locationComponent = mapboxMap.locationComponent
|
||||
val locationComponentOptions = LocationComponentOptions.builder(this)
|
||||
.elevation(5f)
|
||||
.accuracyAlpha(.6f)
|
||||
@@ -88,36 +88,36 @@ class LocationComponentActivationActivity : AppCompatActivity(), OnMapReadyCallb
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.mapbox.mapboxsdk.testapp.R
|
||||
|
||||
class LocationMapChangeActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var permissionsManager: PermissionsManager? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -27,7 +27,7 @@ class LocationMapChangeActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
val stylesFab = findViewById<FloatingActionButton>(R.id.fabStyles)
|
||||
stylesFab.setOnClickListener { v: View? ->
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap!!.setStyle(Style.Builder().fromUri(Utils.nextStyle()))
|
||||
mapboxMap.setStyle(Style.Builder().fromUri(Utils.nextStyle()))
|
||||
}
|
||||
}
|
||||
mapView.onCreate(savedInstanceState)
|
||||
@@ -73,7 +73,7 @@ class LocationMapChangeActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
private fun activateLocationComponent(style: Style) {
|
||||
val locationComponent = mapboxMap!!.locationComponent
|
||||
val locationComponent = mapboxMap.locationComponent
|
||||
locationComponent.activateLocationComponent(
|
||||
LocationComponentActivationOptions
|
||||
.builder(this, style)
|
||||
@@ -100,36 +100,36 @@ class LocationMapChangeActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class LocationModesActivity :
|
||||
private var protectedGestureArea: View? = null
|
||||
private var permissionsManager: PermissionsManager? = null
|
||||
private var locationComponent: LocationComponent? = null
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var defaultStyle = false
|
||||
|
||||
@CameraMode.Mode
|
||||
@@ -225,7 +225,7 @@ class LocationModesActivity :
|
||||
if (locationComponent == null) {
|
||||
return
|
||||
}
|
||||
mapboxMap!!.getStyle { style: Style ->
|
||||
mapboxMap.getStyle { style: Style ->
|
||||
val styleUrl =
|
||||
Style.getPredefinedStyle(
|
||||
if (Style.getPredefinedStyle("Bright") == style.uri) {
|
||||
@@ -235,7 +235,7 @@ class LocationModesActivity :
|
||||
}
|
||||
)
|
||||
|
||||
mapboxMap!!.setStyle(Style.Builder().fromUri(styleUrl))
|
||||
mapboxMap.setStyle(Style.Builder().fromUri(styleUrl))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -124,36 +124,36 @@ class ManualLocationUpdatesActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.util.*
|
||||
* Test activity showcasing the different debug modes and allows to cycle between the default map styles.
|
||||
*/
|
||||
open class DebugModeActivity : AppCompatActivity(), OnMapReadyCallback, OnFpsChangedListener {
|
||||
private var mapView: MapView? = null
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapView: MapView
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var cameraMoveListener: OnCameraMoveListener? = null
|
||||
private var actionBarDrawerToggle: ActionBarDrawerToggle? = null
|
||||
private var currentStyleIndex = 0
|
||||
@@ -59,15 +59,15 @@ open class DebugModeActivity : AppCompatActivity(), OnMapReadyCallback, OnFpsCha
|
||||
val mapboxMapOptions = setupMapboxMapOptions()
|
||||
mapView = MapView(this, mapboxMapOptions)
|
||||
(findViewById<View>(R.id.coordinator_layout) as ViewGroup).addView(mapView, 0)
|
||||
mapView!!.addOnDidFinishLoadingStyleListener {
|
||||
mapView.addOnDidFinishLoadingStyleListener {
|
||||
if (mapboxMap != null) {
|
||||
setupNavigationView(mapboxMap!!.style!!.layers)
|
||||
setupNavigationView(mapboxMap.style!!.layers)
|
||||
}
|
||||
}
|
||||
mapView!!.tag = true
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync(this)
|
||||
mapView!!.addOnDidFinishLoadingStyleListener { Timber.d("Style loaded") }
|
||||
mapView.tag = true
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(this)
|
||||
mapView.addOnDidFinishLoadingStyleListener { Timber.d("Style loaded") }
|
||||
}
|
||||
|
||||
protected open fun setupMapboxMapOptions(): MapboxMapOptions {
|
||||
@@ -76,7 +76,7 @@ open class DebugModeActivity : AppCompatActivity(), OnMapReadyCallback, OnFpsCha
|
||||
|
||||
override fun onMapReady(map: MapboxMap) {
|
||||
mapboxMap = map
|
||||
mapboxMap!!.setStyle(
|
||||
mapboxMap.setStyle(
|
||||
Style.Builder().fromUri(STYLES[currentStyleIndex])
|
||||
) { style: Style -> setupNavigationView(style.layers) }
|
||||
setupZoomView()
|
||||
@@ -85,7 +85,7 @@ open class DebugModeActivity : AppCompatActivity(), OnMapReadyCallback, OnFpsCha
|
||||
|
||||
private fun setFpsView() {
|
||||
fpsView = findViewById(R.id.fpsView)
|
||||
mapboxMap!!.setOnFpsChangedListener(this)
|
||||
mapboxMap.setOnFpsChangedListener(this)
|
||||
}
|
||||
|
||||
override fun onFpsChanged(fps: Double) {
|
||||
@@ -93,7 +93,7 @@ open class DebugModeActivity : AppCompatActivity(), OnMapReadyCallback, OnFpsCha
|
||||
}
|
||||
|
||||
private fun setupNavigationView(layerList: List<Layer>) {
|
||||
Timber.v("New style loaded with JSON: %s", mapboxMap!!.style!!.json)
|
||||
Timber.v("New style loaded with JSON: %s", mapboxMap.style!!.json)
|
||||
val adapter = LayerListAdapter(this, layerList)
|
||||
val listView = findViewById<ListView>(R.id.listView)
|
||||
listView.adapter = adapter
|
||||
@@ -121,13 +121,13 @@ open class DebugModeActivity : AppCompatActivity(), OnMapReadyCallback, OnFpsCha
|
||||
|
||||
private fun setupZoomView() {
|
||||
val textView = findViewById<TextView>(R.id.textZoom)
|
||||
mapboxMap!!.addOnCameraMoveListener(
|
||||
mapboxMap.addOnCameraMoveListener(
|
||||
OnCameraMoveListener {
|
||||
textView.text = String.format(
|
||||
this@DebugModeActivity.getString(
|
||||
R.string.debug_zoom
|
||||
),
|
||||
mapboxMap!!.cameraPosition.zoom
|
||||
mapboxMap.cameraPosition.zoom
|
||||
)
|
||||
}.also { cameraMoveListener = it }
|
||||
)
|
||||
@@ -137,8 +137,8 @@ open class DebugModeActivity : AppCompatActivity(), OnMapReadyCallback, OnFpsCha
|
||||
val fabDebug = findViewById<FloatingActionButton>(R.id.fabDebug)
|
||||
fabDebug.setOnClickListener { view: View? ->
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap!!.isDebugActive = !mapboxMap!!.isDebugActive
|
||||
Timber.d("Debug FAB: isDebug Active? %s", mapboxMap!!.isDebugActive)
|
||||
mapboxMap.isDebugActive = !mapboxMap.isDebugActive
|
||||
Timber.d("Debug FAB: isDebug Active? %s", mapboxMap.isDebugActive)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ open class DebugModeActivity : AppCompatActivity(), OnMapReadyCallback, OnFpsCha
|
||||
if (currentStyleIndex == STYLES.size) {
|
||||
currentStyleIndex = 0
|
||||
}
|
||||
mapboxMap!!.setStyle(Style.Builder().fromUri(STYLES[currentStyleIndex]))
|
||||
mapboxMap.setStyle(Style.Builder().fromUri(STYLES[currentStyleIndex]))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,11 +161,11 @@ open class DebugModeActivity : AppCompatActivity(), OnMapReadyCallback, OnFpsCha
|
||||
if (itemId == R.id.menu_action_toggle_report_fps) {
|
||||
isReportFps = !isReportFps
|
||||
fpsView!!.visibility = if (isReportFps) View.VISIBLE else View.GONE
|
||||
mapboxMap!!.setOnFpsChangedListener(if (isReportFps) this else null)
|
||||
mapboxMap.setOnFpsChangedListener(if (isReportFps) this else null)
|
||||
} else if (itemId == R.id.menu_action_limit_to_30_fps) {
|
||||
mapView!!.setMaximumFps(30)
|
||||
mapView.setMaximumFps(30)
|
||||
} else if (itemId == R.id.menu_action_limit_to_60_fps) {
|
||||
mapView!!.setMaximumFps(60)
|
||||
mapView.setMaximumFps(60)
|
||||
}
|
||||
return actionBarDrawerToggle!!.onOptionsItemSelected(item) || super.onOptionsItemSelected(
|
||||
item
|
||||
@@ -179,40 +179,40 @@ open class DebugModeActivity : AppCompatActivity(), OnMapReadyCallback, OnFpsCha
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap!!.removeOnCameraMoveListener(cameraMoveListener!!)
|
||||
mapboxMap.removeOnCameraMoveListener(cameraMoveListener!!)
|
||||
}
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
private class LayerListAdapter(context: Context?, layers: List<Layer>) :
|
||||
|
||||
@@ -62,8 +62,8 @@ class DoubleMapActivity : AppCompatActivity() {
|
||||
|
||||
// MapView large
|
||||
mapView = MapView(view.context, MapFragmentUtils.resolveArgs(view.context, arguments))
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync { mapboxMap: MapboxMap ->
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { mapboxMap: MapboxMap ->
|
||||
mapboxMap.setStyle(
|
||||
Style.getPredefinedStyle(
|
||||
"Streets"
|
||||
@@ -106,43 +106,43 @@ class DoubleMapActivity : AppCompatActivity() {
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
mapViewMini!!.onResume()
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
mapViewMini!!.onStart()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
mapViewMini!!.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
mapViewMini!!.onStop()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
mapViewMini!!.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
mapViewMini!!.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
// Mini map view is not interactive in this case, so we shouldn't save the instance.
|
||||
// If we'd like to support state saving for both maps, they'd have to be kept in separate fragments.
|
||||
// mapViewMini.onSaveInstanceState(outState);
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.mapbox.mapboxsdk.testapp.R
|
||||
*/
|
||||
class LatLngBoundsForCameraActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_restricted_bounds)
|
||||
@@ -58,12 +58,12 @@ class LatLngBoundsForCameraActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
}
|
||||
|
||||
private fun setupBounds(bounds: LatLngBounds?) {
|
||||
mapboxMap!!.setLatLngBoundsForCameraTarget(bounds)
|
||||
mapboxMap.setLatLngBoundsForCameraTarget(bounds)
|
||||
showBoundsArea(bounds)
|
||||
}
|
||||
|
||||
private fun showBoundsArea(bounds: LatLngBounds?) {
|
||||
mapboxMap!!.clear()
|
||||
mapboxMap.clear()
|
||||
if (bounds != null) {
|
||||
val boundsArea = PolygonOptions()
|
||||
.add(bounds.northWest)
|
||||
@@ -72,7 +72,7 @@ class LatLngBoundsForCameraActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
.add(bounds.southWest)
|
||||
boundsArea.alpha(0.25f)
|
||||
boundsArea.fillColor(Color.RED)
|
||||
mapboxMap!!.addPolygon(boundsArea)
|
||||
mapboxMap.addPolygon(boundsArea)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,42 +80,42 @@ class LatLngBoundsForCameraActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
val crosshair = View(this)
|
||||
crosshair.layoutParams = FrameLayout.LayoutParams(10, 10, Gravity.CENTER)
|
||||
crosshair.setBackgroundColor(Color.BLUE)
|
||||
mapView!!.addView(crosshair)
|
||||
mapView.addView(crosshair)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -39,36 +39,36 @@ class LocalGlyphActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,36 +102,36 @@ class MapChangeActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,40 +51,40 @@ class MapInDialogActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
if (mapView != null) {
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
if (mapView != null) {
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.mapbox.mapboxsdk.testapp.R
|
||||
*/
|
||||
class MapPaddingActivity : AppCompatActivity() {
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_map_padding)
|
||||
@@ -43,37 +43,37 @@ class MapPaddingActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
@@ -89,8 +89,8 @@ class MapPaddingActivity : AppCompatActivity() {
|
||||
.bearing(40.0)
|
||||
.tilt(45.0)
|
||||
.build()
|
||||
mapboxMap!!.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
|
||||
mapboxMap!!.addMarker(MarkerOptions().title("Center map").position(bangalore))
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
|
||||
mapboxMap.addMarker(MarkerOptions().title("Center map").position(bangalore))
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
@@ -30,37 +30,37 @@ class SimpleMapActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.mapbox.mapboxsdk.testapp.activity.maplayout.VisibilityChangeActivity.
|
||||
*/
|
||||
class VisibilityChangeActivity : AppCompatActivity() {
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private val handler = Handler()
|
||||
private var runnable: Runnable? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -25,9 +25,11 @@ class VisibilityChangeActivity : AppCompatActivity() {
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(
|
||||
OnMapReadyCallback { map: MapboxMap? ->
|
||||
mapboxMap = map
|
||||
mapboxMap!!.setStyle(Style.getPredefinedStyle("Streets"))
|
||||
mapboxMap!!.animateCamera(
|
||||
if (map != null) {
|
||||
mapboxMap = map
|
||||
}
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"))
|
||||
mapboxMap.animateCamera(
|
||||
CameraUpdateFactory.newLatLngZoom(
|
||||
LatLng(55.754020, 37.620948),
|
||||
12.0
|
||||
@@ -65,9 +67,9 @@ class VisibilityChangeActivity : AppCompatActivity() {
|
||||
if (isViewHiearchyReady) {
|
||||
if (isEvenStep) {
|
||||
viewParent!!.visibility = View.VISIBLE
|
||||
mapView!!.visibility = View.VISIBLE
|
||||
mapView?.visibility = View.VISIBLE
|
||||
} else if (isFirstOrThirdStep) {
|
||||
mapView!!.visibility = visibilityForStep
|
||||
mapView?.visibility = visibilityForStep
|
||||
} else if (isFifthOrSeventhStep) {
|
||||
viewParent!!.visibility = visibilityForStep
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ class OfflineActivity : AppCompatActivity(), DownloadRegionDialogListener {
|
||||
/*
|
||||
* UI elements
|
||||
*/
|
||||
private var mapView: MapView? = null
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapView: MapView
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var progressBar: ProgressBar? = null
|
||||
private var downloadRegion: Button? = null
|
||||
private var listRegions: Button? = null
|
||||
@@ -63,8 +63,8 @@ class OfflineActivity : AppCompatActivity(), DownloadRegionDialogListener {
|
||||
|
||||
// Set up map
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync { mapboxMap: MapboxMap ->
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { mapboxMap: MapboxMap ->
|
||||
Timber.d("Map is ready")
|
||||
this@OfflineActivity.mapboxMap = mapboxMap
|
||||
mapboxMap.setStyle(Style.Builder().fromUri(STYLE_URL))
|
||||
@@ -96,37 +96,37 @@ class OfflineActivity : AppCompatActivity(), DownloadRegionDialogListener {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -193,9 +193,9 @@ class OfflineActivity : AppCompatActivity(), DownloadRegionDialogListener {
|
||||
startProgress()
|
||||
|
||||
// Definition
|
||||
val bounds = mapboxMap!!.projection.visibleRegion.latLngBounds
|
||||
val minZoom = mapboxMap!!.cameraPosition.zoom
|
||||
val maxZoom = mapboxMap!!.maxZoomLevel
|
||||
val bounds = mapboxMap.projection.visibleRegion.latLngBounds
|
||||
val minZoom = mapboxMap.cameraPosition.zoom
|
||||
val maxZoom = mapboxMap.maxZoomLevel
|
||||
val pixelRatio = this.resources.displayMetrics.density
|
||||
val definition = OfflineTilePyramidRegionDefinition(
|
||||
STYLE_URL,
|
||||
|
||||
@@ -29,7 +29,7 @@ class UpdateMetadataActivity :
|
||||
AdapterView.OnItemClickListener,
|
||||
AdapterView.OnItemLongClickListener {
|
||||
private var adapter: OfflineRegionMetadataAdapter? = null
|
||||
private var mapView: MapView? = null
|
||||
private lateinit var mapView: MapView
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_metadata_update)
|
||||
@@ -73,14 +73,14 @@ class UpdateMetadataActivity :
|
||||
val container = findViewById<ViewGroup>(R.id.container)
|
||||
container.removeAllViews()
|
||||
container.addView(MapView(view.context).also { mapView = it })
|
||||
mapView!!.onCreate(null)
|
||||
mapView!!.getMapAsync { map: MapboxMap ->
|
||||
mapView.onCreate(null)
|
||||
mapView.getMapAsync { map: MapboxMap ->
|
||||
map.setOfflineRegionDefinition(
|
||||
adapter!!.getItem(position).definition
|
||||
)
|
||||
}
|
||||
mapView!!.onStart()
|
||||
mapView!!.onResume()
|
||||
mapView.onStart()
|
||||
mapView.onResume()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -129,9 +129,9 @@ class UpdateMetadataActivity :
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (mapView != null) {
|
||||
mapView!!.onPause()
|
||||
mapView!!.onStop()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onPause()
|
||||
mapView.onStop()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import timber.log.Timber
|
||||
* Test activity showcasing the url transform
|
||||
*/
|
||||
class UrlTransformActivity : AppCompatActivity() {
|
||||
private var mapView: MapView? = null
|
||||
private lateinit var mapView: MapView
|
||||
|
||||
/**
|
||||
* Be sure to use an isolated class so the activity is not leaked when
|
||||
@@ -38,11 +38,11 @@ class UrlTransformActivity : AppCompatActivity() {
|
||||
|
||||
// Initialize map as normal
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView.onCreate(savedInstanceState)
|
||||
|
||||
// Get a handle to the file source and set the resource transform
|
||||
FileSource.getInstance(this@UrlTransformActivity).setResourceTransform(Transform())
|
||||
mapView!!.getMapAsync { map: MapboxMap ->
|
||||
mapView.getMapAsync { map: MapboxMap ->
|
||||
Timber.i("Map loaded")
|
||||
map.setStyle(Style.getPredefinedStyle("Streets"))
|
||||
}
|
||||
@@ -50,27 +50,27 @@ class UrlTransformActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
@@ -78,11 +78,11 @@ class UrlTransformActivity : AppCompatActivity() {
|
||||
|
||||
// Example of how to reset the transform callback
|
||||
FileSource.getInstance(this@UrlTransformActivity).setResourceTransform(null)
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import java.util.*
|
||||
class AnimatedSymbolLayerActivity : AppCompatActivity() {
|
||||
private val random = Random()
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var style: Style? = null
|
||||
private val randomCars: MutableList<Car> = ArrayList()
|
||||
private var randomCarSource: GeoJsonSource? = null
|
||||
@@ -293,7 +293,7 @@ class AnimatedSymbolLayerActivity : AppCompatActivity() {
|
||||
|
||||
private val latLngInBounds: LatLng
|
||||
get() {
|
||||
val bounds = mapboxMap!!.projection.visibleRegion.latLngBounds
|
||||
val bounds = mapboxMap.projection.visibleRegion.latLngBounds
|
||||
val generator = Random()
|
||||
val randomLat = bounds.latitudeSouth + generator.nextDouble() * bounds.latitudeNorth - bounds.latitudeSouth
|
||||
val randomLon = bounds.longitudeWest + generator.nextDouble() * bounds.longitudeEast - bounds.longitudeWest
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.mapbox.mapboxsdk.utils.ColorUtils
|
||||
*/
|
||||
class BuildingFillExtrusionActivity : AppCompatActivity() {
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var light: Light? = null
|
||||
private var isMapAnchorLight = false
|
||||
private var isLowIntensityLight = false
|
||||
@@ -37,8 +37,10 @@ class BuildingFillExtrusionActivity : AppCompatActivity() {
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(
|
||||
OnMapReadyCallback { map: MapboxMap? ->
|
||||
mapboxMap = map
|
||||
mapboxMap!!.setStyle(Style.getPredefinedStyle("Streets")) { style: Style ->
|
||||
if (map != null) {
|
||||
mapboxMap = map
|
||||
}
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style ->
|
||||
setupBuildings(style)
|
||||
setupLight()
|
||||
}
|
||||
@@ -66,7 +68,7 @@ class BuildingFillExtrusionActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun setupLight() {
|
||||
light = mapboxMap!!.style!!.light
|
||||
light = mapboxMap.style!!.light
|
||||
findViewById<View>(R.id.fabLightPosition).setOnClickListener { v: View? ->
|
||||
isInitPosition = !isInitPosition
|
||||
if (isInitPosition) {
|
||||
@@ -103,36 +105,36 @@ class BuildingFillExtrusionActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.net.URISyntaxException
|
||||
*/
|
||||
class CircleLayerActivity : AppCompatActivity(), View.OnClickListener {
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var styleFab: FloatingActionButton
|
||||
private lateinit var routeFab: FloatingActionButton
|
||||
private var layer: CircleLayer? = null
|
||||
@@ -46,11 +46,13 @@ class CircleLayerActivity : AppCompatActivity(), View.OnClickListener {
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(
|
||||
OnMapReadyCallback { map: MapboxMap? ->
|
||||
mapboxMap = map
|
||||
mapboxMap!!.setStyle(Style.getPredefinedStyle("Satellite Hybrid"))
|
||||
if (map != null) {
|
||||
mapboxMap = map
|
||||
}
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Satellite Hybrid"))
|
||||
mapView.addOnDidFinishLoadingStyleListener(
|
||||
OnDidFinishLoadingStyleListener {
|
||||
val style = mapboxMap!!.style
|
||||
val style = mapboxMap.style
|
||||
addBusStopSource(style)
|
||||
addBusStopCircleLayer(style)
|
||||
initFloatingActionButtons()
|
||||
@@ -105,13 +107,13 @@ class CircleLayerActivity : AppCompatActivity(), View.OnClickListener {
|
||||
}
|
||||
|
||||
private fun removeOldSource() {
|
||||
mapboxMap!!.style!!.removeSource(SOURCE_ID)
|
||||
mapboxMap!!.style!!.removeLayer(LAYER_ID)
|
||||
mapboxMap.style!!.removeSource(SOURCE_ID)
|
||||
mapboxMap.style!!.removeLayer(LAYER_ID)
|
||||
}
|
||||
|
||||
private fun addClusteredSource() {
|
||||
try {
|
||||
mapboxMap!!.style!!.addSource(
|
||||
mapboxMap.style!!.addSource(
|
||||
GeoJsonSource(
|
||||
SOURCE_ID_CLUSTER,
|
||||
URI(URL_BUS_ROUTES),
|
||||
@@ -149,7 +151,7 @@ class CircleLayerActivity : AppCompatActivity(), View.OnClickListener {
|
||||
unclustered.setProperties(
|
||||
PropertyFactory.iconImage("bus-15")
|
||||
)
|
||||
mapboxMap!!.style!!.addLayer(unclustered)
|
||||
mapboxMap.style!!.addLayer(unclustered)
|
||||
for (i in layers.indices) {
|
||||
// Add some nice circles
|
||||
val circles = CircleLayer("cluster-$i", SOURCE_ID_CLUSTER)
|
||||
@@ -188,7 +190,7 @@ class CircleLayerActivity : AppCompatActivity(), View.OnClickListener {
|
||||
)
|
||||
}
|
||||
)
|
||||
mapboxMap!!.style!!.addLayer(circles)
|
||||
mapboxMap.style!!.addLayer(circles)
|
||||
}
|
||||
|
||||
// Add the count labels
|
||||
@@ -200,7 +202,7 @@ class CircleLayerActivity : AppCompatActivity(), View.OnClickListener {
|
||||
PropertyFactory.textIgnorePlacement(true),
|
||||
PropertyFactory.textAllowOverlap(true)
|
||||
)
|
||||
mapboxMap!!.style!!.addLayer(count)
|
||||
mapboxMap.style!!.addLayer(count)
|
||||
}
|
||||
|
||||
private fun removeFabs() {
|
||||
@@ -215,17 +217,17 @@ class CircleLayerActivity : AppCompatActivity(), View.OnClickListener {
|
||||
}
|
||||
|
||||
private fun removeBusStop() {
|
||||
mapboxMap!!.style!!.removeLayer(layer!!)
|
||||
mapboxMap!!.style!!.removeSource(source!!)
|
||||
mapboxMap.style!!.removeLayer(layer!!)
|
||||
mapboxMap.style!!.removeSource(source!!)
|
||||
}
|
||||
|
||||
private fun loadNewStyle() {
|
||||
mapboxMap!!.setStyle(Style.Builder().fromUri(nextStyle))
|
||||
mapboxMap.setStyle(Style.Builder().fromUri(nextStyle))
|
||||
}
|
||||
|
||||
private fun addBusStop() {
|
||||
mapboxMap!!.style!!.addLayer(layer!!)
|
||||
mapboxMap!!.style!!.addSource(source!!)
|
||||
mapboxMap.style!!.addLayer(layer!!)
|
||||
mapboxMap.style!!.addSource(source!!)
|
||||
}
|
||||
|
||||
private val nextStyle: String
|
||||
@@ -239,37 +241,37 @@ class CircleLayerActivity : AppCompatActivity(), View.OnClickListener {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
private object Data {
|
||||
|
||||
@@ -27,7 +27,7 @@ import timber.log.Timber
|
||||
*/
|
||||
class CustomSpriteActivity : AppCompatActivity() {
|
||||
private var source: GeoJsonSource? = null
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var mapView: MapView
|
||||
private lateinit var layer: Layer
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -66,7 +66,7 @@ class CustomSpriteActivity : AppCompatActivity() {
|
||||
"point",
|
||||
FeatureCollection.fromFeatures(arrayOf(Feature.fromGeometry(point)))
|
||||
)
|
||||
mapboxMap!!.style!!.addSource(source!!)
|
||||
mapboxMap.style!!.addSource(source!!)
|
||||
|
||||
// Add a symbol layer that references that point source
|
||||
layer = SymbolLayer("layer", "point")
|
||||
@@ -77,7 +77,7 @@ class CustomSpriteActivity : AppCompatActivity() {
|
||||
)
|
||||
|
||||
// lets add a circle below labels!
|
||||
mapboxMap!!.style!!.addLayerBelow(layer, "water_intermittent")
|
||||
mapboxMap.style!!.addLayerBelow(layer, "water_intermittent")
|
||||
fab.setImageResource(R.drawable.ic_directions_car_black)
|
||||
} else {
|
||||
// Update point
|
||||
@@ -96,7 +96,7 @@ class CustomSpriteActivity : AppCompatActivity() {
|
||||
)
|
||||
|
||||
// Move the camera as well
|
||||
mapboxMap!!.moveCamera(
|
||||
mapboxMap.moveCamera(
|
||||
CameraUpdateFactory.newLatLng(
|
||||
LatLng(
|
||||
point.latitude(),
|
||||
@@ -114,37 +114,37 @@ class CustomSpriteActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.io.IOException
|
||||
*/
|
||||
class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var idleListener: IdleZoomListener? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -42,8 +42,10 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
mapView.getMapAsync(
|
||||
OnMapReadyCallback { map: MapboxMap? ->
|
||||
// Store for later
|
||||
mapboxMap = map
|
||||
mapboxMap!!.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? ->
|
||||
if (map != null) {
|
||||
mapboxMap = map
|
||||
}
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? ->
|
||||
// Add a parks layer
|
||||
addParksLayer()
|
||||
|
||||
@@ -52,7 +54,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
// Center and Zoom (Amsterdam, zoomed to streets)
|
||||
mapboxMap!!.animateCamera(
|
||||
mapboxMap.animateCamera(
|
||||
CameraUpdateFactory.newLatLngZoom(
|
||||
LatLng(52.379189, 4.899431),
|
||||
14.0
|
||||
@@ -64,7 +66,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
|
||||
private fun setupDebugZoomView() {
|
||||
val textView = findViewById<View>(R.id.textZoom) as TextView
|
||||
mapboxMap!!.addOnCameraIdleListener(
|
||||
mapboxMap.addOnCameraIdleListener(
|
||||
IdleZoomListener(
|
||||
mapboxMap,
|
||||
textView
|
||||
@@ -79,40 +81,40 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (mapboxMap != null && idleListener != null) {
|
||||
mapboxMap!!.removeOnCameraIdleListener(idleListener!!)
|
||||
mapboxMap.removeOnCameraIdleListener(idleListener!!)
|
||||
}
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
@@ -159,7 +161,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
|
||||
private fun addExponentialZoomFunction() {
|
||||
Timber.i("Add exponential zoom function")
|
||||
val layer = mapboxMap!!.style!!.getLayerAs<FillLayer>("water")!!
|
||||
val layer = mapboxMap.style!!.getLayerAs<FillLayer>("water")!!
|
||||
layer.setProperties(
|
||||
PropertyFactory.fillColor(
|
||||
Expression.interpolate(
|
||||
@@ -176,7 +178,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
|
||||
private fun addIntervalZoomFunction() {
|
||||
Timber.i("Add interval zoom function")
|
||||
val layer = mapboxMap!!.style!!.getLayerAs<FillLayer>("water")!!
|
||||
val layer = mapboxMap.style!!.getLayerAs<FillLayer>("water")!!
|
||||
layer.setProperties(
|
||||
PropertyFactory.fillColor(
|
||||
Expression.step(
|
||||
@@ -193,7 +195,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
|
||||
private fun addExponentialSourceFunction() {
|
||||
Timber.i("Add exponential source function")
|
||||
val layer = mapboxMap!!.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
val layer = mapboxMap.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
layer.setProperties(
|
||||
PropertyFactory.fillColor(
|
||||
Expression.interpolate(
|
||||
@@ -210,7 +212,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
|
||||
private fun addCategoricalSourceFunction() {
|
||||
Timber.i("Add categorical source function")
|
||||
val layer = mapboxMap!!.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
val layer = mapboxMap.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
layer.setProperties(
|
||||
PropertyFactory.fillColor(
|
||||
Expression.match(
|
||||
@@ -230,7 +232,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
|
||||
private fun addIdentitySourceFunction() {
|
||||
Timber.i("Add identity source function")
|
||||
val layer = mapboxMap!!.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
val layer = mapboxMap.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
layer.setProperties(
|
||||
PropertyFactory.fillOpacity(
|
||||
Expression.get("fill-opacity")
|
||||
@@ -241,7 +243,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
|
||||
private fun addIntervalSourceFunction() {
|
||||
Timber.i("Add interval source function")
|
||||
val layer = mapboxMap!!.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
val layer = mapboxMap.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
layer.setProperties(
|
||||
PropertyFactory.fillColor(
|
||||
Expression.step(
|
||||
@@ -258,7 +260,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
|
||||
private fun addCompositeExponentialFunction() {
|
||||
Timber.i("Add composite exponential function")
|
||||
val layer = mapboxMap!!.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
val layer = mapboxMap.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
layer.setProperties(
|
||||
PropertyFactory.fillColor(
|
||||
Expression.interpolate(
|
||||
@@ -302,7 +304,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
|
||||
private fun addCompositeIntervalFunction() {
|
||||
Timber.i("Add composite interval function")
|
||||
val layer = mapboxMap!!.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
val layer = mapboxMap.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
layer.setProperties(
|
||||
PropertyFactory.fillColor(
|
||||
Expression.interpolate(
|
||||
@@ -346,7 +348,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
|
||||
private fun addCompositeCategoricalFunction() {
|
||||
Timber.i("Add composite categorical function")
|
||||
val layer = mapboxMap!!.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
val layer = mapboxMap.style!!.getLayerAs<FillLayer>(AMSTERDAM_PARKS_LAYER)!!
|
||||
layer.setProperties(
|
||||
PropertyFactory.fillColor(
|
||||
Expression.step(
|
||||
@@ -516,7 +518,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
"amsterdam-parks-source",
|
||||
ResourceUtils.readRawResource(this, R.raw.amsterdam)
|
||||
)
|
||||
mapboxMap!!.style!!.addSource(source)
|
||||
mapboxMap.style!!.addSource(source)
|
||||
} catch (ioException: IOException) {
|
||||
Toast.makeText(
|
||||
this@DataDrivenStyleActivity,
|
||||
@@ -527,7 +529,7 @@ class DataDrivenStyleActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
// Add a fill layer
|
||||
mapboxMap!!.style!!
|
||||
mapboxMap.style!!
|
||||
.addLayer(
|
||||
FillLayer(AMSTERDAM_PARKS_LAYER, source.getId())
|
||||
.withProperties(
|
||||
|
||||
@@ -67,36 +67,36 @@ class FillExtrusionActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import com.mapbox.mapboxsdk.testapp.R
|
||||
* Test activity used for instrumentation tests of fill extrusion.
|
||||
*/
|
||||
class FillExtrusionStyleTestActivity : AppCompatActivity() {
|
||||
var mapView: MapView? = null
|
||||
var mapboxMap: MapboxMap? = null
|
||||
lateinit var mapView: MapView
|
||||
lateinit var mapboxMap: MapboxMap
|
||||
private set
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -22,8 +22,8 @@ class FillExtrusionStyleTestActivity : AppCompatActivity() {
|
||||
|
||||
// Initialize map as normal
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync { mapboxMap: MapboxMap ->
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { mapboxMap: MapboxMap ->
|
||||
mapboxMap.setStyle(
|
||||
Style.Builder().fromUri(Style.getPredefinedStyle("Streets"))
|
||||
) { style: Style? -> this@FillExtrusionStyleTestActivity.mapboxMap = mapboxMap }
|
||||
@@ -32,36 +32,36 @@ class FillExtrusionStyleTestActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.Objects
|
||||
*/
|
||||
class GeoJsonClusteringActivity : AppCompatActivity() {
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var clusterSource: GeoJsonSource? = null
|
||||
private var clickOptionCounter = 0
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -46,8 +46,10 @@ class GeoJsonClusteringActivity : AppCompatActivity() {
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(
|
||||
OnMapReadyCallback { map: MapboxMap? ->
|
||||
mapboxMap = map
|
||||
mapboxMap!!.animateCamera(
|
||||
if (map != null) {
|
||||
mapboxMap = map
|
||||
}
|
||||
mapboxMap.animateCamera(
|
||||
CameraUpdateFactory.newLatLngZoom(
|
||||
LatLng(37.7749, 122.4194),
|
||||
0.0
|
||||
@@ -73,7 +75,7 @@ class GeoJsonClusteringActivity : AppCompatActivity() {
|
||||
)
|
||||
)
|
||||
try {
|
||||
mapboxMap!!.setStyle(
|
||||
mapboxMap.setStyle(
|
||||
Style.Builder()
|
||||
.fromUri(Style.getPredefinedStyle("Bright"))
|
||||
.withSource(createClusterSource().also { clusterSource = it })
|
||||
@@ -93,10 +95,10 @@ class GeoJsonClusteringActivity : AppCompatActivity() {
|
||||
} catch (exception: URISyntaxException) {
|
||||
Timber.e(exception)
|
||||
}
|
||||
mapboxMap!!.addOnMapClickListener { latLng: LatLng? ->
|
||||
val point = mapboxMap!!.projection.toScreenLocation(latLng!!)
|
||||
mapboxMap.addOnMapClickListener { latLng: LatLng? ->
|
||||
val point = mapboxMap.projection.toScreenLocation(latLng!!)
|
||||
val features =
|
||||
mapboxMap!!.queryRenderedFeatures(point, "cluster-0", "cluster-1", "cluster-2")
|
||||
mapboxMap.queryRenderedFeatures(point, "cluster-0", "cluster-1", "cluster-2")
|
||||
if (!features.isEmpty()) {
|
||||
onClusterClick(features[0], Point(point.x.toInt(), point.y.toInt()))
|
||||
}
|
||||
@@ -113,8 +115,8 @@ class GeoJsonClusteringActivity : AppCompatActivity() {
|
||||
private fun onClusterClick(cluster: Feature, clickPoint: Point) {
|
||||
if (clickOptionCounter == 0) {
|
||||
val nextZoomLevel = clusterSource!!.getClusterExpansionZoom(cluster).toDouble()
|
||||
val zoomDelta = nextZoomLevel - mapboxMap!!.cameraPosition.zoom
|
||||
mapboxMap!!.animateCamera(
|
||||
val zoomDelta = nextZoomLevel - mapboxMap.cameraPosition.zoom
|
||||
mapboxMap.animateCamera(
|
||||
CameraUpdateFactory.zoomBy(
|
||||
zoomDelta + CAMERA_ZOOM_DELTA,
|
||||
clickPoint
|
||||
|
||||
@@ -70,37 +70,37 @@ class GradientLineActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.net.URISyntaxException
|
||||
*/
|
||||
class HeatmapLayerActivity : AppCompatActivity() {
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_heatmaplayer)
|
||||
@@ -27,9 +27,11 @@ class HeatmapLayerActivity : AppCompatActivity() {
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(
|
||||
OnMapReadyCallback { map: MapboxMap? ->
|
||||
mapboxMap = map
|
||||
if (map != null) {
|
||||
mapboxMap = map
|
||||
}
|
||||
try {
|
||||
mapboxMap!!.setStyle(
|
||||
mapboxMap.setStyle(
|
||||
Style.Builder()
|
||||
.fromUri(Style.getPredefinedStyle("Pastel"))
|
||||
.withSource(createEarthquakeSource())
|
||||
@@ -152,37 +154,37 @@ class HeatmapLayerActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.mapbox.mapboxsdk.testapp.R
|
||||
*/
|
||||
class HillshadeLayerActivity : AppCompatActivity() {
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_fill_extrusion_layer)
|
||||
@@ -20,10 +20,12 @@ class HillshadeLayerActivity : AppCompatActivity() {
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(
|
||||
OnMapReadyCallback { map: MapboxMap? ->
|
||||
mapboxMap = map
|
||||
if (map != null) {
|
||||
mapboxMap = map
|
||||
}
|
||||
val rasterDemSource = RasterDemSource(SOURCE_ID, SOURCE_URL)
|
||||
val hillshadeLayer = HillshadeLayer(LAYER_ID, SOURCE_ID)
|
||||
mapboxMap!!.setStyle(
|
||||
mapboxMap.setStyle(
|
||||
Style.Builder()
|
||||
.fromUri(Style.getPredefinedStyle("Streets"))
|
||||
.withLayerBelow(hillshadeLayer, LAYER_BELOW_ID)
|
||||
@@ -35,37 +37,37 @@ class HillshadeLayerActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -20,21 +20,21 @@ import java.net.URISyntaxException
|
||||
*
|
||||
*/
|
||||
class RealTimeGeoJsonActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
private var mapView: MapView? = null
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapView: MapView
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var handler: Handler? = null
|
||||
private var runnable: Runnable? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_default)
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync(this)
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(this)
|
||||
}
|
||||
|
||||
override fun onMapReady(map: MapboxMap) {
|
||||
mapboxMap = map
|
||||
mapboxMap!!.setStyle(Style.getPredefinedStyle("Streets")) { style -> // add source
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Streets")) { style -> // add source
|
||||
try {
|
||||
style.addSource(GeoJsonSource(ID_GEOJSON_SOURCE, URI(URL_GEOJSON_SOURCE)))
|
||||
} catch (malformedUriException: URISyntaxException) {
|
||||
@@ -57,22 +57,22 @@ class RealTimeGeoJsonActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
public override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
public override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
runnable?.let {
|
||||
handler!!.removeCallbacks(it)
|
||||
}
|
||||
@@ -80,12 +80,12 @@ class RealTimeGeoJsonActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
private class RefreshGeoJsonRunnable internal constructor(
|
||||
|
||||
@@ -45,7 +45,7 @@ import java.util.Collections
|
||||
*/
|
||||
class RuntimeStyleActivity : AppCompatActivity() {
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var styleLoaded = false
|
||||
var lngLats = listOf(
|
||||
Arrays.asList(
|
||||
@@ -82,16 +82,18 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
mapView.getMapAsync(
|
||||
OnMapReadyCallback { map: MapboxMap? ->
|
||||
// Store for later
|
||||
mapboxMap = map
|
||||
if (map != null) {
|
||||
mapboxMap = map
|
||||
}
|
||||
|
||||
// Center and Zoom (Amsterdam, zoomed to streets)
|
||||
mapboxMap!!.animateCamera(
|
||||
mapboxMap.animateCamera(
|
||||
CameraUpdateFactory.newLatLngZoom(
|
||||
LatLng(52.379189, 4.899431),
|
||||
1.0
|
||||
)
|
||||
)
|
||||
mapboxMap!!.setStyle(
|
||||
mapboxMap.setStyle(
|
||||
Style.Builder()
|
||||
.fromUri(Style.getPredefinedStyle("Streets")) // set custom transition
|
||||
.withTransition(TransitionOptions(250, 50))
|
||||
@@ -119,37 +121,37 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
@@ -258,7 +260,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun listLayers() {
|
||||
val layers = mapboxMap!!.style!!
|
||||
val layers = mapboxMap.style!!
|
||||
.layers
|
||||
val builder = StringBuilder("Layers:")
|
||||
for (layer in layers) {
|
||||
@@ -269,7 +271,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun listSources() {
|
||||
val sources = mapboxMap!!.style!!
|
||||
val sources = mapboxMap.style!!
|
||||
.sources
|
||||
val builder = StringBuilder("Sources:")
|
||||
for (source in sources) {
|
||||
@@ -282,21 +284,21 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
private fun setLayerInvisible() {
|
||||
val roadLayers = arrayOf("water")
|
||||
for (roadLayer in roadLayers) {
|
||||
val layer = mapboxMap!!.style!!.getLayer(roadLayer)
|
||||
val layer = mapboxMap.style!!.getLayer(roadLayer)
|
||||
layer?.setProperties(PropertyFactory.visibility(Property.NONE))
|
||||
}
|
||||
}
|
||||
|
||||
private fun setRoadSymbolPlacement() {
|
||||
// Zoom so that the labels are visible first
|
||||
mapboxMap!!.animateCamera(
|
||||
mapboxMap.animateCamera(
|
||||
CameraUpdateFactory.zoomTo(14.0),
|
||||
object : DefaultCallback() {
|
||||
override fun onFinish() {
|
||||
val roadLayers =
|
||||
arrayOf("road-label-small", "road-label-medium", "road-label-large")
|
||||
for (roadLayer in roadLayers) {
|
||||
val layer = mapboxMap!!.style!!
|
||||
val layer = mapboxMap.style!!
|
||||
.getLayer(roadLayer)
|
||||
layer?.setProperties(PropertyFactory.symbolPlacement(Property.SYMBOL_PLACEMENT_POINT))
|
||||
}
|
||||
@@ -306,12 +308,12 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun setBackgroundOpacity() {
|
||||
val background = mapboxMap!!.style!!.getLayer("background")
|
||||
val background = mapboxMap.style!!.getLayer("background")
|
||||
background?.setProperties(PropertyFactory.backgroundOpacity(0.2f))
|
||||
}
|
||||
|
||||
private fun setWaterColor() {
|
||||
val water = mapboxMap!!.style!!.getLayerAs<FillLayer>("water")
|
||||
val water = mapboxMap.style!!.getLayerAs<FillLayer>("water")
|
||||
if (water != null) {
|
||||
water.fillColorTransition = TransitionOptions(7500, 1000)
|
||||
water.setProperties(
|
||||
@@ -329,7 +331,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
|
||||
private fun removeBuildings() {
|
||||
// Zoom to see buildings first
|
||||
mapboxMap!!.style!!.removeLayer("building")
|
||||
mapboxMap.style!!.removeLayer("building")
|
||||
}
|
||||
|
||||
private fun addParksLayer() {
|
||||
@@ -345,7 +347,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
).show()
|
||||
return
|
||||
}
|
||||
mapboxMap!!.style!!.addSource(source)
|
||||
mapboxMap.style!!.addSource(source)
|
||||
var layer: FillLayer? = FillLayer("parksLayer", "amsterdam-spots")
|
||||
layer!!.setProperties(
|
||||
PropertyFactory.fillColor(Color.RED),
|
||||
@@ -364,15 +366,15 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
)
|
||||
)
|
||||
)
|
||||
mapboxMap!!.style!!.addLayerBelow(layer, "building")
|
||||
mapboxMap.style!!.addLayerBelow(layer, "building")
|
||||
// layer.setPaintProperty(fillColor(Color.RED)); // XXX But not after the object is attached
|
||||
|
||||
// Or get the object later and set it. It's all good.
|
||||
mapboxMap!!.style!!.getLayer("parksLayer")!!
|
||||
mapboxMap.style!!.getLayer("parksLayer")!!
|
||||
.setProperties(PropertyFactory.fillColor(Color.RED))
|
||||
|
||||
// You can get a typed layer, if you're sure it's of that type. Use with care
|
||||
layer = mapboxMap!!.style!!.getLayerAs("parksLayer")
|
||||
layer = mapboxMap.style!!.getLayerAs("parksLayer")
|
||||
// And get some properties
|
||||
val fillAntialias = layer!!.fillAntialias
|
||||
Timber.d("Fill anti alias: %s", fillAntialias.getValue())
|
||||
@@ -383,7 +385,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
Timber.d("Visibility: %s", visibility.getValue())
|
||||
|
||||
// Get a good look at it all
|
||||
mapboxMap!!.animateCamera(CameraUpdateFactory.zoomTo(12.0))
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(12.0))
|
||||
}
|
||||
|
||||
private fun addDynamicParksLayer() {
|
||||
@@ -402,7 +404,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
// Add an empty source
|
||||
mapboxMap!!.style!!.addSource(GeoJsonSource("dynamic-park-source"))
|
||||
mapboxMap.style!!.addSource(GeoJsonSource("dynamic-park-source"))
|
||||
val layer = FillLayer("dynamic-parks-layer", "dynamic-park-source")
|
||||
layer.setProperties(
|
||||
PropertyFactory.fillColor(Color.GREEN),
|
||||
@@ -420,10 +422,10 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
)
|
||||
)
|
||||
)
|
||||
mapboxMap!!.style!!.addLayer(layer)
|
||||
mapboxMap.style!!.addLayer(layer)
|
||||
|
||||
// Get a good look at it all
|
||||
mapboxMap!!.animateCamera(CameraUpdateFactory.zoomTo(12.0))
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(12.0))
|
||||
|
||||
// Animate the parks source
|
||||
animateParksSource(parks, 0)
|
||||
@@ -439,7 +441,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
Timber.d("Updating parks source")
|
||||
// change the source
|
||||
val park = if (counter < parks.features()!!.size - 1) counter else 0
|
||||
val source = mapboxMap!!.style!!.getSourceAs<GeoJsonSource>("dynamic-park-source")
|
||||
val source = mapboxMap.style!!.getSourceAs<GeoJsonSource>("dynamic-park-source")
|
||||
if (source == null) {
|
||||
Timber.e("Source not found")
|
||||
Toast.makeText(this@RuntimeStyleActivity, "Source not found", Toast.LENGTH_SHORT)
|
||||
@@ -460,7 +462,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
private fun addTerrainLayer() {
|
||||
// Add a source
|
||||
val source: Source = VectorSource("my-terrain-source", "maptiler://sources/hillshades")
|
||||
mapboxMap!!.style!!.addSource(source)
|
||||
mapboxMap.style!!.addSource(source)
|
||||
var layer: LineLayer? = LineLayer("terrainLayer", "my-terrain-source")
|
||||
layer!!.sourceLayer = "contour"
|
||||
layer.setProperties(
|
||||
@@ -471,7 +473,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
)
|
||||
|
||||
// adding layers below "road" layers
|
||||
val layers = mapboxMap!!.style!!
|
||||
val layers = mapboxMap.style!!
|
||||
.layers
|
||||
var latestLayer: Layer? = null
|
||||
Collections.reverse(layers)
|
||||
@@ -487,16 +489,16 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
if (latestLayer != null) {
|
||||
mapboxMap!!.style!!.addLayerBelow(layer, latestLayer.id)
|
||||
mapboxMap.style!!.addLayerBelow(layer, latestLayer.id)
|
||||
}
|
||||
|
||||
// Need to get a fresh handle
|
||||
layer = mapboxMap!!.style!!.getLayerAs("terrainLayer")
|
||||
layer = mapboxMap.style!!.getLayerAs("terrainLayer")
|
||||
|
||||
// Make sure it's also applied after the fact
|
||||
layer!!.minZoom = 10f
|
||||
layer.maxZoom = 15f
|
||||
layer = mapboxMap!!.style!!.getLayer("terrainLayer") as LineLayer?
|
||||
layer = mapboxMap.style!!.getLayer("terrainLayer") as LineLayer?
|
||||
Toast.makeText(
|
||||
this,
|
||||
String.format(
|
||||
@@ -511,14 +513,14 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
private fun addSatelliteLayer() {
|
||||
// Add a source
|
||||
val source: Source = RasterSource("my-raster-source", "maptiler://sources/satellite", 512)
|
||||
mapboxMap!!.style!!.addSource(source)
|
||||
mapboxMap.style!!.addSource(source)
|
||||
|
||||
// Add a layer
|
||||
mapboxMap!!.style!!.addLayer(RasterLayer("satellite-layer", "my-raster-source"))
|
||||
mapboxMap.style!!.addLayer(RasterLayer("satellite-layer", "my-raster-source"))
|
||||
}
|
||||
|
||||
private fun updateWaterColorOnZoom() {
|
||||
val layer = mapboxMap!!.style!!.getLayerAs<FillLayer>("water") ?: return
|
||||
val layer = mapboxMap.style!!.getLayerAs<FillLayer>("water") ?: return
|
||||
|
||||
// Set a zoom function to update the color of the water
|
||||
layer.setProperties(
|
||||
@@ -535,7 +537,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
)
|
||||
|
||||
// do some animations to show it off properly
|
||||
mapboxMap!!.animateCamera(CameraUpdateFactory.zoomTo(1.0), 1500)
|
||||
mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(1.0), 1500)
|
||||
}
|
||||
|
||||
private fun addCustomTileSource() {
|
||||
@@ -545,7 +547,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
tileSet.minZoom = 0f
|
||||
tileSet.maxZoom = 14f
|
||||
val source: Source = VectorSource("custom-tile-source", tileSet)
|
||||
mapboxMap!!.style!!.addSource(source)
|
||||
mapboxMap.style!!.addSource(source)
|
||||
|
||||
// Add a layer
|
||||
val lineLayer = LineLayer("custom-tile-layers", "custom-tile-source")
|
||||
@@ -557,12 +559,12 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
PropertyFactory.lineWidth(2.0f),
|
||||
PropertyFactory.lineColor(Color.GREEN)
|
||||
)
|
||||
mapboxMap!!.style!!.addLayer(lineLayer)
|
||||
mapboxMap.style!!.addLayer(lineLayer)
|
||||
}
|
||||
|
||||
private fun styleFillColorLayer() {
|
||||
mapboxMap!!.setStyle(Style.Builder().fromUri("asset://fill_color_style.json"))
|
||||
mapboxMap!!.moveCamera(
|
||||
mapboxMap.setStyle(Style.Builder().fromUri("asset://fill_color_style.json"))
|
||||
mapboxMap.moveCamera(
|
||||
CameraUpdateFactory.newLatLngZoom(
|
||||
LatLng(31.0, (-100).toDouble()),
|
||||
3.0
|
||||
@@ -571,8 +573,8 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun styleFillFilterLayer() {
|
||||
mapboxMap!!.setStyle(Style.Builder().fromUri("asset://fill_filter_style.json"))
|
||||
mapboxMap!!.moveCamera(
|
||||
mapboxMap.setStyle(Style.Builder().fromUri("asset://fill_filter_style.json"))
|
||||
mapboxMap.moveCamera(
|
||||
CameraUpdateFactory.newLatLngZoom(
|
||||
LatLng(31.0, (-100).toDouble()),
|
||||
3.0
|
||||
@@ -585,7 +587,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
return@postDelayed
|
||||
}
|
||||
Timber.d("Styling filtered fill layer")
|
||||
val states = mapboxMap!!.style!!.getLayer("states") as FillLayer?
|
||||
val states = mapboxMap.style!!.getLayer("states") as FillLayer?
|
||||
if (states != null) {
|
||||
states.setFilter(Expression.eq(Expression.get("name"), Expression.literal("Texas")))
|
||||
states.fillOpacityTransition = TransitionOptions(2500, 0)
|
||||
@@ -607,8 +609,8 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun styleTextSizeFilterLayer() {
|
||||
mapboxMap!!.setStyle(Style.Builder().fromUri("asset://fill_filter_style.json"))
|
||||
mapboxMap!!.moveCamera(
|
||||
mapboxMap.setStyle(Style.Builder().fromUri("asset://fill_filter_style.json"))
|
||||
mapboxMap.moveCamera(
|
||||
CameraUpdateFactory.newLatLngZoom(
|
||||
LatLng(31.0, (-100).toDouble()),
|
||||
3.0
|
||||
@@ -621,7 +623,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
return@postDelayed
|
||||
}
|
||||
Timber.d("Styling text size fill layer")
|
||||
val states = mapboxMap!!.style!!.getLayer("state-label-lg") as SymbolLayer?
|
||||
val states = mapboxMap.style!!.getLayer("state-label-lg") as SymbolLayer?
|
||||
if (states != null) {
|
||||
states.setProperties(
|
||||
PropertyFactory.textSize(
|
||||
@@ -650,8 +652,8 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun styleLineFilterLayer() {
|
||||
mapboxMap!!.setStyle(Style.Builder().fromUri("asset://line_filter_style.json"))
|
||||
mapboxMap!!.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(40.0, (-97).toDouble()), 5.0))
|
||||
mapboxMap.setStyle(Style.Builder().fromUri("asset://line_filter_style.json"))
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(40.0, (-97).toDouble()), 5.0))
|
||||
val handler = Handler(mainLooper)
|
||||
handler.postDelayed(
|
||||
{
|
||||
@@ -659,7 +661,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
return@postDelayed
|
||||
}
|
||||
Timber.d("Styling filtered line layer")
|
||||
val counties = mapboxMap!!.style!!.getLayer("counties") as LineLayer?
|
||||
val counties = mapboxMap.style!!.getLayer("counties") as LineLayer?
|
||||
if (counties != null) {
|
||||
counties.setFilter(Expression.eq(Expression.get("NAME10"), "Washington"))
|
||||
counties.setProperties(
|
||||
@@ -680,8 +682,8 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun styleNumericFillLayer() {
|
||||
mapboxMap!!.setStyle(Style.Builder().fromUri("asset://numeric_filter_style.json"))
|
||||
mapboxMap!!.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(40.0, (-97).toDouble()), 5.0))
|
||||
mapboxMap.setStyle(Style.Builder().fromUri("asset://numeric_filter_style.json"))
|
||||
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LatLng(40.0, (-97).toDouble()), 5.0))
|
||||
val handler = Handler(mainLooper)
|
||||
handler.postDelayed(
|
||||
{
|
||||
@@ -689,7 +691,7 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
return@postDelayed
|
||||
}
|
||||
Timber.d("Styling numeric fill layer")
|
||||
val regions = mapboxMap!!.style!!.getLayer("regions") as FillLayer?
|
||||
val regions = mapboxMap.style!!.getLayer("regions") as FillLayer?
|
||||
if (regions != null) {
|
||||
regions.setFilter(
|
||||
Expression.all(
|
||||
@@ -720,10 +722,10 @@ class RuntimeStyleActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
private fun bringWaterToFront() {
|
||||
val water = mapboxMap!!.style!!.getLayer("water")
|
||||
val water = mapboxMap.style!!.getLayer("water")
|
||||
if (water != null) {
|
||||
mapboxMap!!.style!!.removeLayer(water)
|
||||
mapboxMap!!.style!!.addLayerAt(water, mapboxMap!!.style!!.layers.size - 1)
|
||||
mapboxMap.style!!.removeLayer(water)
|
||||
mapboxMap.style!!.addLayerAt(water, mapboxMap.style!!.layers.size - 1)
|
||||
} else {
|
||||
Toast.makeText(this, "No water layer in this style", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import com.mapbox.mapboxsdk.testapp.R
|
||||
* Test activity for unit test execution
|
||||
*/
|
||||
class RuntimeStyleTimingTestActivity : AppCompatActivity() {
|
||||
var mapView: MapView? = null
|
||||
var mapboxMap: MapboxMap? = null
|
||||
lateinit var mapView: MapView
|
||||
lateinit var mapboxMap: MapboxMap
|
||||
private set
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -23,8 +23,8 @@ class RuntimeStyleTimingTestActivity : AppCompatActivity() {
|
||||
|
||||
// Initialize map as normal
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync { mapboxMap: MapboxMap ->
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { mapboxMap: MapboxMap ->
|
||||
this@RuntimeStyleTimingTestActivity.mapboxMap = mapboxMap
|
||||
val parksLayer = CircleLayer("parks", "parks_source")
|
||||
parksLayer.sourceLayer = "parks"
|
||||
@@ -48,36 +48,36 @@ class RuntimeStyleTimingTestActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.ArrayList
|
||||
* Test stretchable image as a background for text..
|
||||
*/
|
||||
class StretchableImageActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var mapView: MapView
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -66,7 +66,7 @@ class StretchableImageActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
Timber.e("json is null.")
|
||||
return
|
||||
}
|
||||
val style = mapboxMap!!.style
|
||||
val style = mapboxMap.style
|
||||
if (style != null) {
|
||||
val featureCollection = FeatureCollection.fromJson(json)
|
||||
val stretchSource = GeoJsonSource(STRETCH_SOURCE, featureCollection)
|
||||
@@ -125,37 +125,37 @@ class StretchableImageActivity : AppCompatActivity(), OnMapReadyCallback {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.lang.ref.WeakReference
|
||||
* Test activity showcasing how to use a file:// resource for the style.json and how to use MapboxMap#setStyleJson.
|
||||
*/
|
||||
class StyleFileActivity : AppCompatActivity() {
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var mapView: MapView
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -33,8 +33,10 @@ class StyleFileActivity : AppCompatActivity() {
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(
|
||||
OnMapReadyCallback { map: MapboxMap? ->
|
||||
mapboxMap = map
|
||||
mapboxMap!!.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? ->
|
||||
if (map != null) {
|
||||
mapboxMap = map
|
||||
}
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Streets")) { style: Style? ->
|
||||
val fab = findViewById<FloatingActionButton>(R.id.fab_file)
|
||||
fab.setColorFilter(ContextCompat.getColor(this@StyleFileActivity, R.color.primary))
|
||||
fab.setOnClickListener { view: View ->
|
||||
@@ -149,36 +151,36 @@ class StyleFileActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ class SymbolLayerActivity : AppCompatActivity(), OnMapClickListener, OnMapReadyC
|
||||
private var markerSymbolLayer: SymbolLayer? = null
|
||||
private var mapboxSignSymbolLayer: SymbolLayer? = null
|
||||
private var numberFormatSymbolLayer: SymbolLayer? = null
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private var mapView: MapView? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private lateinit var mapView: MapView
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_symbollayer)
|
||||
@@ -69,13 +69,13 @@ class SymbolLayerActivity : AppCompatActivity(), OnMapClickListener, OnMapReadyC
|
||||
|
||||
// Create map programmatically, add to view hierarchy
|
||||
mapView = MapView(this, mapboxMapOptions)
|
||||
mapView!!.getMapAsync(this)
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync(this)
|
||||
mapView.onCreate(savedInstanceState)
|
||||
(findViewById<View>(R.id.container) as ViewGroup).addView(mapView)
|
||||
|
||||
// Use OnStyleImageMissing API to lazily load an icon
|
||||
mapView!!.addOnStyleImageMissingListener { id: String? ->
|
||||
val style = mapboxMap!!.style
|
||||
mapView.addOnStyleImageMissingListener { id: String? ->
|
||||
val style = mapboxMap.style
|
||||
if (style != null) {
|
||||
Timber.e("Adding image with id: %s", id)
|
||||
val androidIcon =
|
||||
@@ -167,8 +167,8 @@ class SymbolLayerActivity : AppCompatActivity(), OnMapClickListener, OnMapReadyC
|
||||
|
||||
override fun onMapClick(point: LatLng): Boolean {
|
||||
// Query which features are clicked
|
||||
val screenLoc = mapboxMap!!.projection.toScreenLocation(point)
|
||||
val markerFeatures = mapboxMap!!.queryRenderedFeatures(screenLoc, MARKER_LAYER)
|
||||
val screenLoc = mapboxMap.projection.toScreenLocation(point)
|
||||
val markerFeatures = mapboxMap.queryRenderedFeatures(screenLoc, MARKER_LAYER)
|
||||
if (!markerFeatures.isEmpty()) {
|
||||
for (feature in Objects.requireNonNull(markerCollection!!.features())!!) {
|
||||
if (feature.getStringProperty(ID_FEATURE_PROPERTY)
|
||||
@@ -195,7 +195,7 @@ class SymbolLayerActivity : AppCompatActivity(), OnMapClickListener, OnMapReadyC
|
||||
}
|
||||
markerSource!!.setGeoJson(markerCollection)
|
||||
} else {
|
||||
val mapboxSignFeatures = mapboxMap!!.queryRenderedFeatures(screenLoc, MAPBOX_SIGN_LAYER)
|
||||
val mapboxSignFeatures = mapboxMap.queryRenderedFeatures(screenLoc, MAPBOX_SIGN_LAYER)
|
||||
if (!mapboxSignFeatures.isEmpty()) {
|
||||
shuffleMapboxSign()
|
||||
}
|
||||
@@ -282,40 +282,40 @@ class SymbolLayerActivity : AppCompatActivity(), OnMapClickListener, OnMapReadyC
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap!!.removeOnMapClickListener(this)
|
||||
mapboxMap.removeOnMapClickListener(this)
|
||||
}
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
|
||||
@@ -26,20 +26,20 @@ import timber.log.Timber
|
||||
*/
|
||||
class ZoomFunctionSymbolLayerActivity : AppCompatActivity() {
|
||||
private lateinit var mapView: MapView
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var source: GeoJsonSource? = null
|
||||
private var layer: SymbolLayer? = null
|
||||
private var isInitialPosition = true
|
||||
private var isSelected = false
|
||||
private var isShowingSymbolLayer = true
|
||||
private val mapClickListener = OnMapClickListener { point ->
|
||||
val screenPoint = mapboxMap!!.projection.toScreenLocation(point)
|
||||
val featureList = mapboxMap!!.queryRenderedFeatures(screenPoint, LAYER_ID)
|
||||
val screenPoint = mapboxMap.projection.toScreenLocation(point)
|
||||
val featureList = mapboxMap.queryRenderedFeatures(screenPoint, LAYER_ID)
|
||||
if (!featureList.isEmpty()) {
|
||||
val feature = featureList[0]
|
||||
val selectedNow = feature.getBooleanProperty(KEY_PROPERTY_SELECTED)
|
||||
isSelected = !selectedNow
|
||||
updateSource(mapboxMap!!.style)
|
||||
updateSource(mapboxMap.style)
|
||||
} else {
|
||||
Timber.e("No features found")
|
||||
}
|
||||
@@ -123,7 +123,7 @@ class ZoomFunctionSymbolLayerActivity : AppCompatActivity() {
|
||||
if (mapboxMap != null) {
|
||||
if (item.itemId == R.id.menu_action_change_location) {
|
||||
isInitialPosition = !isInitialPosition
|
||||
updateSource(mapboxMap!!.style)
|
||||
updateSource(mapboxMap.style)
|
||||
} else if (item.itemId == R.id.menu_action_toggle_source) {
|
||||
toggleSymbolLayerVisibility()
|
||||
}
|
||||
@@ -133,37 +133,37 @@ class ZoomFunctionSymbolLayerActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
public override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
public override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -17,8 +17,8 @@ import java.util.*
|
||||
* Test animating a [android.view.TextureView] backed map.
|
||||
*/
|
||||
class TextureViewAnimationActivity : AppCompatActivity() {
|
||||
private var mapView: MapView? = null
|
||||
private var mapboxMap: MapboxMap? = null
|
||||
private lateinit var mapView: MapView
|
||||
private lateinit var mapboxMap: MapboxMap
|
||||
private var handler: Handler? = null
|
||||
private var delayed: Runnable? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -39,7 +39,7 @@ class TextureViewAnimationActivity : AppCompatActivity() {
|
||||
|
||||
private fun setupMapView(savedInstanceState: Bundle?) {
|
||||
mapView = findViewById<View>(R.id.mapView) as MapView
|
||||
mapView!!.getMapAsync { mapboxMap: MapboxMap ->
|
||||
mapView.getMapAsync { mapboxMap: MapboxMap ->
|
||||
this@TextureViewAnimationActivity.mapboxMap = mapboxMap
|
||||
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"))
|
||||
setFpsView(mapboxMap)
|
||||
@@ -86,22 +86,22 @@ class TextureViewAnimationActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
if (handler != null && delayed != null) {
|
||||
handler!!.removeCallbacks(delayed!!)
|
||||
}
|
||||
@@ -109,17 +109,17 @@ class TextureViewAnimationActivity : AppCompatActivity() {
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -44,46 +44,46 @@ class TextureViewResizeActivity : AppCompatActivity() {
|
||||
fabDebug.setOnClickListener { view: View? ->
|
||||
if (mapView != null) {
|
||||
val parent = findViewById<View>(R.id.coordinator_layout)
|
||||
val width = if (parent.width == mapView!!.width) parent.width / 2 else parent.width
|
||||
val width = if (parent.width == mapView.width) parent.width / 2 else parent.width
|
||||
val height =
|
||||
if (parent.height == mapView!!.height) parent.height / 2 else parent.height
|
||||
mapView!!.layoutParams = CoordinatorLayout.LayoutParams(width, height)
|
||||
if (parent.height == mapView.height) parent.height / 2 else parent.height
|
||||
mapView.layoutParams = CoordinatorLayout.LayoutParams(width, height)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.io.IOException
|
||||
* Example showcasing how to create a TextureView with a transparent background.
|
||||
*/
|
||||
class TextureViewTransparentBackgroundActivity : AppCompatActivity() {
|
||||
private var mapView: MapView? = null
|
||||
private lateinit var mapView: MapView
|
||||
private val mapboxMap: MapboxMap? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@@ -43,8 +43,8 @@ class TextureViewTransparentBackgroundActivity : AppCompatActivity() {
|
||||
.build()
|
||||
)
|
||||
mapView = MapView(this, mapboxMapOptions)
|
||||
mapView!!.onCreate(savedInstanceState)
|
||||
mapView!!.getMapAsync { mapboxMap: MapboxMap -> initMap(mapboxMap) }
|
||||
mapView.onCreate(savedInstanceState)
|
||||
mapView.getMapAsync { mapboxMap: MapboxMap -> initMap(mapboxMap) }
|
||||
(findViewById<View>(R.id.coordinator_layout) as ViewGroup).addView(mapView)
|
||||
}
|
||||
|
||||
@@ -60,36 +60,36 @@ class TextureViewTransparentBackgroundActivity : AppCompatActivity() {
|
||||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
mapView!!.onStart()
|
||||
mapView.onStart()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mapView!!.onResume()
|
||||
mapView.onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
mapView!!.onPause()
|
||||
mapView.onPause()
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
mapView!!.onStop()
|
||||
mapView.onStop()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
mapView!!.onSaveInstanceState(outState)
|
||||
mapView.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
mapView!!.onDestroy()
|
||||
mapView.onDestroy()
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
mapView!!.onLowMemory()
|
||||
mapView.onLowMemory()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user