diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 82dbdfdf..bb75ea16 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -22,6 +22,7 @@ package="com.rtbishop.look4sat"> + { this.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE toolbar.visibility = View.GONE + mainBinding.includeAppBar.toolbarLayout.visibility = View.GONE + } + R.id.nav_map_osm -> { + this.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + toolbar.visibility = View.GONE + mainBinding.includeAppBar.toolbarLayout.visibility = View.GONE } else -> { this.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT diff --git a/app/src/main/java/com/rtbishop/look4sat/ui/fragments/MapOsmFragment.kt b/app/src/main/java/com/rtbishop/look4sat/ui/fragments/MapOsmFragment.kt new file mode 100644 index 00000000..21c8e0f6 --- /dev/null +++ b/app/src/main/java/com/rtbishop/look4sat/ui/fragments/MapOsmFragment.kt @@ -0,0 +1,73 @@ +package com.rtbishop.look4sat.ui.fragments + +import android.os.Bundle +import android.view.View +import androidx.fragment.app.Fragment +import androidx.preference.PreferenceManager +import com.rtbishop.look4sat.R +import com.rtbishop.look4sat.databinding.FragmentMapOsmBinding +import org.osmdroid.config.Configuration +import org.osmdroid.tileprovider.tilesource.TileSourceFactory +import org.osmdroid.util.GeoPoint +import org.osmdroid.views.MapView +import org.osmdroid.views.overlay.OverlayItem + +class MapOsmFragment : Fragment(R.layout.fragment_map_osm) { + + private lateinit var binding: FragmentMapOsmBinding + private lateinit var mapView: MapView + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + val appContext = requireActivity().applicationContext + + binding = FragmentMapOsmBinding.bind(view) + binding.mapView.apply { + controller.animateTo(mapCenter) + controller.setZoom(2.5) + setMultiTouchControls(true) + maxZoomLevel = 7.5 + minZoomLevel = 2.5 +// isClickable = true +// setScrollableAreaLimitLatitude(-90.0, 90.0, 0) +// setScrollableAreaLimitLongitude(-180.0, 180.0, 0) + } + + Configuration + .getInstance() + .load(appContext, PreferenceManager.getDefaultSharedPreferences(appContext)) + + init() + } + + private fun init() { + mapView.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE) + val gPt = GeoPoint(28.6337874, 77.35767599999997) + val gPt2 = GeoPoint(28.638472, 77.360667) + mapView.controller.setCenter(gPt) + + /*place icon on map*/ + val items = ArrayList() + items.add(OverlayItem("Current Location", "Amrapali Village, Indirapuram", gPt)) + items.add(OverlayItem("Destination", "Aditya Mall, Indirapuram", gPt2)) + } + + override fun onResume() { + super.onResume() + //this will refresh the osmdroid configuration on resuming. + //if you make changes to the configuration, use + //SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + //Configuration.getInstance().load(this, PreferenceManager.getDefaultSharedPreferences(this)); + mapView.onResume() //needed for compass, my location overlays, v6.0.0 and up + } + + override fun onPause() { + super.onPause() + //this will refresh the osmdroid configuration on resuming. + //if you make changes to the configuration, use + //SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + //Configuration.getInstance().save(this, prefs); + mapView.onPause() //needed for compass, my location overlays, v6.0.0 and up + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_map_osm.xml b/app/src/main/res/layout/fragment_map_osm.xml new file mode 100644 index 00000000..130326e9 --- /dev/null +++ b/app/src/main/res/layout/fragment_map_osm.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/app/src/main/res/menu/drawer_menu.xml b/app/src/main/res/menu/drawer_menu.xml index 01a3b951..3dde480b 100644 --- a/app/src/main/res/menu/drawer_menu.xml +++ b/app/src/main/res/menu/drawer_menu.xml @@ -39,5 +39,9 @@ android:id="@+id/nav_about" android:icon="@drawable/ic_about" android:title="@string/menu_about" /> + diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml index 2653ac8e..d6557887 100644 --- a/app/src/main/res/navigation/nav_graph.xml +++ b/app/src/main/res/navigation/nav_graph.xml @@ -1,5 +1,4 @@ - -