change logic of drawFeature to draw relative to offset
This commit is contained in:
parent
307e42eac2
commit
5e548fcc65
@ -6,6 +6,7 @@ import androidx.compose.material.Text
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Home
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.geometry.Size
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.window.Window
|
||||
@ -66,7 +67,7 @@ fun App() {
|
||||
custom(position = pointThree) {
|
||||
drawRect(
|
||||
color = Color.Red,
|
||||
topLeft = it,
|
||||
topLeft = Offset(-10f, -10f),
|
||||
size = Size(20f, 20f)
|
||||
)
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ fun FeatureBuilder.custom(
|
||||
position: Pair<Double, Double>,
|
||||
zoomRange: IntRange = defaultZoomRange,
|
||||
id: FeatureId? = null,
|
||||
drawFeature: DrawScope.(Offset) -> Unit,
|
||||
drawFeature: DrawScope.() -> Unit,
|
||||
) = addFeature(id, MapDrawFeature(position.toCoordinates(), zoomRange, drawFeature))
|
||||
|
||||
fun FeatureBuilder.line(
|
||||
|
@ -36,7 +36,7 @@ class MapFeatureSelector(val selector: (zoom: Int) -> MapFeature) : MapFeature(d
|
||||
class MapDrawFeature(
|
||||
val position: GeodeticMapCoordinates,
|
||||
zoomRange: IntRange = defaultZoomRange,
|
||||
val drawFeature: DrawScope.(Offset) -> Unit,
|
||||
val drawFeature: DrawScope.() -> Unit,
|
||||
) : MapFeature(zoomRange) {
|
||||
override fun getBoundingBox(zoom: Int): GmcBox {
|
||||
//TODO add box computation
|
||||
|
@ -239,7 +239,9 @@ actual fun MapView(
|
||||
}
|
||||
is MapDrawFeature -> {
|
||||
val offset = feature.position.toOffset()
|
||||
feature.drawFeature(this, offset)
|
||||
translate (offset.x, offset.y) {
|
||||
feature.drawFeature(this)
|
||||
}
|
||||
}
|
||||
is MapFeatureGroup -> {
|
||||
feature.children.values.forEach {
|
||||
|
Loading…
Reference in New Issue
Block a user