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

Canvas source initialization from HTML element, instead of element id #6372

Closed
ryanbaumann opened this issue Mar 21, 2018 · 1 comment
Closed

Comments

@ryanbaumann
Copy link
Contributor

ryanbaumann commented Mar 21, 2018

mapbox-gl-js version: 0.44.1

Background

The Canvas source type supports initialization from a canvas HTML element id only. https://www.mapbox.com/mapbox-gl-js/style-spec#sources-canvas-canvas

Feature Request

Allow initialization of Canvas source from an HTML canvas element, the same way that a mapboxgl map object can be bound directly to an HTML element https://www.mapbox.com/mapbox-gl-js/api/#map.

Use case

Canvas elements in an application framework do not have an HTML id element. Adding HTML unique ids to each Canvas element would add complexity to the application, instead of just creating the canvas element and passing to the Canvas source.

cc @lbud

@lbud
Copy link
Contributor

lbud commented Mar 26, 2018

This is definitely feasible. It would mainly entail:

  • Changing CanvasSource so that it can optionally read directly from the element if options.canvas is an HTMLCanvasElement
  • Modifying the CanvasSource#canvas specification to accept either a string or HTMLCanvasElement. Currently there are no other union types in the spec — all type values are either a single string-represented type or an enum type represented by an object — so we'd need to determine the best way to represent a union type and validate it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants