* 智能获取真实地址:优先 Geoapify,备用 OSM
(lat, lon)
| 200 | * 智能获取真实地址:优先 Geoapify,备用 OSM |
| 201 | */ |
| 202 | async function fetchRealAddressSmart(lat, lon) { |
| 203 | // 优先使用 Geoapify(如果有 API Key) |
| 204 | if (geoapifyApiKey) { |
| 205 | const result = await fetchRealAddressFromApi(lat, lon); |
| 206 | if (result) { |
| 207 | console.log('[GeoFill] 使用 Geoapify 地址'); |
| 208 | return result; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | // 降级到 OpenStreetMap |
| 213 | const osmResult = await fetchAddressFromOSM(lat, lon); |
| 214 | if (osmResult) { |
| 215 | console.log('[GeoFill] 使用 OpenStreetMap 地址'); |
| 216 | return osmResult; |
| 217 | } |
| 218 | |
| 219 | return null; |
| 220 | } |
| 221 | |
| 222 | // 各国常见名字库 |
| 223 | const NAME_DATABASE = { |
no test coverage detected