Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import com.mapconductor.core.calculateZIndex
import com.mapconductor.core.circle.AbstractCircleOverlayRenderer
import com.mapconductor.core.circle.CircleEntityInterface
import com.mapconductor.core.circle.CircleState
import com.mapconductor.core.controller.OverlayKind
import com.mapconductor.core.controller.OverlayStacking
import com.mapconductor.core.features.GeoPoint
import com.mapconductor.core.geometry.circleToRing
import com.mapconductor.core.geometry.closeRing
Expand Down Expand Up @@ -37,7 +39,7 @@ class GoogleMapCircleOverlayRenderer(
.fillColor(state.fillColor.toArgb())
.clickable(false)
.geodesic(state.geodesic)
.zIndex((state.zIndex ?: calculateZIndex(state.center)).toFloat())
.zIndex(OverlayStacking.flatZIndex(OverlayKind.Circle, state.zIndex ?: calculateZIndex(state.center)))
holder.map.addPolygon(options).also {
it.tag = state.id
}
Expand Down Expand Up @@ -82,7 +84,11 @@ class GoogleMapCircleOverlayRenderer(
circle.fillColor = current.state.fillColor.toArgb()
}
if (finger.zIndex != prevFinger.zIndex) {
circle.zIndex = (current.state.zIndex ?: calculateZIndex(current.state.center)).toFloat()
circle.zIndex =
OverlayStacking.flatZIndex(
OverlayKind.Circle,
current.state.zIndex ?: calculateZIndex(current.state.center),
)
}
circle
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.mapconductor.googlemaps.groundimage
import androidx.core.graphics.drawable.toBitmap
import com.google.android.gms.maps.model.BitmapDescriptorFactory
import com.google.android.gms.maps.model.GroundOverlayOptions
import com.mapconductor.core.controller.OverlayKind
import com.mapconductor.core.controller.OverlayStacking
import com.mapconductor.core.groundimage.AbstractGroundImageOverlayRenderer
import com.mapconductor.core.groundimage.GroundImageEntityInterface
import com.mapconductor.core.groundimage.GroundImageState
Expand All @@ -28,6 +30,8 @@ class GoogleMapGroundImageOverlayRenderer(
.image(image)
.positionFromBounds(bounds)
.transparency(1.0f - opacity)
// GroundImage の帯(タイルの上、ポリゴンの下)。Google は種類をまたいで zIndex で重ねる。
.zIndex(OverlayStacking.flatZIndex(OverlayKind.GroundImage, 0))
holder.map.addGroundOverlay(options)?.also {
it.tag = state.id
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import androidx.compose.ui.graphics.toArgb
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.PolygonOptions
import com.mapconductor.core.ResourceProvider
import com.mapconductor.core.controller.OverlayKind
import com.mapconductor.core.controller.OverlayStacking
import com.mapconductor.core.features.GeoPoint
import com.mapconductor.core.features.GeoPointInterface
import com.mapconductor.core.geometry.densifyPolygonRing
Expand Down Expand Up @@ -91,7 +93,7 @@ internal class GoogleMapPolygonOverlayRenderer(
.strokeColor(resolved.strokeColor.toArgb())
.strokeWidth(ResourceProvider.dpToPx(resolved.strokeWidth).toFloat())
.fillColor(resolved.fillColor.toArgb())
.zIndex(resolved.zIndex.toFloat())
.zIndex(OverlayStacking.flatZIndex(OverlayKind.Polygon, resolved.zIndex))
.clickable(false)
holder.map.addPolygon(options).also {
it.tag = state.id
Expand Down Expand Up @@ -126,7 +128,7 @@ internal class GoogleMapPolygonOverlayRenderer(
polygon.fillColor = current.state.fillColor.toArgb()
}
if (finger.zIndex != prevFinger.zIndex) {
polygon.zIndex = current.state.zIndex.toFloat()
polygon.zIndex = OverlayStacking.flatZIndex(OverlayKind.Polygon, current.state.zIndex)
}
polygon
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.Polyline
import com.google.android.gms.maps.model.PolylineOptions
import com.mapconductor.core.ResourceProvider
import com.mapconductor.core.controller.OverlayKind
import com.mapconductor.core.controller.OverlayStacking
import com.mapconductor.core.features.GeoPoint
import com.mapconductor.core.features.GeoPointInterface
import com.mapconductor.core.polyline.AbstractPolylineOverlayRenderer
Expand Down Expand Up @@ -57,7 +59,7 @@ class GoogleMapPolylineOverlayRenderer(
.color(state.strokeColor.toArgb())
.width(ResourceProvider.dpToPx(state.strokeWidth).toFloat())
.geodesic(state.geodesic)
.zIndex(state.zIndex.toFloat())
.zIndex(OverlayStacking.flatZIndex(OverlayKind.Polyline, state.zIndex))
.clickable(false)

holder.map.addPolyline(options).also {
Expand Down Expand Up @@ -95,7 +97,7 @@ class GoogleMapPolylineOverlayRenderer(
}

if (finger.zIndex != prevFinger.zIndex) {
polyline.zIndex = current.state.zIndex.toFloat()
polyline.zIndex = OverlayStacking.flatZIndex(OverlayKind.Polyline, current.state.zIndex)
}

polyline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import com.google.android.gms.maps.model.TileOverlay
import com.google.android.gms.maps.model.TileOverlayOptions
import com.google.android.gms.maps.model.TileProvider
import com.google.android.gms.maps.model.TileProvider.NO_TILE
import com.mapconductor.core.controller.OverlayKind
import com.mapconductor.core.controller.OverlayStacking
import com.mapconductor.core.raster.RasterLayerEntityInterface
import com.mapconductor.core.raster.RasterLayerOverlayRendererInterface
import com.mapconductor.core.raster.RasterLayerSource
Expand Down Expand Up @@ -92,12 +94,14 @@ class GoogleMapRasterLayerOverlayRenderer(

private fun isMarkerTileRaster(state: RasterLayerState): Boolean = state.id.startsWith(MARKER_TILE_RASTER_ID_PREFIX)

// Google は TileOverlay・GroundOverlay・Polygon・Circle・Polyline を 1 本の zIndex で重ねる
// (Marker は常にその上)。帯の順(OverlayStacking)に沿って値を割り当てる。
private fun resolveOverlayZIndex(state: RasterLayerState): Float =
if (isMarkerTileRaster(state)) {
// Backward-compatible behavior: marker tiles stay above most overlays.
999f
// マーカーのタイルはマーカーの帯(ポリラインより上)。
OverlayStacking.flatZIndex(OverlayKind.Marker, Int.MIN_VALUE)
} else {
state.zIndex.toFloat()
OverlayStacking.flatZIndex(OverlayKind.RasterLayer, state.zIndex)
}

override suspend fun onAdd(data: List<RasterLayerOverlayRendererInterface.AddParamsInterface>): List<TileOverlay?> =
Expand Down
Loading