import { MyBetaModalFormProps } from '@/common'; import { MyModal } from '@/components/MyModal'; import L from 'leaflet'; import 'leaflet/dist/leaflet.css'; import { useEffect, useRef, useState } from 'react'; // 修复 Leaflet 图标问题 delete L.Icon.Default.prototype._getIconUrl; L.Icon.Default.mergeOptions({ iconRetinaUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon-2x.png', iconUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon.png', shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-shadow.png', }); // 创建自定义图标 const createCustomIcon = (color = 'red') => { return L.divIcon({ className: 'custom-marker', html: `
`, iconSize: [20, 20], iconAnchor: [10, 10], }); }; interface LocationResult { lat: number; lng: number; address: string; name?: string; } export default function ModalsMapLeaflet( props: MyBetaModalFormProps & { onChange?: (location?: LocationResult) => void; }, ) { const modalRef = useRef地址: ${ location.address }
经纬度: ${location.lat.toFixed( 6, )}, ${location.lng.toFixed(6)}
地址: ${location.address}
经纬度: ${location.lat.toFixed( 6, )}, ${location.lng.toFixed(6)}
地址: {selectedLocation.address}
经纬度: {selectedLocation.lat.toFixed(6)},{' '} {selectedLocation.lng.toFixed(6)}