diff options
author | Iván Ávalos <avalos@disroot.org> | 2021-12-16 04:13:39 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2021-12-16 04:13:39 -0600 |
commit | cb56870d28a845b9e86c2c1bef1b890ee47a5184 (patch) | |
tree | 59d9ffdc024289d3f4177b7db99d03696bc8519f | |
parent | 9da618124f61c2d66daa877f47bee1beaab9bde5 (diff) | |
parent | 53960eef74a6b4cf187f380bc462b16e29e26592 (diff) | |
download | etbsa-trackermap-mobile-cb56870d28a845b9e86c2c1bef1b890ee47a5184.tar.gz etbsa-trackermap-mobile-cb56870d28a845b9e86c2c1bef1b890ee47a5184.tar.bz2 etbsa-trackermap-mobile-cb56870d28a845b9e86c2c1bef1b890ee47a5184.zip |
Merge branch 'maply_test'
-rw-r--r-- | androidApp/build.gradle.kts | 2 | ||||
-rw-r--r-- | androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt | 56 | ||||
-rw-r--r-- | androidApp/src/main/res/drawable/map_default.png | bin | 0 -> 819 bytes |
3 files changed, 53 insertions, 5 deletions
diff --git a/androidApp/build.gradle.kts b/androidApp/build.gradle.kts index 3532986..0e25404 100644 --- a/androidApp/build.gradle.kts +++ b/androidApp/build.gradle.kts @@ -28,7 +28,7 @@ dependencies { implementation("com.google.android.material:material:1.4.0") implementation("androidx.appcompat:appcompat:1.4.0") implementation("androidx.constraintlayout:constraintlayout:2.1.2") - implementation("com.squareup.okhttp3:okhttp:3.14.2") + implementation("com.squareup.okhttp3:okhttp:4.9.1") implementation("com.github.Zhuinden:live-event:1.2.0") implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0") implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:2.4.0") diff --git a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt index 2ffaa2c..125d525 100644 --- a/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt +++ b/androidApp/src/main/java/mx/trackermap/TrackerMap/android/map/MapFragment.kt @@ -1,29 +1,77 @@ package mx.trackermap.TrackerMap.android.map +import android.graphics.BitmapFactory import android.os.Bundle import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.fragment.app.Fragment +import com.mousebird.maply.* import kotlinx.coroutines.DelicateCoroutinesApi +import mx.trackermap.TrackerMap.android.R import mx.trackermap.TrackerMap.android.databinding.MapFragmentBinding import mx.trackermap.TrackerMap.android.units.UnitsViewModel import org.koin.androidx.viewmodel.ext.android.viewModel +import java.io.File -class MapFragment: Fragment() { +@DelicateCoroutinesApi +class MapFragment: GlobeMapFragment() { private var _binding: MapFragmentBinding? = null private val binding get() = _binding!! private val unitsViewModel: UnitsViewModel by viewModel() + override fun chooseDisplayType(): MapDisplayType { + return MapDisplayType.Map + } + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { - _binding = MapFragmentBinding.inflate(inflater, container, false) - return binding.root + super.onCreateView(inflater, container, savedInstanceState) + return baseControl.contentView!! + } + + override fun controlHasStarted() { + val cacheDirName = "stamen_watercolor6" + val cacheDir = File(activity!!.cacheDir, cacheDirName) + cacheDir.mkdir() + + val tileInfo = RemoteTileInfoNew("https://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}&s=Ga", 0, 21) + tileInfo.cacheDir = cacheDir + + val params = SamplingParams() + params.coordSystem = SphericalMercatorCoordSystem() + params.coverPoles = true + params.edgeMatching = true + params.minZoom = tileInfo.minZoom + params.maxZoom = tileInfo.maxZoom + params.singleLevel = true + + val loader = QuadImageLoader(params, tileInfo, baseControl) + loader.setImageFormat(RenderController.ImageFormat.MaplyImageUShort565) + + val latitude = 23.191 * Math.PI / 180 + val longitude = -100.36 * Math.PI / 180 + val zoom = 0.4 + mapControl.animatePositionGeo(longitude, latitude, zoom, 1.0) + + insertMarkers() + } + + private fun insertMarkers() { + val markerInfo = MarkerInfo() + val icon = BitmapFactory.decodeResource(activity!!.resources, R.drawable.map_default) + val markerSize = Point2d(80.0, 80.0) + + val moscow = ScreenMarker() + moscow.loc = Point2d.FromDegrees(37.616667, 55.75) + moscow.image = icon + moscow.size = markerSize + + mapControl.addScreenMarker(moscow, markerInfo, ThreadMode.ThreadAny) } override fun onDestroyView() { diff --git a/androidApp/src/main/res/drawable/map_default.png b/androidApp/src/main/res/drawable/map_default.png Binary files differnew file mode 100644 index 0000000..e7d1f72 --- /dev/null +++ b/androidApp/src/main/res/drawable/map_default.png |