-
Notifications
You must be signed in to change notification settings - Fork 17
Add satellite/OSM toggle to map #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,8 @@ import { | |||||||||||||||||||
| MdFullscreen, | ||||||||||||||||||||
| MdFullscreenExit, | ||||||||||||||||||||
| MdOutlineTraffic, | ||||||||||||||||||||
| MdSatellite, | ||||||||||||||||||||
| MdSatelliteAlt, | ||||||||||||||||||||
| MdSpeakerNotes, | ||||||||||||||||||||
| MdSpeakerNotesOff, | ||||||||||||||||||||
| MdTraffic, | ||||||||||||||||||||
|
|
@@ -60,13 +62,19 @@ const LeaftletMap = ({ serverId }: MapProps) => { | |||||||||||||||||||
| defaultValue: true, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const [isSatellite, setIsSatellite] = useLocalStorage({ | ||||||||||||||||||||
| key: "isSatellite", | ||||||||||||||||||||
| defaultValue: false, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const { toggle: toggleFullscreen, fullscreen } = useFullscreen(); | ||||||||||||||||||||
| const FullscreenIcon = fullscreen ? MdFullscreenExit : MdFullscreen; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const ShowSignalStatusIcon = | ||||||||||||||||||||
| showSignalInfo === true ? MdTraffic : MdOutlineTraffic; | ||||||||||||||||||||
| const RenderPopupIcon = | ||||||||||||||||||||
| renderPopup === true ? MdSpeakerNotes : MdSpeakerNotesOff; | ||||||||||||||||||||
| const SatelliteIcon = isSatellite === true ? MdSatellite : MdSatelliteAlt; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const { selectedTrain, setSelectedTrain } = useSelectedTrain(); | ||||||||||||||||||||
| const [stations, setStations] = useState<Station[] | null>(null); | ||||||||||||||||||||
|
|
@@ -238,6 +246,20 @@ const LeaftletMap = ({ serverId }: MapProps) => { | |||||||||||||||||||
| </button> | ||||||||||||||||||||
| </Tooltip> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| <Tooltip | ||||||||||||||||||||
| label={ | ||||||||||||||||||||
| isSatellite ? "Switch to OSM view" : "Switch to satellite view" | ||||||||||||||||||||
| } | ||||||||||||||||||||
| position="right" | ||||||||||||||||||||
| > | ||||||||||||||||||||
| <button type="button" className={style.icon}> | ||||||||||||||||||||
| <SatelliteIcon | ||||||||||||||||||||
| onClick={() => setIsSatellite((prev) => !prev)} | ||||||||||||||||||||
| size={24} | ||||||||||||||||||||
| /> | ||||||||||||||||||||
| </button> | ||||||||||||||||||||
| </Tooltip> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| <Tooltip | ||||||||||||||||||||
| label={fullscreen ? "Exit fullscreen" : "Enter fullscreen"} | ||||||||||||||||||||
| position="right" | ||||||||||||||||||||
|
|
@@ -249,11 +271,26 @@ const LeaftletMap = ({ serverId }: MapProps) => { | |||||||||||||||||||
| </div> | ||||||||||||||||||||
| </Control> | ||||||||||||||||||||
|
|
||||||||||||||||||||
| <TileLayer | ||||||||||||||||||||
| className={styles.test} | ||||||||||||||||||||
| attribution='© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> | © <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" | ||||||||||||||||||||
| /> | ||||||||||||||||||||
| {isSatellite ? ( | ||||||||||||||||||||
| <> | ||||||||||||||||||||
| <TileLayer | ||||||||||||||||||||
| attribution='Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGS, and the GIS User Community | © <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a> | <a href="https://discord.gg/d65Q8gWM5W">Created by SimRail France 🇫🇷 Community</a>' | ||||||||||||||||||||
| url="https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}" | ||||||||||||||||||||
| /> | ||||||||||||||||||||
| <TileLayer | ||||||||||||||||||||
| url="https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png" | ||||||||||||||||||||
| opacity={0.6} | ||||||||||||||||||||
| attribution='© <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a>' | ||||||||||||||||||||
| /> | ||||||||||||||||||||
| </> | ||||||||||||||||||||
| ) : ( | ||||||||||||||||||||
| <TileLayer | ||||||||||||||||||||
| className={styles.test} | ||||||||||||||||||||
| attribution='© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> | © <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" | ||||||||||||||||||||
| /> | ||||||||||||||||||||
|
Comment on lines
+287
to
+291
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify or remove The className 🧹 Proposed fix (if unintentional) <TileLayer
- className={styles.test}
attribution='© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> | © <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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| )} | ||||||||||||||||||||
|
|
||||||||||||||||||||
| <LayersControl position="bottomright" collapsed={false}> | ||||||||||||||||||||
| <LayersControl.Overlay | ||||||||||||||||||||
| checked={ | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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='© <a href="http://www.openrailwaymap.org/">OpenRailwayMap</a>' />📝 Committable suggestion
🤖 Prompt for AI Agents