Skip to content

Commit

Permalink
Downgrade MapLibre to version 10.2.0.
Browse files Browse the repository at this point in the history
This was made for compatibility with `ramani-maps`.

Changes were mostly changes to imports.
  • Loading branch information
alejandrocalles authored and octogradiste committed May 12, 2024
1 parent dce74c6 commit 3d908ee
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ dependencies {

// Map Libre
implementation(libs.android.sdk)
implementation(libs.ramani.maplibre)

// Hilt
implementation(libs.hilt.android)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@ import android.annotation.SuppressLint
import android.content.Context
import com.github.swent.echo.R
import com.github.swent.echo.data.model.Event
import org.maplibre.android.MapLibre
import org.maplibre.android.annotations.MarkerOptions
import org.maplibre.android.camera.CameraPosition
import org.maplibre.android.geometry.LatLng
import org.maplibre.android.location.LocationComponent
import org.maplibre.android.location.LocationComponentActivationOptions
import org.maplibre.android.location.LocationComponentOptions
import org.maplibre.android.location.engine.LocationEngineRequest
import org.maplibre.android.location.modes.CameraMode
import org.maplibre.android.maps.MapLibreMap
import org.maplibre.android.maps.MapView
import org.maplibre.android.maps.Style
import com.mapbox.mapboxsdk.Mapbox
import com.mapbox.mapboxsdk.annotations.MarkerOptions
import com.mapbox.mapboxsdk.camera.CameraPosition
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.location.LocationComponent
import com.mapbox.mapboxsdk.location.LocationComponentActivationOptions
import com.mapbox.mapboxsdk.location.LocationComponentOptions
import com.mapbox.mapboxsdk.location.engine.LocationEngineRequest
import com.mapbox.mapboxsdk.location.modes.CameraMode
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMap
import com.mapbox.mapboxsdk.maps.Style

class MapLibreMapViewProvider : IMapViewProvider<MapView> {

private var mapView: MapView? = null
private var locationComponent: LocationComponent? = null
private var firstRecenter = true

private fun redrawMarkers(map: MapLibreMap, events: List<Event>, callback: (Event) -> Unit) {
private fun redrawMarkers(map: MapboxMap, events: List<Event>, callback: (Event) -> Unit) {
map.markers.forEach { map.removeMarker(it) }
events.forEach {
val markerBuilder = MarkerOptions().setPosition(it.location.toLatLng()).title(it.title)
Expand All @@ -37,7 +37,7 @@ class MapLibreMapViewProvider : IMapViewProvider<MapView> {
}

@SuppressLint("MissingPermission")
private fun displayLocation(context: Context, map: MapLibreMap, style: Style) {
private fun displayLocation(context: Context, map: MapboxMap, style: Style) {
locationComponent = map.locationComponent
val locationComponentOptions =
LocationComponentOptions.builder(context).pulseEnabled(true).build()
Expand Down Expand Up @@ -66,7 +66,7 @@ class MapLibreMapViewProvider : IMapViewProvider<MapView> {
}

override fun factory(context: Context, withLocation: Boolean, onCreate: () -> Unit): MapView {
MapLibre.getInstance(context)
Mapbox.getInstance(context)
val styleUrl =
context.getString(R.string.maptiler_base_style_url) +
context.getString(R.string.maptiler_api_key)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import com.github.swent.echo.data.model.Event
import com.github.swent.echo.data.model.EventCreator
import com.github.swent.echo.data.model.Location
import com.github.swent.echo.data.model.Tag
import com.mapbox.mapboxsdk.geometry.LatLng
import java.time.ZonedDateTime
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
import org.maplibre.android.geometry.LatLng

// This should come from the repository

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.swent.echo.data.model

import com.mapbox.mapboxsdk.geometry.LatLng
import kotlinx.serialization.Serializable
import org.maplibre.android.geometry.LatLng

@Serializable
data class Location(val name: String, val lat: Double, val long: Double) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.github.swent.echo.compose.map

import com.mapbox.mapboxsdk.maps.MapView
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import org.junit.Before
import org.junit.Test
import org.maplibre.android.maps.MapView

class MapLibreMapViewProviderTest {

Expand Down
7 changes: 6 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ agp = "8.3.1"
credentials = "1.2.2"
googleid = "1.1.0"
hiltNavigationCompose = "1.2.0"
androidSdk = "11.0.0-pre6"
#####################
# Do not upgrade
androidSdk = "10.2.0"
#####################
kotlinxSerializationJson = "1.6.3"
ktorClientAndroid = "2.3.9"
ramaniMaplibre = "0.3.0"
robolectric = "4.12"
roomRuntime = "2.6.1"
slf4jSimple = "1.7.36"
Expand Down Expand Up @@ -42,6 +46,7 @@ hilt-android-testing = { module = "com.google.dagger:hilt-android-testing", vers
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinxSerializationJson" }
ktor-client-android = { module = "io.ktor:ktor-client-android", version.ref = "ktorClientAndroid" }
mockk-android = { module = "io.mockk:mockk-android", version.ref = "mockk" }
ramani-maplibre = { module = "org.ramani-maps:ramani-maplibre", version.ref = "ramaniMaplibre" }
robolectric = { module = "org.robolectric:robolectric", version.ref = "robolectric" }
slf4j-simple = { module = "org.slf4j:slf4j-simple", version.ref = "slf4jSimple" }
supabase-bom = { module = "io.github.jan-tennert.supabase:bom", version.ref = "supabase" }
Expand Down

0 comments on commit 3d908ee

Please sign in to comment.