From 29a2df4f1afab99c7dc2b54e4ddc9702356a2ca6 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Mar 2026 23:19:00 +0800 Subject: [PATCH] fix: normalize longitude for popup coordinates Fixes #2692 When popup longitude is greater than 180 degrees, the popup displays at the wrong position. This fix normalizes the longitude to -180 ~ 180 range before converting to container coordinates. --- packages/component/src/popup/popup.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/component/src/popup/popup.ts b/packages/component/src/popup/popup.ts index 47548f654a3..3b5099f9c6c 100644 --- a/packages/component/src/popup/popup.ts +++ b/packages/component/src/popup/popup.ts @@ -397,7 +397,14 @@ export default class Popup return; } const { lng, lat } = this.lngLat; - const { x, y } = this.mapsService.lngLatToContainer([lng, lat]); + // Normalize longitude to -180 ~ 180 range + let normalizedLng = lng; + if (lng > 180) { + normalizedLng = lng - 360 * Math.floor((lng + 180) / 360); + } else if (lng < -180) { + normalizedLng = lng + 360 * Math.floor((-lng + 180) / 360); + } + const { x, y } = this.mapsService.lngLatToContainer([normalizedLng, lat]); this.setPopupPosition(x, y); };