Преглед изворни кода

fix: OSM тайлы (дома, светлее), flex-раскладка кнопки, чёрный фон MapPicker, Nominatim error handling

neyrogovnarik пре 1 месец
родитељ
комит
9138213b9a
3 измењених фајлова са 20 додато и 13 уклоњено
  1. 13 6
      frontend/src/components/MapPicker.tsx
  2. 6 6
      frontend/src/components/PlaceForm.tsx
  3. 1 1
      frontend/src/lib/map.ts

+ 13 - 6
frontend/src/components/MapPicker.tsx

@@ -21,7 +21,7 @@ export default function MapPicker({ onSelect, onClose }: MapPickerProps) {
     if (!mapRef.current || mapInstanceRef.current) return
 
     const map = L.map(mapRef.current, {
-      zoomControl: false,
+      zoomControl: true,
       attributionControl: false,
     }).setView([lat, lng], 14)
 
@@ -61,16 +61,23 @@ export default function MapPicker({ onSelect, onClose }: MapPickerProps) {
         `https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lng}&format=json&accept-language=ru`,
         { headers: { 'User-Agent': 'Photoplaces/1.0' } }
       )
-      const data = await res.json()
-      onSelect(lat, lng, data.display_name || undefined)
+      if (res.ok) {
+        const data = await res.json()
+        if (data.display_name) {
+          onSelect(lat, lng, data.display_name)
+          return
+        }
+      }
     } catch {
-      onSelect(lat, lng)
+      // игнорируем ошибку геокодирования
     }
+    onSelect(lat, lng)
   }
 
   return (
-    <div className="fixed inset-0 z-[60] flex flex-col bg-black/80 backdrop-blur-sm">
-      <div ref={mapRef} className="flex-1" />
+    <div className="fixed inset-0 z-[60] flex flex-col bg-black">
+      <div ref={mapRef} className="min-h-0 flex-1 bg-[#1e293b]" />
+      <style>{'.leaflet-container { background: #1e293b !important; }'}</style>
       <div className="flex items-center justify-between bg-[#1e293b] px-4 py-3">
         <div className="text-sm text-white/60">
           {lat.toFixed(6)}, {lng.toFixed(6)}

+ 6 - 6
frontend/src/components/PlaceForm.tsx

@@ -164,8 +164,8 @@ export default function PlaceForm({ type, onSuccess }: PlaceFormProps) {
         />
       </div>
 
-      <div className="grid grid-cols-5 gap-4">
-        <div className="col-span-2">
+      <div className="flex gap-4">
+        <div className="flex-1">
           <label className="mb-1 block text-sm text-white/60">Широта</label>
           <input
             type="number"
@@ -175,7 +175,7 @@ export default function PlaceForm({ type, onSuccess }: PlaceFormProps) {
             className="w-full rounded-lg border border-white/10 bg-white/5 px-3 py-3 text-white outline-none focus:border-green-500"
           />
         </div>
-        <div className="col-span-2">
+        <div className="flex-1">
           <label className="mb-1 block text-sm text-white/60">Долгота</label>
           <input
             type="number"
@@ -185,13 +185,13 @@ export default function PlaceForm({ type, onSuccess }: PlaceFormProps) {
             className="w-full rounded-lg border border-white/10 bg-white/5 px-3 py-3 text-white outline-none focus:border-green-500"
           />
         </div>
-        <div className="col-span-1 flex items-end">
+        <div className="flex items-end">
           <button
             type="button"
             onClick={() => setShowMapPicker(true)}
-            className="w-auto rounded-lg border border-white/10 bg-white/5 px-3 py-3 text-sm text-white/80 hover:bg-white/10 transition text-center whitespace-nowrap"
+            className="rounded-lg border border-white/10 bg-white/5 px-3 py-3 text-sm text-white/80 hover:bg-white/10 transition text-center whitespace-nowrap"
           >
-            Указать на карте
+            На карте
           </button>
         </div>
       </div>

+ 1 - 1
frontend/src/lib/map.ts

@@ -18,7 +18,7 @@ export interface MarkerOptions {
   color?: string
 }
 
-const TILE_URL = 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png'
+const TILE_URL = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
 const MARKER_COLORS: Record<string, string> = {
   place: '#FFF82A',
   studio: '#FF80DF',