diff --git a/app/src/main/java/fr/iut/mapping/MainActivity.kt b/app/src/main/java/fr/iut/mapping/MainActivity.kt index 823172d..85a29af 100644 --- a/app/src/main/java/fr/iut/mapping/MainActivity.kt +++ b/app/src/main/java/fr/iut/mapping/MainActivity.kt @@ -3,6 +3,7 @@ package fr.iut.mapping import android.Manifest.permission.ACCESS_COARSE_LOCATION import android.Manifest.permission.ACCESS_FINE_LOCATION +import android.location.Location import android.os.Build import androidx.appcompat.app.AppCompatActivity import android.os.Bundle diff --git a/app/src/main/java/fr/iut/mapping/MapPage.kt b/app/src/main/java/fr/iut/mapping/MapPage.kt index 6f9ad9b..2a57008 100644 --- a/app/src/main/java/fr/iut/mapping/MapPage.kt +++ b/app/src/main/java/fr/iut/mapping/MapPage.kt @@ -8,7 +8,6 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.LinearLayout -import android.widget.Toast import androidx.annotation.RequiresApi import androidx.core.content.ContextCompat import androidx.core.content.res.ResourcesCompat @@ -35,8 +34,6 @@ class FirstFragment: Fragment(R.layout.fragment_map_page), LocationListener { private var symbolManager: SymbolManager? = null private var lastSymbol: Symbol? = null - private val locationPermissionCode = 2 - private fun makeStyleUrl(): String { return "${getString(R.string.mapbox_style_url)}"; } @@ -54,6 +51,7 @@ class FirstFragment: Fragment(R.layout.fragment_map_page), LocationListener { mapView?.getMapAsync { map -> map.setStyle(makeStyleUrl()) { style -> map.uiSettings.setAttributionMargins(15, 0, 0, 15) + // Add an icons ("classic" and "selected") to the map style. val selectedMarkerIconDrawable = ResourcesCompat.getDrawable(this.resources, R.drawable.ic_menu_likes, null) style.addImage(MARKER_ICON, BitmapUtils.getBitmapFromDrawable(selectedMarkerIconDrawable)!!) val markerIconDrawable = ResourcesCompat.getDrawable(this.resources, R.drawable.ic_menu_likes, null) @@ -64,20 +62,16 @@ class FirstFragment: Fragment(R.layout.fragment_map_page), LocationListener { this.symbolManager?.iconAllowOverlap = true this.symbolManager?.iconIgnorePlacement = true - // Insert markers with their associated data. insertIconOnMap( LatLng(51.50853, -0.076132), "Tower of London", R.drawable.ic_menu_likes, - "It is a historic castle on the north bank of the River Thames in central London." + - "It lies within the London Borough of Tower Hamlets, which is separated from the eastern edge of the square mile of the City of London by the open space known as Tower Hill." + - "It was founded towards the end of 1066 as part of the Norman Conquest of England." + "It is a historic castle on the north bank of the River Thames in central London." ) // Add a listener to trigger markers clicks. this.symbolManager?.addClickListener { // Put all marker information into the layout. - titleView.text = it.data?.asJsonObject?.get("title")?.asString descriptionView.text = it.data?.asJsonObject?.get("description")?.asString descriptionLayout.background = ContextCompat.getDrawable(requireContext(),it.data?.asJsonObject?.get("imageId")?.asInt!!) @@ -87,6 +81,7 @@ class FirstFragment: Fragment(R.layout.fragment_map_page), LocationListener { toggleLayout() true } + } } @@ -94,7 +89,7 @@ class FirstFragment: Fragment(R.layout.fragment_map_page), LocationListener { } private fun toggleLayout() { - mapView?.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 2f) + mapLayout?.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 2f) descriptionLayout?.layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, 1f) } @@ -126,13 +121,12 @@ class FirstFragment: Fragment(R.layout.fragment_map_page), LocationListener { """ // Add symbol at specified lat/lon. val newSymbol = symbolManager!!.create( - SymbolOptions() - .withLatLng(LatLng(point.latitude, point.longitude)) - .withData(JsonParser.parseString(jsonData)) + SymbolOptions().withLatLng(LatLng(point.latitude, point.longitude)).withData(JsonParser.parseString(jsonData)) ) setDefaultIcon(newSymbol) } + override fun onStart() { super.onStart() mapView?.onStart()