-
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
Make query methods return raster features/sources #1404
Comments
@scothis in that example, the raster layers are hacked in to show up across the whole map. Ideally the raster layer only appears in the popup if it exists where user clicked. |
At this time we don't return raster sources or features from This will be dependent on #3186: querying searches for features in a tile, but since we shoehorn features into a tile, querying a point on a visible raster layer may search for points past a tile (the source cache's tile)'s "extent." The equivalent of the noop mentioned in #1404 (comment) is now query_features.js#L12: raster layers don't have feature indices. This was brought up in #3745. Indeed for something like a canvas-based raster layer it would be helpful to return an [x,y] coordinate mapped back to the original raster data. |
This could be particularly useful for raster layers like the terrain rgb where users could query the pixel values and calculate elevation at a point based on the raster data 💭 |
Any luck on this? This would very useful. |
#5916 notes that raster layers with a canvas source should be included with this feature. |
Exactly the use case I have. Layer with rgb data that I want to be able to query with a click event point. |
Any updates on this? |
any updates or solution ? |
1 similar comment
any updates or solution ? |
Oh gosh.. This would be so helpful especially for querying via RGB values.. fingers crossed on this one |
Any news here? I'd like to query RGB values of underlying raster pixel too. |
While this is not working, you can add a note to the documentation that it does not work for raster layers. This would reduce confusion. |
I'm interested in a solution. Adding my upvote here... |
Yes, and it would be great to get a distribution of raster color values within a given polygon. |
Well, I worked a new method through to the tile.js layer here . The idea is that you could ask for the value from a raster source at a given location:
But this still needs the function to pull a pixel value out of the raster source:
It might be that we need to use the Painter to render the source/layer for a viewport that is one pixel square? That seems like a lot of code for one pixel. Maybe there is a way to query the screen x,y for the already-rendered layer? Would a new painter function work?
I'm hoping someone who knows the internals well can jump in. |
Here is something that is starting to kind of work. I started with the
|
This would be very useful, for generating interactive tooltip information for raster sources. My use case is generating a tooltip for a weather map. |
any updates? |
You can force the map to repaint after querying the color and it will render correctly. I didn't see any flickering or stuttering but it's not great performance wise when dragging the cursor over the map. For my use it was good enough to only query the color when the cursor has stopped moving to improve that. let timeout
map.on("mousemove", e -> {
clearTimeout(timeout)
timeout = setTimeout(() => {
//query the color for a layer created elsewhere
const clr = map.colorForLayerPoint("layer_id", e.point)
//draw the map to fix anything getting the color broke
map.triggerRepaint()
//use clr to do something interesting
useColor(clr)
}, 150)
}) If you want to use the color as a lookup as I did you also need to be careful how you add the layer to the map. Raster layers need resampling set to nearest and you need the latest version with the fix from #12577 to disable interpolation as best as possible. const layer = {
id: "layer_id",
type: "raster",
source: "source_id",
paint: {
"raster-resampling": "nearest"
}
} |
It would be useful if raster layers were included in featuresAt. Especially for raster layers with sources with limited bounds.
I see here that this is a noop:
mapbox-gl-js/js/source/raster_tile_source.js
Line 98 in 2a2aec4
The text was updated successfully, but these errors were encountered: