|
@@ -27,6 +27,7 @@ export default function MapPicker({ onSelect, onClose }: MapPickerProps) {
|
|
|
|
|
|
|
|
L.tileLayer('https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', {
|
|
L.tileLayer('https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', {
|
|
|
maxZoom: 19,
|
|
maxZoom: 19,
|
|
|
|
|
+ opacity: 0.92,
|
|
|
}).addTo(map)
|
|
}).addTo(map)
|
|
|
|
|
|
|
|
map.on('click', (e) => {
|
|
map.on('click', (e) => {
|
|
@@ -35,7 +36,14 @@ export default function MapPicker({ onSelect, onClose }: MapPickerProps) {
|
|
|
setLat(newLat)
|
|
setLat(newLat)
|
|
|
setLng(newLng)
|
|
setLng(newLng)
|
|
|
if (markerRef.current) markerRef.current.remove()
|
|
if (markerRef.current) markerRef.current.remove()
|
|
|
- markerRef.current = L.marker([newLat, newLng]).addTo(map)
|
|
|
|
|
|
|
+ markerRef.current = L.marker([newLat, newLng], {
|
|
|
|
|
+ icon: L.divIcon({
|
|
|
|
|
+ className: '',
|
|
|
|
|
+ iconSize: [24, 24],
|
|
|
|
|
+ iconAnchor: [12, 24],
|
|
|
|
|
+ html: '<svg viewBox="0 0 24 24" width="24" height="24" style="filter:drop-shadow(0 1px 3px rgba(0,0,0,0.5))"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z" fill="#FF4B4B"/><circle cx="12" cy="9" r="2.5" fill="white"/></svg>',
|
|
|
|
|
+ }),
|
|
|
|
|
+ }).addTo(map)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
mapInstanceRef.current = map
|
|
mapInstanceRef.current = map
|
|
@@ -50,8 +58,10 @@ export default function MapPicker({ onSelect, onClose }: MapPickerProps) {
|
|
|
setLoading(true)
|
|
setLoading(true)
|
|
|
try {
|
|
try {
|
|
|
const res = await fetch(
|
|
const res = await fetch(
|
|
|
- `https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lng}&format=json&accept-language=ru`
|
|
|
|
|
|
|
+ `https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lng}&format=json&accept-language=ru`,
|
|
|
|
|
+ { headers: { 'User-Agent': 'Photoplaces/1.0' } }
|
|
|
)
|
|
)
|
|
|
|
|
+ if (!res.ok) { onSelect(lat, lng); return }
|
|
|
const data = await res.json()
|
|
const data = await res.json()
|
|
|
onSelect(lat, lng, data.display_name || undefined)
|
|
onSelect(lat, lng, data.display_name || undefined)
|
|
|
} catch {
|
|
} catch {
|