question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

forEachLayerAtPixel gives error for WebGLTile Layer

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
valluzzicommented, Oct 5, 2021

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?

1reaction
mike-000commented, Sep 28, 2021

You can access the WebGL context by non-API methods https://codesandbox.io/s/cog-forked-dqreb?file=/main.js

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found