Repository navigation
Conversation
Every provider is to stack overlays, bottom to top, as raster layers < ground images < polygons (and polygon tiles) < circles < polylines < markers (and marker tiles), whatever order they were added or re-sent in (after clearOverlays(), after a design change). zIndex orders within a band; equal keys keep the order they were passed in. Providers had drifted: GL providers appended each layer on top, so a circle re-sent after clearOverlays() covered the polyline; Google and HERE compared raw zIndex across kinds (all 0, so add order decided). OverlayStacking gives the providers one place to compute it: - insertionIndex(for:among:ceiling:) - where a layer goes among the existing ones (nil entries are basemap layers); ceiling keeps rasters under the basemap labels without dropping them below lower overlays. - band(ofStyleLayerId:) - the band of the style layer ids MapLibre, Mapbox, MapTiler and Mappls use (they share the prefixes). - rasterKey(stateId:zIndex:) - the band of a layer that rides the raster path: app rasters, marker tiles (marker-tile-...), and PolygonTiler's mc-polygon-tiles (polygon band) once feat/polygon-tiling lands. - globalZIndex(_:) - one Int32 for SDKs that compare a single number across kinds (Google zIndex, HERE drawOrder). Bands are 4096 apart, zIndex clamped to +-2047: with 1e8-wide bands Google drew a circle over a polyline on the device, as if the values were clamped. @_spi(MapConductorDriver): driver-only, not in the app-facing API (api-surface check unchanged). OverlayStackingTests checks all 720 add orders. Swapping in the old MapLibre insertion (raster below the labels, ground image below the first vector overlay, everything else on top) fails four of its tests.
This was referenced Nov 8, 2026
Open
Open
Open
Open
Open
Open
Open
This was referenced Nov 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
なぜ
利用者の決定で、すべてのプロバイダ・3 プラットフォームで、オーバーレイを下から次の順に重ねます。
追加した順・送り直した順(clearOverlays の後など)・デザイン変更の後に左右されません。帯の中は zIndex、同じ zIndex なら渡された順です。
プロバイダごとに重なり順がばらばらでした(TomTom のラスターがポリゴンを覆う、送り直した GroundImage がポリゴンより上に来る、GL 系でサークルがポリゴンの下になる、など)。
何を変えたか
OverlayBandとOverlayStackingを足しました(@_spi(MapConductorDriver)。アプリ向けの公開 API には出ません。api-surface は変化なし)。insertionIndex(for:among:ceiling:): 既存のレイヤーの中で差し込む位置(nil はベースマップのレイヤー)。ceiling は、ラスターを下のオーバーレイより下に落とさずにベースマップのラベルの下に保つためのもの。band(ofStyleLayerId:): MapLibre・Mapbox・MapTiler・Mappls が使うスタイルレイヤー id の帯(接頭辞が共通)。rasterKey(stateId:zIndex:): ラスターの経路に乗るレイヤーの帯(アプリのラスター、マーカータイル、feat/polygon-tiling が入ったときのポリゴンタイル)。globalZIndex(_:): 種類をまたいで 1 つの数で比べる SDK(Google の zIndex、HERE の drawOrder)向けの Int32。帯の間隔は 4096、zIndex は ±2047 に丸めます(1e8 幅では Google が実機でサークルをポリラインの上に描きました)。OverlayStackingTestsは 720 通りの追加順をすべて確かめます。前の MapLibre の差し込み方に戻すと 4 件落ちます。直す前と後(このプラットフォームのプロバイダ)
SDK の制約で守れないもの
地図のラベルとの関係(今のまま)
今のままにしています。GL 系(MapLibre・Mapbox・Mappls・MapTiler)はラスターをベースマップの最初のラベルの下、他のオーバーレイはラベルの上です(MapTiler のラスターは、前はすべての上でしたが、他の GL 系に合わせてラベルの下に移りました)。Google はラベルを常にオーバーレイの上に描きます(変更なし)。MapKit だけは変わります: 帯の順を守るために全部を同じレベルに置く必要があり、ラスターと GroundImage が .aboveLabels から .aboveRoads(ラベルの下)へ移りました。ポリゴン・サークル・ポリラインは前からラベルの下です。逆に全部を .aboveLabels にすると、ポリゴン類がラベルの上へ移ります。今回は前者で、利用者の判断で承認済みです。
検証
2026-11-08 に develop(fix/mapview-teardown、fix/geodesic-polygon-fill、fix/clear-followups、refactor/polygon-controller などのマージ後)の上に載せ直してから確かめています。
OverlayStackingTestsは 720 通りの追加順。前の MapLibre の差し込み方に戻すと 4 件落ちます)。api-surface は変化なし(@_spi)。fix/clear-strategy+ この PR 一式を合わせたアプリが実機向けにビルドでき、iPad 実機で MapLibre / MapKit を撮り直しました。普通に追加・逆の順・clearOverlays → 送り直し・デザイン変更 のどれでも、下から ラスター < GroundImage < ポリゴン < サークル < ポリライン < マーカー でした。確認できていないもの
rasterKey(stateId:)でポリゴンの帯に入る用意だけしてあり、実物では確かめていません。関連 PR(
fix/overlay-stacking-orderの一式)マージの順番:
fix/clear-strategyの一式(先に入れる想定。衝突はしないことをgit merge-treeで確認済み)fix/maptiler-overlay-restoreの上に載せています(同じ削除処理を両方が書き換えたため)。先に restore の PR(Remove style layers and sources by object so they can come back android-for-maptiler#17)を入れてください。