-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
map.on("click") on touch when using touch screen #9114
Comments
This appears to be a known issue with Electron. See electron/electron#8725. I'm not sure if there's anything we can do on our end. Are you seeing this all the time or is it environment specific? |
Actually as of now, click events are being triggered by touch events on every element except the map element. Ie |
Is this happening on Windows, Linux, Mac or all 3? cc @vakila |
Only tested on windows (don't have access to other OS's). The app is meant for windows |
@bribrah Without more information I'm not sure how much we can help. Can you let us know:
|
for clarification: touch events are triggering click events on literally every other element in my app except the map, so I am confident that electron is not the issue here... touch is failing to trigger "dblclick" and "click" events on the map map.on("touchend") is triggered on map. "touchmove and "touchstart" are as well If I do a The minimal code is just
|
This may be an issue with draw because once I get rid of
touches register as clicks on the map
|
I managed to fix this by using this version: https://gist.github.com/godismyjudge95/a4ea43263db53b90b05511c911cd0034 of mapboxdraw |
Oh interesting. This is apparently a known issue with GL Draw mapbox/mapbox-gl-draw#617 Thanks for pointing this out |
In case someone like me wanted to make it without using MapboxDraw there is a possible trick using events Here is how I've handled if (this.isMobile) {
let touchEndPosition: any;
let touchStartPosition: any;
this.map.on('touchstart', (e) => {
touchStartPosition = e.point;
});
this.map.on('touchend', (e) => {
touchEndPosition = e.point;
if (touchStartPosition.x === touchEndPosition.x &&
touchStartPosition.y === touchEndPosition.y) {
this.onMapClick_(touchEndPosition.x, touchEndPosition.y);
}
});
} else {
this.map.on('click', (e: any) => {
this.onMapClick_(e.point.x, e.point.y);
});
}
So if I am on a mobile device it memorizes the position on Hope it helps |
mapbox-gl-js version: 1.6.0
browser: Electron (chromium)
Steps to Trigger Behavior
Expected Behavior
touching map triggers on click events
Actual Behavior
touching map does not trigget map.on("click") events
The text was updated successfully, but these errors were encountered: