forEachLayerAtPixel gives error for WebGLTile Layer
See original GitHub issueDescribe the bug
I receive the following error when implementing a singleclick event for a map with a WebGLTile layer + GeoTiff source:
util.js:9 Uncaught Error: Unimplemented abstract method.
at util.js:9
at abstract (util.js:10)
at WebGLTileLayerRenderer.push../node_modules/ol/renderer/Layer.js.LayerRenderer.getDataAtPixel (Layer.js:133)
at CompositeMapRenderer.push../node_modules/ol/renderer/Composite.js.CompositeMapRenderer.forEachLayerAtPixel (Composite.js:167)
at Map.push../node_modules/ol/PluggableMap.js.PluggableMap.forEachLayerAtPixel (PluggableMap.js:560)
at Map.<anonymous> (MapViewer.vue:179)
at Map.push../node_modules/ol/events/Target.js.Target.dispatchEvent (Target.js:116)
at Map.push../node_modules/ol/PluggableMap.js.PluggableMap.handleMapBrowserEvent (PluggableMap.js:897)
at MapBrowserEventHandler.push../node_modules/ol/events/Target.js.Target.dispatchEvent (Target.js:116)
at MapBrowserEventHandler.<anonymous> (MapBrowserEventHandler.js:129)
To Reproduce
Can’t provide a codesandbox right now due to the txml issue, but use the COG basic example and add something like:
map.on('singleclick', evt => {
const pixel = this.map.getEventPixel(evt.originalEvent);
map.forEachLayerAtPixel(pixel, layer => {
console.log(pixel);
console.log(layer);
});
});
OpenLayers version 6.8.1.
Expected behavior Be able to get pixel values.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
openlayers 4 method forEachLayerAtPixel() throws SecurityError
1. I am trying to select a layer on my map with the singleclick event so I can use layer.getSource().getGetFeatureInfoUrl and display the ......
Read more >OpenLayers v7.2.2 API - Class: Map
The map is the core component of OpenLayers. For a map to render, a view, one or more layers, and a target container...
Read more >Openlayers 3 forEachLayerAtPixel get only layer
I used "forEachLayerAtPixel" to get information of the current layer when zoom. Example: When zoom to layer District then get information layer ......
Read more >OpenLayers v6.1.1 API - Class: Map
forEachLayerAtPixel(pixel, callback, opt_options){T|undefined} inherited ... Note: this may give false positives unless the map layers have had different ...
Read more >Openlayers Versions - Open Source Agenda
Future versions will no longer throw ol/AssertionError with an error code . ... Clear cache when WebGL tile layer source reset (by @mike-000...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is there any way to get the real data value of the pixel? (not the styled one).
in https://codesandbox.io/s/cog-forked-dqreb?file=/main.js example the source is a RGBA source and in this case it returns the rgba value that is also the real value. But in case of a style that classify the data, this example will return the color of styled pixel, not the original pixel data value. Can anyone suggest some solution or approach?
You can access the WebGL context by non-API methods https://codesandbox.io/s/cog-forked-dqreb?file=/main.js