Giter VIP home page Giter VIP logo

nebula.gl's Issues

EditableLayer does not compensate for CSS transforms applied to the map

Is this the correct repository to be raising PRs/issues for nebula.gl now? Our project makes extensive use of nebula.gl so I'm interested in its ongoing maintenance and community support :)

EditableLayer does not compensate for CSS transforms applied to the map

Perhaps this is a slightly niche requirement, but our editor allows us to annotate reasonably high resolution static maps for printing, using nebula.gl. We have a zoomable, pannable panel on which the static map is rendered at a fixed resolution, this uses CSS transform scale.

A similar issue to this was reported previously and fixed here react-map-gl-js

Work around

This prototype-based hack works around the issue for me for now, but I wanted to raise this in case there's a chance this can be fixed in a future release so the behavior is consistent with react-map-gl's.

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

Let me know if I can do anything to help with this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.