简体   繁体   中英

google map zoom event: Ignored attempt to cancel a touchend event with cancelable=false

I'm using google map in my ionic 2 app, and I want my markers to display/disappear depending on the map's zoom level. So I added the following line in the function "ionViewDidEnter":

    this.map.addListener('idle', this.adjustMarkerVisibility);

However, when I zoom the map (or even just scrolling it), I get a warning

"Ignored attempt to cancel a touchend event with cancelable=false, for example because scrolling is in progress and cannot be interrupted."

and this.adjustMarkerVisibility() is never called. I've searched the error for a while but nothing relating with google map has come up. Anyone with any suggestions? Thanks!

I would post this as a comment, but I don't have the 50 rep to do so yet :(

My team has run into the same issue ourselves with Google Maps and this particular error in Chromium (we are using Kiosk Mode with a hard set resolution on a touchscreen system) and the odd thing we've discovered is that it seems to only throw this error when launched in the original browser tab, if it launches in a new tab created after the browser has started then these warnings go away and everything works as it should. We continue to investigate but it seems like it may have something to do with viewport sizing not being properly set on the initial tab at initial launch. Does this match your experience as well (perhaps we can find a solution for both of us together here)?

After a little searching and looking from solutions i think i have found one, its not very elegant but it works.

I am developing a Cordova app and face the same issue with Google Maps, i researched it and i realized its thrown by the maps api file that its downloaded from Google servers.

The problem with it its the on some line on the file it tries to stop some event wich in that moment cannot be stopped and it has a easy fix.

So, you have to download the api file from Google servers and not to load it dinamycally and do the correction on that file;

There is a line that look like that;

问题

That a.preventDefault(); is the problem, you only have to replace it whit this condition;

if (a.cancelable) a.preventDefault();

So it checks if the event can be cancelled before it tries to cancel it.

You can found the line easy on the obfuscated file by the developers tool on your browser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM