modifie la position de la camera en fct de la géocalisation

master
Bastien OLLIER 2 years ago
parent da2c34ceac
commit 2250cf71fa

@ -16,6 +16,7 @@ import androidx.core.content.res.ResourcesCompat
import androidx.fragment.app.Fragment
import com.google.gson.JsonParser
import com.mapbox.mapboxsdk.Mapbox
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory
import com.mapbox.mapboxsdk.geometry.LatLng
import com.mapbox.mapboxsdk.maps.MapView
import com.mapbox.mapboxsdk.plugins.annotation.Symbol
@ -79,12 +80,17 @@ class FirstFragment: Fragment(R.layout.fragment_map_page) {
Log.e("Debug","${locationListener.latitude},${locationListener.latitude}")
listRestaurant = getRestaurants(locationListener.latitude,locationListener.latitude,1000000)
if(listRestaurant.isEmpty()){
Toast.makeText(requireContext(), "Pas de restaurants trouver", Toast.LENGTH_SHORT).show()
}
mapView?.getMapAsync { map ->
map.animateCamera(CameraUpdateFactory.newLatLngZoom(
LatLng(locationListener.latitude, locationListener.longitude), 11.0))
map.setStyle(makeStyleUrl()) { style ->
map.uiSettings.setAttributionMargins(15, 0, 0, 15)
// Add an icons ("classic" and "selected") to the map style.

@ -25,9 +25,9 @@
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapbox_cameraTargetLat="51.5073509"
mapbox:mapbox_cameraTargetLng="-0.1277583"
mapbox:mapbox_cameraZoom="11"
mapbox:mapbox_cameraTargetLat="0"
mapbox:mapbox_cameraTargetLng="0"
mapbox:mapbox_cameraZoom="1"
mapbox:mapbox_uiAttribution="true"
mapbox:mapbox_uiLogo="false">

Loading…
Cancel
Save