Document how to avoid canvas reuse for layers

This restores the `map.forEachLayerAtPixel` functionality.

This is intended to help with openlayers#9720
This commit is contained in:
Olivier Guyot
2019-09-23 17:34:49 +02:00
parent 4abb9c2fd0
commit 449686527b
3 changed files with 27 additions and 0 deletions
+17
View File
@@ -4,6 +4,23 @@
#### Backwards incompatible changes
##### Usage of `Map.forEachLayerAtPixel`
Due to performance considerations, the layers in a map will sometimes be rendered into one
single canvas instead of separate elements.
This means `Map.forEachLayerAtPixel` will bring up false positives.
The easiest solution to avoid that is to assign different `className` properties to each layer like so:
```js
new Layer({
// ...
className: 'my-layer'
})
```
Please note that this may incur a significant performance loss when dealing with many layers and/or
targetting mobile devices.
##### Removal of `TOUCH` constant from `ol/has`
If you were previously using this constant, you can check if `'ontouchstart'` is defined in `window` instead.