Skip to content

Add satellite/OSM toggle to map#138

Open
Over441 wants to merge 1 commit into
simrail:mainfrom
Over441:OSM-&-Satellite
Open

Add satellite/OSM toggle to map#138
Over441 wants to merge 1 commit into
simrail:mainfrom
Over441:OSM-&-Satellite

Conversation

@Over441

@Over441 Over441 commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Introduce a satellite view toggle for the map.
Adds MdSatellite/MdSatelliteAlt imports, a persistent isSatellite state (useLocalStorage key "isSatellite"), and a control button (with tooltip) that switches the tile layers. When enabled, the map uses Esri World_Imagery tiles plus a semi-transparent OpenRailwayMap overlay; when disabled it falls back to the original OpenStreetMap + OpenRailwayMap attribution and tile.
Also introduces a SatelliteIcon computed from isSatellite and preserves existing controls and fullscreen behavior.

image image

Summary by CodeRabbit

Release Notes

  • New Features
    • Added a map view toggle allowing users to switch between satellite and standard map views. User preference is automatically saved and restored in future sessions.

Introduce a satellite view toggle for the map. Adds MdSatellite/MdSatelliteAlt imports, a persistent isSatellite state (useLocalStorage key "isSatellite"), and a control button (with tooltip) that switches the tile layers. When enabled, the map uses Esri World_Imagery tiles plus a semi-transparent OpenRailwayMap overlay; when disabled it falls back to the original OpenStreetMap + OpenRailwayMap attribution and tile. Also introduces a SatelliteIcon computed from isSatellite and preserves existing controls and fullscreen behavior.
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Map.tsx gains a satellite/OSM view toggle. A isSatellite boolean state is persisted in localStorage, two satellite icons are imported, a tooltip-wrapped control button toggles the state, and the base tile layer rendering switches between Esri World Imagery and OpenStreetMap accordingly.

Changes

Satellite View Toggle

Layer / File(s) Summary
Satellite state and icon imports
packages/map/components/Map.tsx
Imports MdSatellite and MdSatelliteAlt from react-icons/md and introduces isSatellite via useLocalStorage (default false), with a derived SatelliteIcon based on current state.
Toggle control button and conditional tile layers
packages/map/components/Map.tsx
Adds a tooltip-wrapped button that flips isSatellite on click, and conditionally renders Esri World Imagery + OpenRailwayMap overlay (satellite mode) or the previous OSM + OpenRailwayMap tile layers (default mode).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Hoppity-hop, I flip the switch,
From roads to stars without a hitch!
🛰️ Satellite beams and railway lines,
A localStorage memory forever shines.
No matter where the bunny roams,
The map remembers satellite homes!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add satellite/OSM toggle to map' accurately and concisely summarizes the main change: adding a toggle feature to switch between satellite and OpenStreetMap views in the map component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/map/components/Map.tsx`:
- Around line 287-291: The TileLayer component in the Map.tsx file has a
className attribute set to styles.test which appears to be a development
artifact. Verify whether this test styling is intentional for the TileLayer
component; if it is not needed, remove the className prop entirely from the
TileLayer element.
- Around line 280-284: The TileLayer component rendering the OpenRailwayMap
tiles (with url="https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png")
has an attribution prop that duplicates credit already included in the main Esri
TileLayer attribution, causing OpenRailwayMap to appear twice in the map footer.
Remove the attribution prop from this OpenRailwayMap TileLayer component to
eliminate the duplicate while keeping the credit in the primary attribution
source.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0a21d0cc-01f9-442d-8a25-0d4c8c412aff

📥 Commits

Reviewing files that changed from the base of the PR and between bc0fb47 and b6c23cc.

📒 Files selected for processing (1)
  • packages/map/components/Map.tsx

Comment on lines +280 to +284
<TileLayer
url="https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png"
opacity={0.6}
attribution='&copy; <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a>'
/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove duplicate OpenRailwayMap attribution.

The OpenRailwayMap attribution on line 283 duplicates the credit already included in the main Esri TileLayer attribution on line 277. Leaflet combines all TileLayer attributions, causing OpenRailwayMap to appear twice in the map footer.

🧹 Proposed fix
 <TileLayer
   url="https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png"
   opacity={0.6}
-  attribution='&copy; <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a>'
 />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<TileLayer
url="https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png"
opacity={0.6}
attribution='&copy; <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a>'
/>
<TileLayer
url="https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png"
opacity={0.6}
/>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/map/components/Map.tsx` around lines 280 - 284, The TileLayer
component rendering the OpenRailwayMap tiles (with
url="https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png") has an
attribution prop that duplicates credit already included in the main Esri
TileLayer attribution, causing OpenRailwayMap to appear twice in the map footer.
Remove the attribution prop from this OpenRailwayMap TileLayer component to
eliminate the duplicate while keeping the credit in the primary attribution
source.

Comment on lines +287 to +291
<TileLayer
className={styles.test}
attribution='&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> | &copy; <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a> | <a href="https://discord.gg/d65Q8gWM5W">Created by SimRail France 🇫🇷 Community</a>'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Verify or remove className={styles.test}.

The className test on line 288 appears to be a development artifact. Verify whether this styling is intentional; if not, please remove it.

🧹 Proposed fix (if unintentional)
 <TileLayer
-  className={styles.test}
   attribution='&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> | &copy; <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a> | <a href="https://discord.gg/d65Q8gWM5W">Created by SimRail France 🇫🇷 Community</a>'
   url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
 />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<TileLayer
className={styles.test}
attribution='&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> | &copy; <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a> | <a href="https://discord.gg/d65Q8gWM5W">Created by SimRail France 🇫🇷 Community</a>'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<TileLayer
attribution='&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> | &copy; <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a> | <a href="https://discord.gg/d65Q8gWM5W">Created by SimRail France 🇫🇷 Community</a>'
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/map/components/Map.tsx` around lines 287 - 291, The TileLayer
component in the Map.tsx file has a className attribute set to styles.test which
appears to be a development artifact. Verify whether this test styling is
intentional for the TileLayer component; if it is not needed, remove the
className prop entirely from the TileLayer element.

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