Add mapview to the layout.
This commit is contained in:
parent
bf48617fc6
commit
824e713c51
|
@ -61,6 +61,8 @@ allprojects {
|
||||||
groups.jitsi.group.each { includeGroup it }
|
groups.jitsi.group.each { includeGroup it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO. MapTiler
|
||||||
|
mavenCentral()
|
||||||
google {
|
google {
|
||||||
content {
|
content {
|
||||||
groups.google.regex.each { includeGroupByRegex it }
|
groups.google.regex.each { includeGroupByRegex it }
|
||||||
|
|
|
@ -486,6 +486,9 @@ dependencies {
|
||||||
}
|
}
|
||||||
implementation 'commons-codec:commons-codec:1.15'
|
implementation 'commons-codec:commons-codec:1.15'
|
||||||
|
|
||||||
|
// MapTiler
|
||||||
|
implementation 'org.maplibre.gl:android-sdk:9.5.2'
|
||||||
|
|
||||||
|
|
||||||
// TESTS
|
// TESTS
|
||||||
testImplementation libs.tests.junit
|
testImplementation libs.tests.junit
|
||||||
|
|
|
@ -21,6 +21,8 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import com.airbnb.mvrx.activityViewModel
|
import com.airbnb.mvrx.activityViewModel
|
||||||
|
import com.mapbox.mapboxsdk.Mapbox
|
||||||
|
import im.vector.app.BuildConfig
|
||||||
import im.vector.app.core.platform.VectorBaseFragment
|
import im.vector.app.core.platform.VectorBaseFragment
|
||||||
import im.vector.app.databinding.FragmentLocationSharingBinding
|
import im.vector.app.databinding.FragmentLocationSharingBinding
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -34,7 +36,24 @@ class LocationSharingFragment @Inject constructor() :
|
||||||
return FragmentLocationSharingBinding.inflate(inflater, container, false)
|
return FragmentLocationSharingBinding.inflate(inflater, container, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
// Initialize Mapbox before inflating mapView
|
||||||
|
Mapbox.getInstance(requireContext())
|
||||||
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
initMapView(savedInstanceState)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initMapView(savedInstanceState: Bundle?) {
|
||||||
|
val key = BuildConfig.mapTilerKey
|
||||||
|
val styleUrl = "https://api.maptiler.com/maps/streets/style.json?key=${key}"
|
||||||
|
views.mapView.onCreate(savedInstanceState)
|
||||||
|
views.mapView.getMapAsync { map ->
|
||||||
|
map.setStyle(styleUrl)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,9 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<com.mapbox.mapboxsdk.maps.MapView
|
||||||
|
android:id="@+id/mapView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue