Skip to content
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

新增工廠第一步:無法選取工廠座標 #101

Closed
Yukaii opened this issue Apr 28, 2021 · 7 comments · Fixed by #102
Closed

新增工廠第一步:無法選取工廠座標 #101

Yukaii opened this issue Apr 28, 2021 · 7 comments · Fixed by #102
Labels
bug Something isn't working

Comments

@Yukaii
Copy link
Contributor

Yukaii commented Apr 28, 2021

ael: 用 Firefox

@Yukaii Yukaii added the bug Something isn't working label Apr 28, 2021
@Yukaii
Copy link
Contributor Author

Yukaii commented Apr 28, 2021

Firefox 可以重現 😂

@Yukaii
Copy link
Contributor Author

Yukaii commented Apr 28, 2021

Firefox 上的 alpha 值取到的是: 153 (transparent) vs 204 (black)

data: [ 158, 193, 143, 153 ] vs [ 88, 87, 85, 204 ]

frontend/src/lib/map.ts

Lines 598 to 599 in 7d74967

this._map.forEachLayerAtPixel(pixel, function (_, data) {
const [,,, a] = data

forEachLayerAtPixel 回傳的已經是 rendered 完、疊合完的 pixel 顏色值

@Yukaii
Copy link
Contributor Author

Yukaii commented Apr 28, 2021

diff 一下 production 和 dev 吧

@Yukaii
Copy link
Contributor Author

Yukaii commented Apr 28, 2021

Openlayer: ^5.3.3 -> ^6.5.0

@Yukaii Yukaii changed the title 無法新增工廠 無法新增工廠點位:第一步 Apr 28, 2021
@Yukaii
Copy link
Contributor Author

Yukaii commented Apr 28, 2021

https://github.com/openlayers/openlayers/blob/main/changelog/upgrade-notes.md#usage-of-mapforeachlayeratpixel

Openlayer breaking change,哭啊

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:

@Yukaii
Copy link
Contributor Author

Yukaii commented Apr 28, 2021

@ol/types 反而忘記升級,這個 issue 一起解掉

@Yukaii Yukaii changed the title 無法新增工廠點位:第一步 新增工廠第一步:無法選取工廠座標 Apr 28, 2021
@Yukaii
Copy link
Contributor Author

Yukaii commented Apr 30, 2021

Firefox 即使在 Layer 加入 className,還是會被疊合成 canvas,致使 forEachLayerAtPixel 錯誤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant