-
Notifications
You must be signed in to change notification settings - Fork 128
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
Doesn't work on the Web #40
Comments
If I print the first four points I get this on Android:
but this when I run the same code with Flutter run-d chrome:
|
I found the bug. If you look at the description of the int class you can read Note: When compiling to JavaScript, integers are restricted to values that can be represented exactly by double-precision floating point values. The available integer values include all integers between -2^53 and 2^53, and some integers with larger magnitude. That includes some integers larger than 2^63. The behavior of the operators and methods in the int class therefore sometimes differs between the Dart VM and Dart code compiled to JavaScript. For example, the bitwise operators truncate their operands to 32-bit integers when compiled to JavaScript. The plugin uses the Bitwise Or operator ~ on an int, which can give different results in Android and Web. I copied the decodeEncodedPolyline function and modified it to use BigInt instead of int. See below. (I also changed the return format). I use the function below instead of the plugin. It works both on Android and Web.
|
Thanks for the debug @BoHellgren, this was reported in flutter/plugins as well. |
Thanks to @BoHellgren for fixing the issue. Now with new update you need to change LatLng part to PointLatLng.
I didn't test it on Android or iOs only tested on Web. |
🎉 Thanks! |
When I try to decode encoded polyline using flutter for Web it returns very strange results, for example:
Any ideas to fix it?
The text was updated successfully, but these errors were encountered: