androidMain.tech.skot.libraries.map.SKMapViewProxy.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of viewlegacy Show documentation
Show all versions of viewlegacy Show documentation
viewlegacy module for SK-Map skot library
The newest version!
package tech.skot.libraries.map
import androidx.fragment.app.Fragment
import com.google.android.gms.maps.MapView
import tech.skot.core.components.SKActivity
import tech.skot.core.components.SKComponentViewProxy
import tech.skot.view.live.MutableSKLiveData
import tech.skot.view.live.SKMessage
class SKMapViewProxy(
mapInteractionSettingsInitial: SKMapVC.MapInteractionSettings,
markersInitial: List,
linesInitial: List,
polygonsInitial: List,
selectedMarkerInitial: SKMapVC.Marker?,
selectMarkerOnClickInitial: Boolean,
unselectMarkerOnMapClickInitial: Boolean,
onMarkerClickInitial: Function1?,
onMarkerSelectedInitial: Function1?,
onMapClickedInitial: Function1?,
onMapLongClickedInitial: Function1?,
onMapBoundsChangeInitial: Function1?,
showLogInitial: Boolean,
mapTypeInitial : MapType
) : SKComponentViewProxy(), InternalSKMapVC {
private val mapInteractionSettingsLD: MutableSKLiveData =
MutableSKLiveData(mapInteractionSettingsInitial)
override var mapInteractionSettings: SKMapVC.MapInteractionSettings by mapInteractionSettingsLD
private val markersLD: MutableSKLiveData> =
MutableSKLiveData(markersInitial)
override var markers: List by markersLD
private val linesLD: MutableSKLiveData> = MutableSKLiveData(linesInitial)
override var polylines: List by linesLD
private val polygonsLD: MutableSKLiveData> = MutableSKLiveData(polygonsInitial)
override var polygons: List by polygonsLD
private val onMapClickedLD: MutableSKLiveData?> =
MutableSKLiveData(onMapClickedInitial)
override var onMapClicked: Function1? by onMapClickedLD
private val onMapLongClickedLD: MutableSKLiveData?> =
MutableSKLiveData(onMapLongClickedInitial)
override var onMapLongClicked: Function1? by onMapLongClickedLD
private val onMarkerClickLD: MutableSKLiveData?> =
MutableSKLiveData(onMarkerClickInitial)
override var onMarkerClicked: Function1? by onMarkerClickLD
private val onMapBoundsChangeLD: MutableSKLiveData?> =
MutableSKLiveData(onMapBoundsChangeInitial)
override var onMapBoundsChange: Function1? by onMapBoundsChangeLD
private val selectMarkerOnClickLD: MutableSKLiveData =
MutableSKLiveData(selectMarkerOnClickInitial)
override var selectMarkerOnClick: Boolean by selectMarkerOnClickLD
private val showLogLD: MutableSKLiveData =
MutableSKLiveData(showLogInitial)
override var showLog: Boolean by showLogLD
private val mapTypeLD: MutableSKLiveData =
MutableSKLiveData(mapTypeInitial)
override var mapType: MapType by mapTypeLD
private val unselectMarkerOnMapClickLD: MutableSKLiveData =
MutableSKLiveData(unselectMarkerOnMapClickInitial)
override var unselectMarkerOnMapClick: Boolean by unselectMarkerOnMapClickLD
private val onMarkerSelectedLD: MutableSKLiveData?> =
MutableSKLiveData(onMarkerSelectedInitial)
override var onMarkerSelected: Function1? by onMarkerSelectedLD
private val selectedMarkerLD: MutableSKLiveData =
MutableSKLiveData(selectedMarkerInitial)
override var selectedMarker: SKMapVC.Marker? by selectedMarkerLD
private val setCameraPositionMessage: SKMessage = SKMessage()
private val setCenterOnPositionsMessage: SKMessage = SKMessage()
private val setCameraZoomMessage: SKMessage = SKMessage()
private val showMyLocationButtonMessage: SKMessage = SKMessage()
private val showMyLocationMessage: SKMessage = SKMessage()
private val getMapBoundsMessage: SKMessage = SKMessage()
private val getCurrentLocationMessage: SKMessage = SKMessage()
override fun showMyLocationButton(
show: Boolean,
onPermissionError: (() -> Unit)?
) {
showMyLocationButtonMessage.post(
ShowMyLocationButtonData(
show,
onPermissionError
)
)
}
override fun showMyLocation(
show: Boolean,
onPermissionError: (() -> Unit)?
) {
showMyLocationMessage.post(
ShowMyLocationData(
show,
onPermissionError
)
)
}
override fun getMapBounds(onResult: (SKMapVC.LatLngBounds) -> Unit) {
getMapBoundsMessage.post(GetMapBoundsData(onResult))
}
override fun getCurrentLocation(onResult: (LatLng) -> Unit) {
getCurrentLocationMessage.post(GetCurrentLocationData(onResult))
}
override fun setCameraPosition(
position: LatLng,
zoomLevel: Float,
animate: Boolean
) {
setCameraPositionMessage.post(SetCameraPositionData(position, zoomLevel, animate))
}
override fun centerOnPositions(positions: List) {
setCenterOnPositionsMessage.post(CenterOnPositionsData(positions))
}
override fun setCameraZoom(zoomLevel: Float, animate: Boolean) {
setCameraZoomMessage.post(SetCameraZoomData(zoomLevel, animate))
}
override fun saveState() {
}
override fun bindTo(
activity: SKActivity,
fragment: Fragment?,
binding: MapView
): SKMapView = SKMapView(this, activity, fragment, binding).apply {
markersLD.observe {
onMarkers(it)
}
linesLD.observe {
onLines(it)
}
polygonsLD.observe {
onPolygons(it)
}
mapInteractionSettingsLD.observe {
onMapInteractionSettings(it)
}
onMarkerClickLD.observe {
onOnMarkerClick(it)
}
selectMarkerOnClickLD.observe {
}
selectedMarkerLD.observe {
onSelectedMarker(it)
}
unselectMarkerOnMapClickLD.observe {
}
onMapClickedLD.observe {
onOnMapClicked(it)
}
onMapLongClickedLD.observe {
onOnMapLongClicked(it)
}
setCameraPositionMessage.observe {
setCameraPosition(it.position, it.zoomLevel, it.animate)
}
setCenterOnPositionsMessage.observe {
centerOnPositions(it.positions)
}
setCameraZoomMessage.observe {
setCameraZoom(it.zoomLevel, it.animate)
}
showMyLocationButtonMessage.observe {
showMyLocationButton(it.show, it.onPermissionError)
}
showMyLocationMessage.observe {
showMyLocation(it.show, it.onPermissionError)
}
getMapBoundsMessage.observe {
getMapBounds(it.onResult)
}
getCurrentLocationMessage.observe {
getCurrentLocation(it.onResult)
}
onMapBoundsChangeLD.observe {
onOnMapBoundsChange(it)
}
showLogLD.observe {
onShowLog(it)
}
mapTypeLD.observe {
onMapType(it)
}
}
data class SetCameraPositionData(
val position: LatLng,
val zoomLevel: Float,
val animate: Boolean
)
data class SetCameraZoomData(
val zoomLevel: Float,
val animate: Boolean
)
data class ShowMyLocationButtonData(
val show: Boolean,
val onPermissionError: (() -> Unit)?
)
data class ShowMyLocationData(
val show: Boolean,
val onPermissionError: (() -> Unit)?
)
data class CenterOnPositionsData(val positions: List)
data class GetMapBoundsData(
val onResult: (SKMapVC.LatLngBounds) -> Unit
)
data class GetCurrentLocationData(
val onResult: (LatLng) -> Unit
)
}
interface SKMapRAI {
fun onMarkers(markers: List)
fun onLines(polylines: List)
fun onPolygons(polygons: List)
fun onSelectedMarker(selectedMarker: SKMapVC.Marker?)
fun setCameraPosition(
position: LatLng,
zoomLevel: Float,
animate: Boolean
)
fun centerOnPositions(positions: List)
fun setCameraZoom(zoomLevel: Float, animate: Boolean)
fun showMyLocationButton(
show: Boolean,
onPermissionError: (() -> Unit)?
)
fun showMyLocation(
show: Boolean,
onPermissionError: (() -> Unit)?
)
fun getMapBounds(
onResult: (SKMapVC.LatLngBounds) -> Unit
)
fun onOnMapBoundsChange(
onMapBoundsChange: ((SKMapVC.LatLngBounds) -> Unit)?
)
fun onOnMapClicked(
onMapClicked: ((LatLng) -> Unit)?
)
fun onOnMapLongClicked(
onMapLongClicked: ((LatLng) -> Unit)?
)
fun onOnMarkerClick(
onMarkerClick: ((SKMapVC.Marker) -> Unit)?
)
fun onMapInteractionSettings(mapInteractionSettings: SKMapVC.MapInteractionSettings)
fun onShowLog(show: Boolean)
fun onMapType(mapType : MapType)
fun getCurrentLocation(onResult: (LatLng) -> Unit)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy