| | |
| | | |
| | | syncFenceEditGuideHover(event) |
| | | |
| | | // 鼠标当前位置是否落在当前城市范围内,只在“新建围栏”阶段实时判断; |
| | | // 默认浏览态、围栏编辑态和其他实体创建态都不再触发位置查询与 hover 提示。 |
| | | if (!fenceCreateMode.value) { |
| | | fenceCreateOutsideCurrentCity.value = false |
| | | hideCityBoundaryHoverTooltip() |
| | | return |
| | | } |
| | | |
| | | const currentPoint: LngLatTuple = [lng, lat] |
| | | const inCurrentCityBoundary = isPointInCurrentCityBoundary(currentPoint) |
| | | |
| | | if (fenceCreateMode.value) { |
| | | if (!hasFenceDrawingStarted()) { |
| | | fenceCreateOutsideCurrentCity.value = false |
| | | hideCityBoundaryHoverTooltip() |
| | | return |
| | | } |
| | | // 仅在鼠标首次移出当前行政区时提示一次,避免移动过程中连续刷屏。 |
| | | const nextOutsideCurrentCity = !inCurrentCityBoundary |
| | | if (nextOutsideCurrentCity && !fenceCreateOutsideCurrentCity.value) |
| | | showFenceCreateBoundaryTip() |
| | | fenceCreateOutsideCurrentCity.value = nextOutsideCurrentCity |
| | | hideCityBoundaryHoverTooltip() |
| | | return |
| | | } |
| | | |
| | | fenceCreateOutsideCurrentCity.value = false |
| | | if (stationCreateMode.value) { |
| | | hideCityBoundaryHoverTooltip() |
| | | return |
| | | } |
| | | |
| | | cityBoundaryHoverPosition.x = Number(event.pixel.x || 0) + 16 |
| | | cityBoundaryHoverPosition.y = Number(event.pixel.y || 0) - 12 |
| | |
| | | } |
| | | cityBoundaryHoverText.value = currentCityLabel.value || '当前城市' |
| | | cityBoundaryHoverOutsideSelected.value = false |
| | | return |
| | | } |
| | | |
| | | cityBoundaryHoverOutsideSelected.value = true |
| | | const cacheKey = getHoverCityCacheKey(currentPoint) |
| | | const cachedCityName = cityBoundaryHoverTextCache.get(cacheKey) |
| | | if (cachedCityName) { |
| | | if (cityBoundaryHoverQueryTimer) { |
| | | clearTimeout(cityBoundaryHoverQueryTimer) |
| | | cityBoundaryHoverQueryTimer = null |
| | | } |
| | | cityBoundaryHoverText.value = cachedCityName |
| | | else { |
| | | cityBoundaryHoverOutsideSelected.value = true |
| | | return |
| | | const cacheKey = getHoverCityCacheKey(currentPoint) |
| | | const cachedCityName = cityBoundaryHoverTextCache.get(cacheKey) |
| | | if (cachedCityName) { |
| | | if (cityBoundaryHoverQueryTimer) { |
| | | clearTimeout(cityBoundaryHoverQueryTimer) |
| | | cityBoundaryHoverQueryTimer = null |
| | | } |
| | | cityBoundaryHoverText.value = cachedCityName |
| | | cityBoundaryHoverOutsideSelected.value = true |
| | | } |
| | | else { |
| | | cityBoundaryHoverText.value = '查询中...' |
| | | cityBoundaryHoverOutsideSelected.value = true |
| | | if (cityBoundaryHoverQueryTimer) |
| | | clearTimeout(cityBoundaryHoverQueryTimer) |
| | | const seq = ++cityBoundaryHoverQuerySeq |
| | | cityBoundaryHoverQueryTimer = setTimeout(() => { |
| | | cityBoundaryHoverQueryTimer = null |
| | | void resolveHoverCityName(currentPoint, cacheKey, seq) |
| | | }, 120) |
| | | } |
| | | } |
| | | |
| | | cityBoundaryHoverText.value = '查询中...' |
| | | cityBoundaryHoverOutsideSelected.value = true |
| | | if (cityBoundaryHoverQueryTimer) |
| | | clearTimeout(cityBoundaryHoverQueryTimer) |
| | | const seq = ++cityBoundaryHoverQuerySeq |
| | | cityBoundaryHoverQueryTimer = setTimeout(() => { |
| | | cityBoundaryHoverQueryTimer = null |
| | | void resolveHoverCityName(currentPoint, cacheKey, seq) |
| | | }, 120) |
| | | if (!hasFenceDrawingStarted()) { |
| | | fenceCreateOutsideCurrentCity.value = false |
| | | return |
| | | } |
| | | // 仅在鼠标首次移出当前行政区时提示一次,避免移动过程中连续刷屏。 |
| | | const nextOutsideCurrentCity = !inCurrentCityBoundary |
| | | if (nextOutsideCurrentCity && !fenceCreateOutsideCurrentCity.value) |
| | | showFenceCreateBoundaryTip() |
| | | fenceCreateOutsideCurrentCity.value = nextOutsideCurrentCity |
| | | } |
| | | |
| | | function searchDistrictBoundary(keyword: string): Promise<LngLatTuple[][]> { |