-
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 type #3765
Canvas type #3765
Conversation
Based on what I've heard about perf, we don't need to go out of our way to support WebGL canvases. If we get some support for free from |
Curious: will this feature allow me to draw to a 2d canvas, and have it show up on the map (correctly zooming/panning/etc)? Eg will this allow me animate something on the chart, unrelated to geojson and webgl? |
Yes!
Yup 😄 |
Awesome! Can't wait!
…On Fri, Dec 16, 2016 at 6:59 PM Lucas Wojciechowski < ***@***.***> wrote:
Curious: will this feature allow me to draw to a 2d canvas, and have it
show up on the map (correctly zooming/panning/etc)?
Yes!
Eg will this allow me animate something on the chart, unrelated to geojson
and webgl?
Yup 😄
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3765 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AWUtDOVDYVlOagajPyhKwA262W_oJd-Aks5rIt-HgaJpZM4LHVng>
.
|
@@ -45,6 +45,7 @@ | |||
"babel-eslint": "^7.0.0", | |||
"benchmark": "~2.1.0", | |||
"browserify": "^13.0.0", | |||
"canvas": "^1.6.2", |
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.
NOTE: this is a relatively nontrivial dep for something just used in one test…discuss
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 you create a fake Canvas API using Sinon?
Alright, I simplified this a lot by using Once I pull together a good example and tighten up the docs this should be good to 👀 & 🚢
🤔 |
…ce, set evented parent before possible racing for ImageSprite
…Image2D if we resize the canvas
…if 2D context (rather than webgl) is present
(Enables removal of dimensions and secondary _canvas)
Rebased; I think this is good to go. I actually think this is fine to merge without an example, at least for now. I do have an example I've been playing around with, but it depends on loading 60-some images…this can be a follow-up task 🤔🌩 Secondly, tests were failing by hanging/timing out at the ignored line-width property function test because the spec |
|
||
if (!this.tile) return; // not enough data for current position | ||
this._prepareImage(this.map.painter.gl, this.canvas, this.resize); | ||
this.resize = false; |
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.
Maybe convert this to a local var?
} | ||
if (this._hasInvalidDimensions()) { | ||
return this.fire('error', new Error('Canvas dimensions cannot be less than or equal to zero.')); | ||
} |
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.
Maybe make this a no-op instead of a failure
classes: options.classes, | ||
interactive: false, | ||
attributionControl: false, | ||
preserveDrawingBuffer: true | ||
}); | ||
|
||
const _style = new Style(style, map, { validate: !options.ignored }); | ||
map.setStyle(_style); | ||
|
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.
We can use skipped
flags to get around validating these tests without adding new code
* make resize a local var * fail silently on invalid canvas dimensions * use 'skipped' rather than changing suite_implementation for line-width property fn test
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.
There's a regression test that also uses a data-driven line width. If you skip that one, everything should be 🍏 and you're clear to !
aha 🕵️♀️ I saw line-width was still failing and didn't get a chance to look into it yet. Alright, will do! |
This is awesome! One use case I feel I haven't found an optimal solution for has been to effectively show small thumbnail images in Mapbox GL JS, to create maps like this: While it is possible to come up with something quite close to that with the marker plugin I found it hard to make a seamless experience that switches between symbols (dots/icons) and thumbnails based on zoom, and the markers are not data-driven in a similar manner as with other sources which makes it tedious to add and remove them based on map interaction. Could the |
It would be possible to create a Have you tried using implementing this using the |
No..? The I think the best Mapbox GL JS examples of this are: .. but again, both of these use markers and are therefore 1) not data driven by sources (i.e. you have to micro manage the marker behaviour with discrete code hooked into map interaction and other events), and 2) inherently not benefited by WebGL as they are based on regular HMTL in the DOM. What I typically do in a case like this is falling back to a data driven, projected SVG overlay using d3.js. That often solves some of the hurdles, such as projection and a declarative data-driven approach, however, it obviously lacks the ability to work directly with Mapbox sources, such as vector tiles, and you are still not benefiting from WebGL. |
marked and keep attention |
@lucaswoj I'm working with a canvas source right now, wondering this exact thing. I how do I project from lat/lng to canvas coordinates? |
Closes #3580.
This adds a
canvas
source type, which can be used inraster
layers like existingimage
andvideo
sources.To be resolved:
Related feature but not a blocker: raster querying #1404 (came up in #3745)
Launch Checklist