From e4b44c3feda3458c2a1ea6f0e8ede8ffd01188c2 Mon Sep 17 00:00:00 2001 From: Xiaoji Chen Date: Mon, 6 Dec 2021 19:49:00 -0800 Subject: [PATCH] Fix unprojection when using terrain (#1620) --- src/components/interactive-map.js | 7 ++++--- yarn.lock | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/interactive-map.js b/src/components/interactive-map.js index 08170234..8bbc26d7 100644 --- a/src/components/interactive-map.js +++ b/src/components/interactive-map.js @@ -147,9 +147,10 @@ function normalizeEvent(event) { event.point = pos; - const {viewport} = this; - const location = viewport.unproject(pos, {targetZ: viewport.meterOffset[2]}); - event.lngLat = [location[0], location[1]]; + if (this.map) { + const location = this.map.unproject(pos); + event.lngLat = [location.lng, location.lat]; + } return event; } diff --git a/yarn.lock b/yarn.lock index cc09d9d8..d185b7b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3303,9 +3303,9 @@ camelcase@^5.0.0: integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== caniuse-lite@^1.0.30001219: - version "1.0.30001228" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001228.tgz#bfdc5942cd3326fa51ee0b42fbef4da9d492a7fa" - integrity sha512-QQmLOGJ3DEgokHbMSA8cj2a+geXqmnpyOFT0lhQV6P3/YOJvGDEwoedcwxEQ30gJIwIIunHIicunJ2rzK5gB2A== + version "1.0.30001285" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001285.tgz" + integrity sha512-KAOkuUtcQ901MtmvxfKD+ODHH9YVDYnBt+TGYSz2KIfnq22CiArbUxXPN9067gNbgMlnNYRSwho8OPXZPALB9Q== caseless@~0.12.0: version "0.12.0"