Cesium map due to transfrom caused map offset, click inaccurate problem
- Dominant language
- JavaScript
- Stars
- 15.8k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
Cesium map due to transfrom caused map offset, click inaccurate problem.
Now change the vue file path:/cesium/Source/Core/ScreenSpaceEventHandler.js
Change the getPosition method inside as follows:
function getPosition(screenSpaceEventHandler, event, result) {
var element = screenSpaceEventHandler._element;
var fa = element.offsetWidth/element.getBoundingClientRect().width;
var fa1 = element.offsetHeight/element.getBoundingClientRect().height;
if (element === document) {
result.x = event.clientX * fa;
result.y = event.clientY * fa1;
return result;
}
var rect = element.getBoundingClientRect();
result.x = (event.clientX - rect.left) * fa;
result.y = (event.clientY - rect.top) * fa1;
return result;
}
The above is my way of handling. May I ask whether it can be added into the official document?
Contributor guide
Research direction
Start in cesium/Source/Core/ScreenSpaceEventHandler.js and inspect the getPosition method and its callers. Reproduce the Cesium map offset and inaccurate clicks when the map element uses a transform, then verify that screen coordinates are correctly mapped to the element; check whether the proposed change belongs in the implementation or documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100