mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-05 03:57:24 +00:00
Initial OSM setup
This commit is contained in:
1 parent
85c01f05af
commit
770fb9b244
6 files changed
+98
-2
No files matched your search
@@ -22,6 +22,7 @@
|
|||||||
package="com.rtbishop.look4sat">
|
package="com.rtbishop.look4sat">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
|||||||
@@ -109,6 +109,12 @@ class MainActivity : AppCompatActivity(), TleSourcesDialogFragment.SourcesSubmit
|
|||||||
R.id.nav_map_view -> {
|
R.id.nav_map_view -> {
|
||||||
this.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
this.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
|
||||||
toolbar.visibility = View.GONE
|
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 -> {
|
else -> {
|
||||||
this.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
this.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
|
|||||||
@@ -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<OverlayItem>()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<org.osmdroid.views.MapView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/mapView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.fragments.MapOsmFragment" />
|
||||||
@@ -39,5 +39,9 @@
|
|||||||
android:id="@+id/nav_about"
|
android:id="@+id/nav_about"
|
||||||
android:icon="@drawable/ic_about"
|
android:icon="@drawable/ic_about"
|
||||||
android:title="@string/menu_about" />
|
android:title="@string/menu_about" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/nav_map_osm"
|
||||||
|
android:icon="@drawable/ic_world_map"
|
||||||
|
android:title="@string/placeholder" />
|
||||||
</group>
|
</group>
|
||||||
</menu>
|
</menu>
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
<!--
|
|
||||||
~ Look4Sat. Amateur radio and weather satellite tracker and passes predictor for Android.
|
~ Look4Sat. Amateur radio and weather satellite tracker and passes predictor for Android.
|
||||||
~ Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
|
~ Copyright (C) 2019, 2020 Arty Bishop (bishop.arty@gmail.com)
|
||||||
~
|
~
|
||||||
@@ -65,4 +64,10 @@
|
|||||||
android:label="@string/menu_about"
|
android:label="@string/menu_about"
|
||||||
tools:layout="@layout/fragment_about" />
|
tools:layout="@layout/fragment_about" />
|
||||||
|
|
||||||
|
<fragment
|
||||||
|
android:id="@+id/nav_map_osm"
|
||||||
|
android:name="com.rtbishop.look4sat.ui.fragments.MapOsmFragment"
|
||||||
|
android:label="@string/placeholder"
|
||||||
|
tools:layout="@layout/fragment_map_osm" />
|
||||||
|
|
||||||
</navigation>
|
</navigation>
|
||||||
Reference in new issue
Block a user