sc/full-world-wrap #6
+33
-1
@@ -630,6 +630,22 @@ const APP = () => {
|
|||||||
return 'https://demotiles.maplibre.org/style.json';
|
return 'https://demotiles.maplibre.org/style.json';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleLocateMe = () => {
|
||||||
|
if (!navigator.geolocation) return;
|
||||||
|
navigator.geolocation.getCurrentPosition(
|
||||||
|
(pos) => {
|
||||||
|
const { latitude: lat, longitude: lon } = pos.coords;
|
||||||
|
selectedPointRef.current = { lat, lon };
|
||||||
|
setSelectedPoint({ lat, lon });
|
||||||
|
if (startMarkerRef.current) {
|
||||||
|
startMarkerRef.current.setLngLat([lon, lat]);
|
||||||
|
}
|
||||||
|
mapRef.current?.flyTo({ center: [lon, lat], zoom: 5 });
|
||||||
|
},
|
||||||
|
(err) => console.error('Geolocation error:', err)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const handleShowLineOfSight = async () => {
|
const handleShowLineOfSight = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setSelectedCity(null);
|
setSelectedCity(null);
|
||||||
@@ -661,7 +677,23 @@ const APP = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="app-container">
|
<div className="app-container">
|
||||||
<div className="map-container" ref={mapContainerRef} />
|
<div className="map-container" ref={mapContainerRef}>
|
||||||
|
{!isLocked && (
|
||||||
|
<button
|
||||||
|
className="locate-btn"
|
||||||
|
onClick={handleLocateMe}
|
||||||
|
title="Use my current location"
|
||||||
|
>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||||
|
<circle cx="12" cy="12" r="3"/>
|
||||||
|
<line x1="12" y1="2" x2="12" y2="6"/>
|
||||||
|
<line x1="12" y1="18" x2="12" y2="22"/>
|
||||||
|
<line x1="2" y1="12" x2="6" y2="12"/>
|
||||||
|
<line x1="18" y1="12" x2="22" y2="12"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="controls">
|
<div className="controls">
|
||||||
<div className={`control-group ${isLocked ? 'disabled-controls' : ''}`}>
|
<div className={`control-group ${isLocked ? 'disabled-controls' : ''}`}>
|
||||||
|
|||||||
@@ -13,6 +13,30 @@
|
|||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.locate-btn {
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
left: 10px;
|
||||||
|
z-index: 10;
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
background: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-shadow: 0 1px 4px rgba(0,0,0,0.3);
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #333;
|
||||||
|
transition: background 0.15s, color 0.15s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.locate-btn:hover {
|
||||||
|
background: #f0f0f0;
|
||||||
|
color: #1a73e8;
|
||||||
|
}
|
||||||
|
|
||||||
.controls {
|
.controls {
|
||||||
width: 350px;
|
width: 350px;
|
||||||
background: white;
|
background: white;
|
||||||
|
|||||||
Reference in New Issue
Block a user