| | |
| | | if (cityInfo?.code) { |
| | | const { isInside, newMarkers, sites } = await mapState.updateMapData(res.latitude, res.longitude, cityInfo.code); |
| | | const lockedManualStartSite = forceNearestSite ? null : resolveLockedManualStartSite(cityInfo.code); |
| | | if (lockedManualStartSite) { |
| | | siteState.setCurrentAddress(String(lockedManualStartSite?.name || '')); |
| | | siteState.setCurrentSite(lockedManualStartSite); |
| | | siteState.setIsAdsorbed(true); |
| | | siteState.setShowToolTip(true); |
| | | onLocationSettled( |
| | | Number(lockedManualStartSite?.latitude || res.latitude), |
| | | Number(lockedManualStartSite?.longitude || res.longitude), |
| | | !!isInside |
| | | ); |
| | | return; |
| | | } |
| | | const nearestCandidates = sites.length > 0 ? sites : newMarkers; |
| | | const { adsorbed, marker } = lockedManualStartSite |
| | | ? { adsorbed: false, marker: null } |
| | | : siteState.tryAdsorb(res.latitude, res.longitude, nearestCandidates); |
| | | const { adsorbed, marker } = siteState.tryAdsorb(res.latitude, res.longitude, nearestCandidates); |
| | | const finalLat = adsorbed && marker ? marker.latitude : res.latitude; // 最终纬度 |
| | | const finalLng = adsorbed && marker ? marker.longitude : res.longitude; // 最终经度 |
| | | onLocationSettled(finalLat, finalLng, !!isInside); |