Make bearing a clockwise map rotation - #15
Open
wf9a5m75 wants to merge 1 commit into
Open
Conversation
bearing を「値を増やすと地図が時計回りに回る」向きに統一し、ネイティブ SDK との変換をコアの CameraBearing に集約する。
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.
なぜ
MapCameraPosition.bearingは 「値を増やすと地図が時計回り(右)に回る」 向きで定義する、というのが本来の設計。ところが実装は Google / MapLibre / Mapbox などネイティブ SDK の カメラの向き(heading) をそのまま渡していて、
値を増やすと地図が反時計回りに回っていた。両者は符号が反転している。
どう直したか
符号をプロバイダ各所に散らすと必ずどこかが漏れるので、変換はコアの
CameraBearing1 か所に集約した。画面投影と、各プロバイダの負 tilt エミュレーション(カメラの前進方向)も同じ変換を通している。
見た目
同じカメラ(エッフェル塔 / zoom 17 / tilt 0 / MapLibre)で bearing だけを変えたもの。
bearing 0 ではセーヌ川が左上(=北が上)。bearing 90 では地図が右へ 90 度回り、セーヌ川が右上に来る(=西が上)。
確認したこと
注意
破壊的変更。既存利用者の
bearingは逆を向く。visibleRegion/ 画面投影 /fitBounds/ 負 tilt がすべて bearing に依存しているため、一部だけ取り込むと「地図は回るがマーカーが逆」になる。関連 PR はまとめて取り込むこと。
作業中に判明した非対称(コードにコメントあり):
MapView.rotationは rotation 系(恒等)Viewpoint.rotationは heading 系(反転)map.rotationは rotation 系(恒等)MKMapCamera.headingは heading 系(反転)型定義やネイティブ版からの推測ではなく、実機 / 実ブラウザで測って決めた。