Repository navigation
Keep an unset camera property from the current camera, and honour an explicit 0 - #17
Merged
Merged
Conversation
…explicit 0 #11 dropped the all-zero test because it took zoom 0 (the whole world) for "not given". Removing it fixed that and lost the other half: a camera built as MapCameraPosition(position:) reset zoom, bearing and tilt to 0 instead of leaving them where they were. The two cannot be told apart from the value, because zoom defaults to 0. So the camera now records which of zoom / bearing / tilt the caller gave (isZoomSpecified, ...), and moveCameraTo(cameraPosition:) fills only the unset ones from the current camera via resolved(onto:). Each property is resolved on its own, and an explicit 0 is used as given. The properties stay Double and read 0 when unset, so the providers, which only read them, are unchanged. copy() keeps an unset property unset.
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.
概要
moveCameraTo(cameraPosition:)で、カメラの zoom / bearing / tilt が未指定なら現在のカメラの値を引き継ぎ、明示的に 0 を指定したらそのまま 0 を使うようにしました。#11 では、zoom 0(世界全体)に移動できない問題を直すため、「すべて 0 なら未指定とみなす」判定を消しました。その結果、今度は
MapCameraPosition(position:)で位置だけ渡しても zoom / bearing / tilt が 0 にリセットされるようになっていました。zoom のデフォルトは 0 なので、値を見ただけでは未指定と明示的な 0 を区別できません。変更内容
MapCameraPosition.initのzoom/bearing/tiltをDouble? = nilにしました。指定されたかどうかはisZoomSpecified/isBearingSpecified/isTiltSpecifiedで持ちます。Doubleのままで、未指定なら 0 と読めます。値を読むだけのプロバイダー側は変更不要です。MapCameraPosition(position: p, zoom: 12)のような既存の呼び出しは、そのままコンパイルできます。resolved(onto:)を追加しました。未指定のプロパティだけを、渡したカメラの値で埋めます。プロパティごとに個別に判定します。copy()は、未指定だったプロパティをコピー後も未指定のまま保ちます。MapViewState.moveCameraTo(cameraPosition:)はresolved(onto: storedCameraPosition)を通してからコントローラーに渡します。paddingsはどのドライバーもまだ対応していないので、今回は対象外です。MapCameraPositionの部分だけです)。android-sdk-core(MapConductor/android-sdk-core#14)と js-sdk-core(MapConductor/js-sdk-core#7)にも同じ変更を入れています。
テスト
CameraPositionResolveTestsを追加しました(位置だけ渡す・明示的な 0・プロパティごとの引き継ぎ・copy()・MapViewState経由)。コアのテストは 315 件すべて通ります(iPhone 17 Pro シミュレーター)。