Skip to content

feat: マップ手動操作時の自動追従を無効化し「現在地に戻る」ボタンを追加#10

Merged
TinyKitten merged 1 commit intomainfrom
claude/add-location-button-map-JG0Mo
Jan 30, 2026
Merged

feat: マップ手動操作時の自動追従を無効化し「現在地に戻る」ボタンを追加#10
TinyKitten merged 1 commit intomainfrom
claude/add-location-button-map-JG0Mo

Conversation

@TinyKitten
Copy link
Copy Markdown
Member

@TinyKitten TinyKitten commented Jan 30, 2026

ユーザーが地図をパン操作した際に位置更新による自動カメラ移動を
停止し、右下に「現在地に戻る」ボタンを表示するようにした。

https://claude.ai/code/session_014Dfww6cbtt9ZEBh2Ea2REQ

Summary by CodeRabbit

  • 新機能
    • マップ追従機能を追加:移動軌跡に自動フィット
    • ユーザーがマップをドラッグすると追従が解除
    • 「現在地に戻る」ボタンで追従を再開し、マップが現在地に自動フィット

✏️ Tip: You can customize this high-level summary in your review settings.

ユーザーが地図をパン操作した際に位置更新による自動カメラ移動を
停止し、右下に「現在地に戻る」ボタンを表示するようにした。

https://claude.ai/code/session_014Dfww6cbtt9ZEBh2Ea2REQ
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

app/(tabs)/map.tsx に follow-and-return マップ機能を追加。ユーザーがマップをパンしたときに自動フィットを無効化し、現在地へのリターン操作で再度有効化するロジックを実装。現在地に戻るボタン UI を追加し、マップコンテナの構造と関連イベントハンドラーを更新。

Changes

Cohort / File(s) Summary
Follow-and-Return Map Behavior
app/(tabs)/map.tsx
isFollowing 状態を追加してマップの自動フィット動作を制御。ユーザーがマップをドラッグしたときに following を無効化し、リターンボタンで現在地へのフォーカスと再度の follow 有効化を実装。マップコンテナのラップと onPanDrag イベントハンドラーの追加により、パンニング検出を実装。現在地に戻るボタン UI と対応するスタイルを追加。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • マップ画面実装 #2: 同じ MapScreen 実装に基づき、follow/return 状態、パンハンドリング、および現在地へのリターン UI・カメラロジックを追加する主要 PR。

Poem

🐰 地図が追う、ウサギの歩み
パンしたら離れ、戻ったら寄り添う
指一つで世界が踊る
現在地ボタン、小さき優しさ
フォローの絆、再び結ぶ 🗺️✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed タイトルはプルリクエストの主要な変更内容を正確に反映しており、マップの手動操作時の自動追従無効化と「現在地に戻る」ボタン追加という2つの主要な機能追加を簡潔に説明しています。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/add-location-button-map-JG0Mo

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@app/`(tabs)/map.tsx:
- Around line 77-88: The effect currently calls mapRef.current.fitToCoordinates
with allCoords (from getAllCoordinates) which makes "return to current location"
feel inconsistent when trajectories are long; change the useEffect (and the
handleReturnToCurrentLocation function) to compute and pass only the latest
coordinate (e.g., take the last item from getAllCoordinates(trajectories) or
getLatestCoordinate helper) to mapRef.current.animateToRegion/fitToCoordinates
so the camera recenters on the most recent position; update references in
useEffect (the dependency on trajectories/isFollowing remains) and inside
handleReturnToCurrentLocation to use the same latest-coordinate logic to unify
behavior.
🧹 Nitpick comments (2)
app/(tabs)/map.tsx (2)

90-93: パン以外のジェスチャーでも追従解除するなら、検知範囲を広げるのが安全です。

onPanDrag だけだとズーム/回転の操作で追従解除されず、次の更新で強制的に戻る可能性があります。onRegionChangeCompleteisGesture を使う方法を検討してください(v1.26.20 の仕様確認前提)。

♻️ 例(ジェスチャー全般で解除)
-  const handleMapPanDrag = useCallback(() => {
-    setIsFollowing(false);
-  }, []);
+  const handleMapInteraction = useCallback((_region, details) => {
+    if (details?.isGesture) setIsFollowing(false);
+  }, []);
-                onPanDrag={handleMapPanDrag}
+                onRegionChangeComplete={handleMapInteraction}

Also applies to: 304-305


327-333: 戻るボタンにアクセシビリティ属性を追加してください。

スクリーンリーダー向けに accessibilityRole / accessibilityLabel を付けると安心です。

♿ 追加例
                <TouchableOpacity
                  style={styles.returnButton}
                  onPress={handleReturnToCurrentLocation}
                  activeOpacity={0.8}
+                 accessibilityRole="button"
+                 accessibilityLabel="現在地に戻る"
                >

@TinyKitten TinyKitten merged commit 084fe55 into main Jan 30, 2026
1 check passed
@TinyKitten TinyKitten deleted the claude/add-location-button-map-JG0Mo branch January 30, 2026 22:11
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.

2 participants