openlayers
openlayers copied to clipboard
how to select feature in WebGLVectorTileLayer
I created a layer as this:
class WebGLVectorTileLayer extends VectorTileLayer {
createRenderer() {
return new WebGLVectorTileLayerRenderer(this, {
style: {
fill: {
fragment: result.builder.getFillFragmentShader(),
vertex: result.builder.getFillVertexShader(),
},
stroke: {
fragment: result.builder.getStrokeFragmentShader(),
vertex: result.builder.getStrokeVertexShader(),
},
symbol: {
fragment: result.builder.getSymbolFragmentShader(),
vertex: result.builder.getSymbolVertexShader(),
},
attributes: {
fillColor: {
size: 2,
callback: (feature) => {
return packColor([21, 255, 18, 1])
},
},
strokeColor: {
size: 2,
callback: (feature) => {
return packColor([255, 255, 255, 1])
},
},
strokeWidth: {
size: 1,
callback: (feature) => {
return 1
},
},
},
},
})
}
}
let layer = new WebGLVectorTileLayer({
source: new VectorTileSource({
attributions: [],
format: new MVT(),
url: API_URL + 'mapManage/GetRasterMVT?z={z}&x={x}&y={y}',
minZoom: MIN_ZOOM,
maxZoom: MAX_ZOOM,
}),
})
now, how to select the feature in this layer? please thank you
The Vector Tile layer example https://openlayers.org/en/latest/examples/vector-tile-selection.html uses feature id, so a fix for #15251 would be needed before something similar can be attempted in WebGL.
It seems this is still not possible. Although #15120 also updated WebGLVectorTileLayerRenderer to enable the VectorStyleRenderer to hit detect by default map.forEachFeatureAtPixel
returns no hits and layer.getFeatures
is not supported.
Hit detection on vector tile layers rendered using WebGL is currently being worked by @gberaudo on and a PR is likely to come in the near future.
We look forward to hearing from you soon. @jahow
So, my case is (not vector tiles, but a Vector Source with features)
- useGeographic()
- WebGL layer with feature source and preloaded features in EPSG:4326
- Default Select tool working with WebGL layer..
It seems that internally some "math" is not yet correctly working.
The value of "ref" variable has nothing related to real "ref" as keys in batch_ data stucture of WebGL renderer... (looks like it should be 1,2,3... N
Source code is a bit of magic at the moment for me in WebGL renderer, so just inconsistency of calculated "ref" value is obvious, may be it helps.
Codebase is OL 8.2.0
@vitalus thanks for reporting, this problem has most likely been fixed by https://github.com/openlayers/openlayers/pull/15340; unfortunately, this hasn't made it to 8.2.0. Could you please let us know if the issue persists when using the ol@dev
latest package? Thanks!
in version 9.0.0-dev.1701358929517 selection is working normally, seems.
It seems this is still not possible. Although #15120 also updated WebGLVectorTileLayerRenderer to enable the VectorStyleRenderer to hit detect by default
map.forEachFeatureAtPixel
returns no hits andlayer.getFeatures
is not supported.
Feature selection remains unavailable for WebGLVectorTileLayerRenderer
, correct? It seems that the behavior described above is still the case (ol 9.2.4
).
Hi, by any chance is there any development related to selecting features from WebGLVectorTileLayer?