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

[Bug] EditableGeoJsonLayer does not compensate for CSS transforms #149

Open
2 of 8 tasks
federicoviscomi opened this issue Oct 29, 2024 · 1 comment
Open
2 of 8 tasks
Labels
bug Something isn't working

Comments

@federicoviscomi
Copy link

federicoviscomi commented Oct 29, 2024

Module

  • deck.gl-community/arrow-layers
  • deck.gl-community/bing-maps
  • deck.gl-community/editable-layers
  • deck.gl-community/experimental
  • deck.gl-community/graph-layers
  • deck.gl-community/layers
  • deck.gl-community/react
  • deck.gl-community/react-graph-layer

Description

When drawing a polygon on a map, the polygon is not drawn in the same points where I click. (on the other hand deck.gl appears to compensate properly for CSS transforms)

Expected Behavior

No response

Steps to Reproduce

Draw a polygon here https://codesandbox.io/p/sandbox/deck-gl-community-editable-layers-css-scale-bug-xzy7zr

Environment

  • Framework version: react-scripts
  • Browser: Google Chrome Version 130.0.6723.70 (Official Build) (64-bit)
  • OS: Windows 11 Pro

Logs

No response

@federicoviscomi federicoviscomi added the bug Something isn't working label Oct 29, 2024
@federicoviscomi federicoviscomi changed the title [Bug] [Bug] EditableGeoJsonLayer does not compensate for CSS transforms Oct 29, 2024
@rjwats
Copy link

rjwats commented Oct 29, 2024

We have worked around this issue with the following hack (which we had in place when using nebula.gl too)

/**
 * This code hacks editable-layers to make the getScreenCoords function work with a CSS scale transformation applied
 */
export const applyEditableGeoJsonLayerOverrides = () => {
  EditableGeoJsonLayer.prototype.getScreenCoords = (function (this: EditableGeoJsonLayer, pointerEvent: any): [number, number] {
    const canvas = this.context.device.getCanvasContext().canvas as HTMLCanvasElement;
    const rect = canvas.getBoundingClientRect();
    const scaleX = rect.width / canvas.offsetWidth;
    const scaleY = rect.height / canvas.offsetHeight;
    return [
      (pointerEvent.clientX - rect.left - canvas.clientLeft) / scaleX,
      (pointerEvent.clientY - rect.top - canvas.clientTop) / scaleY
    ];
  });
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants