-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 #6424
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Two things I'm not sure of:
- Should we continue to allow canvas sources in
setStyle
and theMap
constructor? (With the validator skipping canvas sources rather than warning.) We like it when people use smartsetStyle
, so it seems unfortunate to prevent that in combination with a canvas source. Canvas#serialize
includes thecanvas
property in the result, which is theHTMLCanvasElement
. It looks like this has always been the case, but is this an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me.
Regarding @jfirebaugh 's point about setStyle
, I'm torn. I agree that we want to encourage the use of setStyle
, but I also think there are advantages to keeping MapOptions#style
/ the setStyle
argument spec-compliant. One of those advantages is clarity: it's simpler to describe what style
is allowed to be if it's just "a style spec document", rather than "a style spec document, plus canvas sources, custom sources, and custom layers".
Alternative: deprecate canvas
in style objects (as is currently happening in this PR), and plan a Map#setState()
API that accepts a style, the desired camera state, and extra-style-spec items like canvas/custom sources, custom layers.
I agree the clarity would be nice, but I think since at the moment our current best/only recommendation for "how do I persist my overlays while changing the basemap" is to use |
Yeah, I guess deprecating this without yet having an alternative doesn't really make sense |
As of 79a84c2 we silence validation errors specifically for canvas sources. This makes it pretty easy to rip out in the future (in the event of a |
debug/canvas.html
Outdated
[-122.51423120498657, 37.56161849366671] | ||
] | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can/should this be reverted now?
CanvasSource#canvas
property to accept either a string denoting the ID of the canvas element from which to read (as it previously functioned) or an HTMLCanvasElement (fixes Canvas source initialization from HTML element, instead of element id #6372)map.addSource
, it's possible (and in fact this was done by our own debug example). It seems abrupt to deprecate this quickly and without warning, so validation now warns and does not fail on canvas sources added in the stylesheet.Closes #6372.
Supersedes #6403.
Ref #5545.
Docs now show a separate
CanvasSourceOptions
typedef (🙇♀️ thank you @jfirebaugh):Launch Checklist