Pārlūkot izejas kodu

fix: MapPicker — dark_all+opacity 0.92, inline SVG pin, User-Agent для Nominatim

neyrogovnarik 1 mēnesi atpakaļ
vecāks
revīzija
050974fe60
1 mainītis faili ar 12 papildinājumiem un 2 dzēšanām
  1. 12 2
      frontend/src/components/MapPicker.tsx

+ 12 - 2
frontend/src/components/MapPicker.tsx

@@ -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', {
       maxZoom: 19,
+      opacity: 0.92,
     }).addTo(map)
 
     map.on('click', (e) => {
@@ -35,7 +36,14 @@ export default function MapPicker({ onSelect, onClose }: MapPickerProps) {
       setLat(newLat)
       setLng(newLng)
       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
@@ -50,8 +58,10 @@ export default function MapPicker({ onSelect, onClose }: MapPickerProps) {
     setLoading(true)
     try {
       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()
       onSelect(lat, lng, data.display_name || undefined)
     } catch {