mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 01:45:05 +08:00
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 }
|
||||
}
|
||||
}
|
||||
// TODO. MapTiler
|
||||
mavenCentral()
|
||||
google {
|
||||
content {
|
||||
groups.google.regex.each { includeGroupByRegex it }
|
||||
|
@ -486,6 +486,9 @@ dependencies {
|
||||
}
|
||||
implementation 'commons-codec:commons-codec:1.15'
|
||||
|
||||
// MapTiler
|
||||
implementation 'org.maplibre.gl:android-sdk:9.5.2'
|
||||
|
||||
|
||||
// TESTS
|
||||
testImplementation libs.tests.junit
|
||||
|
@ -21,6 +21,8 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
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.databinding.FragmentLocationSharingBinding
|
||||
import javax.inject.Inject
|
||||
@ -34,7 +36,24 @@ class LocationSharingFragment @Inject constructor() :
|
||||
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?) {
|
||||
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_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>
|
Loading…
Reference in New Issue
Block a user