Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map event carray terrain data #2209

Merged
merged 3 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions src/map/Map.Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,13 @@ Map.include(/** @lends Map.prototype */{

_setCameraMovement(frameOption, frame) {
this.animateTo({
zoom : frameOption.zoom,
center : frameOption.center,
pitch : frameOption.pitch,
bearing : frameOption.bearing
zoom: frameOption.zoom,
center: frameOption.center,
pitch: frameOption.pitch,
bearing: frameOption.bearing
}, {
duration : frameOption.duration,
easing : 'out'
duration: frameOption.duration,
easing: 'out'
}, frame);
},

Expand Down Expand Up @@ -871,6 +871,25 @@ Map.include(/** @lends Map.prototype */{
return false;
},

_queryTerrainInfo(containerPoint) {
const layers = this._getLayers() || [];
for (let i = 0; i < layers.length; i++) {
const layer = layers[i];
if (containerPoint && layer && layer.queryTerrainAtPoint && layer.getTerrainLayer && layer.getTerrainLayer()) {
const coordinate = layer.queryTerrainAtPoint(containerPoint);
if (coordinate) {
return {
coordinate,
altitude: coordinate.z
};
} else {
break;
}
}
}
return null;
},

_getFovRatio() {
const fov = this.getFov();
return Math.tan(fov / 2 * RADIAN);
Expand Down
9 changes: 9 additions & 0 deletions src/map/Map.DomEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,12 @@ Map.include(/** @lends Map.prototype */ {
return false;
},

_wrapTerrainData(eventParam) {
if (eventParam.containerPoint && !eventParam.terrain) {
eventParam.terrain = this._queryTerrainInfo(eventParam.containerPoint);
}
},

_parseEvent(e, type) {
if (!e) {
return null;
Expand All @@ -355,6 +361,7 @@ Map.include(/** @lends Map.prototype */ {
}
}
}
this._wrapTerrainData(eventParam);
return eventParam;
},

Expand Down Expand Up @@ -382,6 +389,7 @@ Map.include(/** @lends Map.prototype */ {
}

const eventParam = this._parseEvent(e, type);
this._wrapTerrainData(eventParam);
if (isMoveEvent(type)) {
this.getRenderer().callInNextFrame(() => {
if (eventParam.domEvent && eventParam.domEvent._cancelBubble) {
Expand Down Expand Up @@ -417,6 +425,7 @@ Map.include(/** @lends Map.prototype */ {
eventParam['viewPoint'] = map.containerPointToViewPoint(containerPoint);
eventParam['pont2d'] = map._containerPointToPoint(containerPoint);
}
this._wrapTerrainData(eventParam);
return eventParam;
}
});
Expand Down