| | |
| | | const isAuto = options?.isAuto ?? true; |
| | | const signature = options?.signature ?? ''; |
| | | const paddingInput = options?.padding; |
| | | mapPerfLog('focus:request', { point, isAuto, signature }); |
| | | // mapPerfLog('focus:request', { point, isAuto, signature }); |
| | | this.enqueue({ |
| | | kind: 'focus', |
| | | isAuto, |
| | |
| | | // 执行时才解析 padding 并换算纵向偏移,保证用的是执行那一刻的卡片高度/缩放 |
| | | run: () => |
| | | this.resolveFocusCenter(point, paddingInput).then((center) => { |
| | | mapPerfLog('focus:exec', { point, center }); |
| | | // mapPerfLog('focus:exec', { point, center }); |
| | | return this.runNative((done) => { |
| | | this.getCtx().moveToLocation({ |
| | | latitude: center.latitude, |
| | |
| | | const [top, , bottom] = padding; |
| | | const offsetPx = (Number(bottom) - Number(top)) / 2; |
| | | if (!Number.isFinite(offsetPx) || offsetPx === 0) { |
| | | mapPerfLog('focus:fallback', { reason: 'zero-offset', offsetPx, padding }); |
| | | // mapPerfLog('focus:fallback', { reason: 'zero-offset', offsetPx, padding }); |
| | | return point; |
| | | } |
| | | return Promise.all([this.getRegionSafe(), this.getMapHeightPx()]).then( |
| | |
| | | const latSpan = |
| | | (region?.northeast?.latitude ?? NaN) - (region?.southwest?.latitude ?? NaN); |
| | | if (!Number.isFinite(latSpan) || latSpan <= 0 || !heightPx) { |
| | | mapPerfLog('focus:fallback', { reason: 'region-or-height-invalid', latSpan, heightPx }); |
| | | // mapPerfLog('focus:fallback', { reason: 'region-or-height-invalid', latSpan, heightPx }); |
| | | return point; |
| | | } |
| | | const degPerPx = latSpan / heightPx; |
| | |
| | | latitude: point.latitude - offsetPx * degPerPx, |
| | | longitude: point.longitude, |
| | | }; |
| | | mapPerfLog('focus:visible-center', { point, center, offsetPx, latSpan, heightPx, degPerPx }); |
| | | // mapPerfLog('focus:visible-center', { point, center, offsetPx, latSpan, heightPx, degPerPx }); |
| | | return center; |
| | | } |
| | | ); |
| | |
| | | private enqueue(cmd: InternalCommand): void { |
| | | // 避让窗口内忽略自动意图 |
| | | if (cmd.isAuto && this.isHolding()) { |
| | | mapPerfLog('skip:hold', { kind: cmd.kind, signature: cmd.signature, points: cmd.points }); |
| | | // mapPerfLog('skip:hold', { kind: cmd.kind, signature: cmd.signature, points: cmd.points }); |
| | | return; |
| | | } |
| | | // 自动意图去重(fit/focus):相同签名且已应用/在途/排队则跳过(用户显式意图不去重) |
| | |
| | | cmd.signature === this.lastAppliedSignature || |
| | | this.queue.some((q) => q.signature === cmd.signature); |
| | | if (duplicate) { |
| | | mapPerfLog('skip:dedup', { signature: cmd.signature, points: cmd.points }); |
| | | // mapPerfLog('skip:dedup', { signature: cmd.signature, points: cmd.points }); |
| | | return; |
| | | } |
| | | } |