Compare commits
10 Commits
master
...
licard-dev
| Author | SHA1 | Date |
|---|---|---|
|
|
c66c1a8caf | |
|
|
a7dd994631 | |
|
|
6eeb9c8b99 | |
|
|
6f74a503c4 | |
|
|
d154ee1988 | |
|
|
06e63202c8 | |
|
|
f692c07d71 | |
|
|
2c264ecd66 | |
|
|
77331dd2a2 | |
|
|
c73a8c8e8e |
|
|
@ -1,10 +1,10 @@
|
|||
apply plugin: 'kotlin-android'
|
||||
|
||||
rootProject.ext {
|
||||
compileSdk = 29
|
||||
compileSdk = 31
|
||||
|
||||
minSdk = 21
|
||||
targetSdk = 29
|
||||
targetSdk = 31
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ plugins {
|
|||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion(29)
|
||||
compileSdkVersion(31)
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion(21)
|
||||
targetSdkVersion(29)
|
||||
targetSdkVersion(31)
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ abstract class AbstractMapManager<TMapView : View, TMap : Any, TLocation : Any>(
|
|||
this.mapListener = mapListener
|
||||
}
|
||||
|
||||
open fun onCreate(savedInstanceState: Bundle) = Unit
|
||||
open fun onCreate(savedInstanceState: Bundle?) = Unit
|
||||
|
||||
open fun onDestroy() = Unit
|
||||
|
||||
|
|
@ -67,6 +67,8 @@ abstract class AbstractMapManager<TMapView : View, TMap : Any, TLocation : Any>(
|
|||
this.mapListener?.onMapInitialized(map)
|
||||
}
|
||||
|
||||
fun isMapInitialized(): Boolean = this::map.isInitialized
|
||||
|
||||
interface AbstractMapListener<TMapView, TMap, TLocation> {
|
||||
|
||||
fun onMapInitialized(map: TMap)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ allprojects {
|
|||
google()
|
||||
jcenter()
|
||||
maven {
|
||||
url "https://dl.bintray.com/touchin/touchin-tools"
|
||||
url "https://maven.dev.touchin.ru"
|
||||
metadataSources {
|
||||
artifact()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.google.android.gms.maps.MapView
|
|||
import com.google.android.gms.maps.model.CameraPosition
|
||||
import com.google.android.gms.maps.model.LatLng
|
||||
import com.google.android.gms.maps.model.LatLngBounds
|
||||
import com.google.android.gms.maps.model.VisibleRegion
|
||||
import ru.touchin.basemap.AbstractMapManager
|
||||
|
||||
@Suppress("detekt.TooManyFunctions")
|
||||
|
|
@ -29,7 +30,7 @@ class GoogleMapManager(mapView: MapView) : AbstractMapManager<MapView, GoogleMap
|
|||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle) {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
mapView.onCreate(savedInstanceState)
|
||||
}
|
||||
|
|
@ -77,10 +78,16 @@ class GoogleMapManager(mapView: MapView) : AbstractMapManager<MapView, GoogleMap
|
|||
|
||||
override fun getCameraTilt(): Float = map.cameraPosition.tilt
|
||||
|
||||
fun getVisibleRegion(): VisibleRegion = map.projection.visibleRegion
|
||||
|
||||
override fun moveCamera(target: LatLng, zoom: Float, azimuth: Float, tilt: Float) {
|
||||
map.moveCamera(CameraUpdateFactory.newCameraPosition(buildCameraPosition(target, zoom, azimuth, tilt)))
|
||||
}
|
||||
|
||||
fun moveCamera(target: LatLng, userRegionZoom: Float) {
|
||||
map.animateCamera(CameraUpdateFactory.newLatLngZoom(target, userRegionZoom))
|
||||
}
|
||||
|
||||
override fun smoothMoveCamera(target: LatLng, zoom: Float, azimuth: Float, tilt: Float) {
|
||||
map.animateCamera(CameraUpdateFactory.newCameraPosition(buildCameraPosition(target, zoom, azimuth, tilt)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ open class DefaultActivityLifecycleCallbacks : Application.ActivityLifecycleCall
|
|||
|
||||
override fun onActivityDestroyed(activity: Activity) = Unit
|
||||
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle?) = Unit
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) = Unit
|
||||
|
||||
override fun onActivityStopped(activity: Activity) = Unit
|
||||
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ dependencies {
|
|||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib"
|
||||
|
||||
implementation "com.yandex.android:mapkit"
|
||||
implementation "com.yandex.android:maps.mobile"
|
||||
|
||||
constraints {
|
||||
implementation("com.yandex.android:mapkit") {
|
||||
implementation("com.yandex.android:maps.mobile") {
|
||||
version {
|
||||
require '3.4.0'
|
||||
require '4.3.2-lite'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,18 +10,20 @@ import com.yandex.mapkit.geometry.Point
|
|||
import com.yandex.mapkit.layers.ObjectEvent
|
||||
import com.yandex.mapkit.map.CameraListener
|
||||
import com.yandex.mapkit.map.CameraPosition
|
||||
import com.yandex.mapkit.map.CameraUpdateSource
|
||||
import com.yandex.mapkit.map.CameraUpdateReason
|
||||
import com.yandex.mapkit.map.InputListener
|
||||
import com.yandex.mapkit.map.Map
|
||||
import com.yandex.mapkit.map.MapLoadStatistics
|
||||
import com.yandex.mapkit.map.MapLoadedListener
|
||||
import com.yandex.mapkit.map.MapObjectCollection
|
||||
import com.yandex.mapkit.map.VisibleRegion
|
||||
import com.yandex.mapkit.mapview.MapView
|
||||
import com.yandex.mapkit.user_location.UserLocationObjectListener
|
||||
import com.yandex.mapkit.user_location.UserLocationView
|
||||
import com.yandex.runtime.image.ImageProvider
|
||||
import ru.touchin.basemap.AbstractMapManager
|
||||
|
||||
@Suppress("detekt.TooManyFunctions")
|
||||
@Suppress("detekt.TooManyFunctions", "detekt.UnusedPrivateMember")
|
||||
class YandexMapManager(
|
||||
mapView: MapView,
|
||||
private val isDebug: Boolean = false
|
||||
|
|
@ -57,7 +59,6 @@ class YandexMapManager(
|
|||
|
||||
override fun initMap(map: Map) {
|
||||
super.initMap(map)
|
||||
map.isDebugInfoEnabled = isDebug
|
||||
map.setMapLoadedListener(this)
|
||||
map.addCameraListener(this)
|
||||
map.addInputListener(this)
|
||||
|
|
@ -79,7 +80,7 @@ class YandexMapManager(
|
|||
mapListener?.onMapLoaded()
|
||||
}
|
||||
|
||||
override fun onCameraPositionChanged(map: Map, cameraPosition: CameraPosition, cameraUpdateSource: CameraUpdateSource, finished: Boolean) {
|
||||
override fun onCameraPositionChanged(map: Map, cameraPosition: CameraPosition, cameraUpdateSource: CameraUpdateReason, finished: Boolean) {
|
||||
mapListener?.onCameraMoved(finished)
|
||||
}
|
||||
|
||||
|
|
@ -91,6 +92,8 @@ class YandexMapManager(
|
|||
mapListener?.onMapTap(point)
|
||||
}
|
||||
|
||||
fun getCameraPosition(): CameraPosition = map.cameraPosition
|
||||
|
||||
override fun getCameraTarget(): Point = map.cameraPosition.target
|
||||
|
||||
override fun getCameraZoom(): Float = map.cameraPosition.zoom
|
||||
|
|
@ -99,6 +102,10 @@ class YandexMapManager(
|
|||
|
||||
override fun getCameraTilt(): Float = map.cameraPosition.tilt
|
||||
|
||||
fun moveCamera(target: CameraPosition) {
|
||||
map.move(target)
|
||||
}
|
||||
|
||||
override fun moveCamera(target: Point, zoom: Float, azimuth: Float, tilt: Float) {
|
||||
map.move(CameraPosition(target, zoom, azimuth, tilt), Animation(Animation.Type.LINEAR, CAMERA_ANIMATION_DURATION), null)
|
||||
}
|
||||
|
|
@ -152,9 +159,9 @@ class YandexMapManager(
|
|||
userLocationAccuracyCirceColor = accuracyCircleColor
|
||||
}
|
||||
|
||||
fun getVisibleRegion() = map.visibleRegion
|
||||
fun getVisibleRegion(): VisibleRegion = map.visibleRegion
|
||||
|
||||
fun getMapObjects() = map.mapObjects
|
||||
fun getMapObjects(): MapObjectCollection = map.mapObjects
|
||||
|
||||
interface MapListener : AbstractMapListener<MapView, Map, Point>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue