Adding OpenStreetMap view

pull/4/head
Arthur VALIN 2 years ago
parent 984c6c31b7
commit 3a71233073

@ -1,6 +1,7 @@
plugins { plugins {
id 'com.android.application' id 'com.android.application'
id 'org.jetbrains.kotlin.android' id 'org.jetbrains.kotlin.android'
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
} }
android { android {
@ -40,4 +41,6 @@ dependencies {
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
implementation "androidx.fragment:fragment-ktx:1.5.5"
implementation 'org.osmdroid:osmdroid-android:6.1.14'
} }

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools" >
<application <application
android:allowBackup="true" android:allowBackup="true"
@ -11,15 +11,37 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.Geocaching" android:theme="@style/Theme.Geocaching"
tools:targetApi="31"> tools:targetApi="31" >
<activity android:name=".MainWindow" android:exported="true"> <!--
TODO: Before you run your application, you need a Google Maps API key.
To get one, follow the directions here:
https://developers.google.com/maps/documentation/android-sdk/get-api-key
Once you have your API key (it starts with "AIza"), define a new property in your
project's local.properties file (e.g. MAPS_API_KEY=Aiza...), and replace the
"YOUR_API_KEY" string in this file with "${MAPS_API_KEY}".
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY" />
<activity
android:name=".MainWindow"
android:exported="true" >
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
</application> </application>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest> </manifest>

@ -3,10 +3,16 @@ package uca.baptistearthur.geocaching
import android.os.Bundle import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import org.osmdroid.config.Configuration
class MainWindow: AppCompatActivity() { class MainWindow: AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
Configuration.getInstance().userAgentValue = "Geocaching"
// Set the user agent for OsmDroid
setContentView(R.layout.main_window) setContentView(R.layout.main_window)
} }

@ -6,8 +6,6 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<!-- Trouver un moyen de virer le menu par défaut ou le garder et virer le frameLayout en dessous-->
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
@ -20,13 +18,14 @@
android:textSize="20sp" android:textSize="20sp"
android:textStyle="bold" /> android:textStyle="bold" />
<!-- Ici map, j'ai essayé de télécharger la map de google dans "Design" mais ca a cassé le projet donc à éviter pour l'instant je pense--> <org.osmdroid.views.MapView
<View android:id="@+id/mapView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="8"></View> android:layout_weight="8"
android:clickable="true"
android:focusable="true" />
<!-- Faire un composant pour éviter la répétition ?-->
<com.google.android.material.bottomnavigation.BottomNavigationView <com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation" android:id="@+id/bottom_navigation"
android:layout_width="match_parent" android:layout_width="match_parent"

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item <item
android:id="@+id/profile" android:id="@+id/profile"
android:enabled="true" android:enabled="true"
@ -15,4 +15,4 @@
android:enabled="true" android:enabled="true"
android:title="@string/liste" android:title="@string/liste"
android:icon="@drawable/list" /> android:icon="@drawable/list" />
</menu> </menu>

@ -3,4 +3,5 @@ plugins {
id 'com.android.application' version '7.3.0' apply false id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false id 'com.android.library' version '7.3.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' version '2.0.1' apply false
} }

@ -3,6 +3,7 @@ pluginManagement {
gradlePluginPortal() gradlePluginPortal()
google() google()
mavenCentral() mavenCentral()
} }
} }
dependencyResolutionManagement { dependencyResolutionManagement {

Loading…
Cancel
Save