master
Bastien OLLIER 2 years ago
parent ae2dee36e3
commit f7a94e1700

@ -10,10 +10,11 @@ android {
defaultConfig {
applicationId "fr.iut.mapping"
minSdk 16
targetSdk 32
minSdk 19
targetSdk 33
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@ -31,17 +32,23 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'org.maplibre.gl:android-sdk:9.5.2'
//implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.5.0'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.fragment:fragment-ktx:1.5.5'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.8.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.android.material:material:1.2.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation 'com.google.android.material:material:1.2.0'
}

@ -2,6 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
@ -18,9 +20,8 @@
<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
</application>
</manifest>

@ -3,6 +3,7 @@ package fr.iut.mapping
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.Fragment
import com.mapbox.mapboxsdk.Mapbox
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
@ -10,6 +11,8 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
/*navBar*/
val firstFragment=FirstFragment()
val secondFragment=SecondFragment()

@ -1,6 +1,77 @@
package fr.iut.mapping
import android.os.Bundle
import android.provider.Settings.Global.getString
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.mapbox.mapboxsdk.Mapbox
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.maps.MapboxMapOptions
import com.mapbox.mapboxsdk.maps.Style
class FirstFragment:Fragment(R.layout.fragment_map_page) {
private var mapView: MapView? = null
// Returns the Jawg url depending on the style given (jawg-streets by default)
// See /res/values/strings which contains the url, the list of styles and your access token.
private fun makeStyleUrl(): String {
print("${getString(R.string.mapbox_style_url)}")
return "${getString(R.string.mapbox_style_url)}";
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
super.onCreate(savedInstanceState)
Mapbox.getInstance(requireContext())
// Inflate the layout for this fragment
val rootView = inflater.inflate(R.layout.fragment_map_page, container, false)
// We get the map view to set its style with the desired Jawg url.
mapView = rootView.findViewById(R.id.mapView)
mapView?.onCreate(savedInstanceState)
mapView?.getMapAsync { map ->
map.setStyle(makeStyleUrl()) {
// Map fully loaded in this scope.
// Update attributions position
map.uiSettings.setAttributionMargins(15, 0, 0, 15)
}
}
return rootView
}
override fun onStart() {
super.onStart()
mapView?.onStart()
}
override fun onResume() {
super.onResume()
mapView?.onResume()
}
override fun onPause() {
super.onPause()
mapView?.onPause()
}
override fun onStop() {
super.onStop()
mapView?.onStop()
}
override fun onLowMemory() {
super.onLowMemory()
mapView?.onLowMemory()
}
override fun onDestroy() {
super.onDestroy()
mapView?.onDestroy()
}
}

@ -1,14 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapPage">
android:layout_height="match_parent">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/mapPage" />
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>

@ -3,4 +3,6 @@
<!-- TODO: Remove or change this placeholder text -->
<string name="likesPage">likes page</string>
<string name="mapPage">mapPage</string>
<string name="mapbox_access_token">BrSQRu6QFT4Q4zQVBux0vT9bkiOFpQUrEWGyBnYddcBo4hY1e60eYnSs50rLmFP4</string>
<string name="mapbox_style_url">https://tile.jawg.io/jawg-streets.json?access-token=BrSQRu6QFT4Q4zQVBux0vT9bkiOFpQUrEWGyBnYddcBo4hY1e60eYnSs50rLmFP4</string>
</resources>

@ -21,3 +21,4 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.enableJetifier=true
Loading…
Cancel
Save