Skip to content

Commit

Permalink
Add mapview to the layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
Onuray Sahin committed Dec 15, 2021
1 parent bf48617 commit 824e713
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ allprojects {
groups.jitsi.group.each { includeGroup it }
}
}
// TODO. MapTiler
mavenCentral()
google {
content {
groups.google.regex.each { includeGroupByRegex it }
Expand Down
3 changes: 3 additions & 0 deletions vector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}
}
5 changes: 5 additions & 0 deletions vector/src/main/res/layout/fragment_location_sharing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

0 comments on commit 824e713

Please sign in to comment.