Skip to content

Keep an unset camera property from the current camera, and honour an explicit 0 - #7

Merged
wf9a5m75 merged 1 commit into
developfrom
fix/camera-unset-inherits
Oct 24, 2026
Merged

wf9a5m75 merged 1 commit into
developfrom
fix/camera-unset-inherits

Conversation

@wf9a5m75

@wf9a5m75 wf9a5m75 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

概要

MapViewState.moveCameraTo(cameraPosition) で、カメラの zoom / bearing / tilt が未指定なら現在のカメラの値を引き継ぎ、明示的に 0 を指定したらそのまま 0 を使うようにしました。

#4 では、zoom 0(世界全体)に移動できない問題を直すため、「すべて 0 なら未指定とみなす」判定を消しました。その結果、今度は createMapCameraPosition({ position }) で位置だけ渡しても zoom / bearing / tilt が 0 にリセットされるようになっていました。zoom のデフォルトは 0 なので、値を見ただけでは未指定と明示的な 0 を区別できません。

変更内容

  • createMapCameraPosition は、zoom / bearing / tilt が渡されたかどうか(null / undefined なら未指定)を記録します。MapCameraPosition に isZoomSpecified / isBearingSpecified / isTiltSpecified を追加しました。
    • プロパティの型は number のままで、未指定なら 0 と読めます。値を読むだけのプロバイダー側は変更不要です。
  • resolvedOnto(current) を追加しました。未指定のプロパティだけを、current の値で埋めます。プロパティごとに個別に判定します。
  • copy() と MapCameraPosition.from() は、未指定だったプロパティを未指定のまま保ちます。
  • MapViewState.moveCameraTo は resolvedOnto(this._cameraPosition) を通してからコントローラーに渡します。
  • paddings はどのドライバーもまだ対応していないので、今回は対象外です。
  • api/js-sdk-core.api.d.ts を更新しました(MapCameraPosition の部分だけです)。

ios-sdk-core(MapConductor/ios-sdk-core#17)と android-sdk-core(MapConductor/android-sdk-core#14)にも同じ変更を入れています。

テスト

test/CameraPositionResolve.test.mjs を追加しました(位置だけ渡す・明示的な 0・プロパティごとの引き継ぎ・copy() / from()・MapViewState 経由)。npm test は 49 件すべて通ります。

…explicit 0

#4 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
createMapCameraPosition({ 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 MapViewState.moveCameraTo fills only the unset ones
from the current camera via resolvedOnto(). Each property is resolved on its
own, and an explicit 0 is used as given.

The properties stay numbers and read 0 when unset, so the providers, which only
read them, are unchanged. copy() and MapCameraPosition.from() keep an unset
property unset. Same change as ios-sdk-core and android-sdk-core.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant