google_maps_utils 3.0.0 copy "google_maps_utils: ^3.0.0" to clipboard
google_maps_utils: ^3.0.0 copied to clipboard

SphericalUtils, MathUtils and PolyUtils ported from Google's android-maps-utils: distances, headings, bounds, polyline encode/decode and Douglas-Peucker simplification.

Changelog #

3.0.0 #

  • BREAKING: the public API is now typed with double instead of num. Coordinates use Point<double> (so methods take Point<double> / List<Point<double>> and scalar parameters like distance, heading, tolerance, fraction and radius are double); all numeric return types are now double (or int for indices). Callers using List<Point>, Point<num> or integer-coordinate points must switch to Point<double> (e.g. Point(0.0, 0.0)). Behaviour and results are unchanged.
  • Fixed PolyUtils.isLocationOnEdge, isLocationOnPath and locationIndexOnPath/locationIndexOnEdgeOrPath always reporting "not on path" in geodesic mode (even for a point lying exactly on the line). Three boolean returns in the private _isOnSegmentGC helper were inverted during the original Java port; they now match the canonical android-maps-utils source.
  • Fixed & upgraded PolyUtils.containsLocationPoly. It returned wrong results on shapes with multiple vertices when the test point shared a latitude with a vertex (issue #11). It is now a faithful spherical port of android-maps-utils' PolyUtil.containsLocation (verified identical in v2.3.0 and v4.5.1), so it is also correct for polygons that cross the antimeridian (±180°) or enclose a pole — cases the old planar ray-cast could not handle. Added an optional geodesic parameter (great-circle vs Rhumb edges; defaults to false, the closest match to prior behaviour). Verified against an independent 3D winding-number oracle across 200k points. A point on a vertex is inside; the result for a point exactly on an edge is now undefined (it was a fragile, float-exact check before).
  • Performance: PolyUtils.decode no longer re-splits the entire encoded string on every character (O(n²) → O(n)); encode internals simplified. Output is unchanged.
  • Docs: corrected stale Distance and Distance to Line values in the README and example (they predated the earthRadius precision update) and fixed a malformed code fence.
  • Tests: added regression tests for the geodesic on-path/on-edge bug plus broad coverage for previously-untested functions.
  • Pub score: resolved all package:lints/core analysis issues (return-type and dangling-doc-comment lints), eliminated every dartdoc warning, documented the remaining public members, and added analysis_options.yaml, a lints dev-dependency, a repository field and a refreshed package description.
  • Style: local variables now use final name = … (inferred type) when never reassigned and an explicit Type name = … (no var) when reassigned; enabled prefer_final_locals.
  • Funding: added a funding: entry to the pubspec, a .github/FUNDING.yml, and a README sponsor section, all pointing to bus2.me.

Audited and fixed with Claude Opus 4.8 (Ultracode — xhigh + workflows). Sponsored by bus2.me

2.0.0+1 #

  • Fixed toSubBounds

2.0.0+0 #

  • BREAKING CHANGE
  • Changed folder files structure
  • Replaced all int and double by num
  • Added toSubBounds

1.5.1+0 #

  • Fixed import directive

  • Updated earthRadius to more precise value

1.5.0+0 #

  • Calculate route distance

1.4.0+1 #

  • nnbd hotfix for pub.dev dartanalyzer

1.4.0 #

  • nnbd migration

1.3.0+1 #

  • dartfmt -w .

1.3.0 #

1.2.2+1 #

Fixed: 'List' is deprecated and shouldn't be used.

Updated poly stack package

1.2.2+0 #

Fixed changelog order for new releases, left unordered for old releases

Breaking changes:

  • Renamed LatLngBounds to GMULatLngBounds, prevent using prefix import while using google_maps_flutter

  • MathUtils, PolyUtils and SphericalUtils are no longer instantiable

1.2.1+1 #

Added all cardinal directions Removed PT-BR exclusive function translation from cardinals

1.2.1+0 #

Fixed Poly simplify, merge PR thanks to https://github.com/0oL

1.2.0+3 #

Replaced LatLng for Point class, kept LatLngBounds class

1.2.0+2 #

Fixed Readme

Added: https://pub.dev/packages/poly package for replacing Google's containsLocation function for compiler reasons, google java code could not behave as expected, replacing by new algorithm from Poly package fixed the issue, thanks https://github.com/nicolascav for the feedback.

Added https://github.com/nicolascav code as example on example.dart

1.2.0+1 #

1.2.0+0 #

Old realeases #

1.0.0+1 #

Added SphericalUtils and MathUtils

1.0.0+2 #

Added Readme, License and PolyUtils

1.0.0+3 #

Simplified and shorted some codes Fixed Readme

1.1.0+1 #

Added Changelog and formated all files, updated stack package from ^0.0.1 to ^0.1.0 Removed google maps package, replaced for created Lightweight Point and LatLngBounds classes (lat_lng.dart) Fixed docs in all classes Added example.dart

1.1.0+2 #

Fixed description

1.1.0+3 #

Fixed description

1.1.1+0 #

Fixed poly_utils.dart, all 3 functions are working as expected Removed unnecessary dependencies Updated example.dart Added example.dart in Readme

1.1.1+1 #

1.1.1+2 #

1.1.1+3 #

Fixed dart.pub health: DO use curly braces for all flow control structures

1.1.1+4 #

Fixed LatLngBounds variable names Fixed toBounds method, variables in return were inverted

62
likes
160
points
256
downloads

Documentation

API reference

Publisher

verified publisheradriankohls.app

Weekly Downloads

SphericalUtils, MathUtils and PolyUtils ported from Google's android-maps-utils: distances, headings, bounds, polyline encode/decode and Douglas-Peucker simplification.

Homepage
Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

bus2.me

License

Apache-2.0 (license)

More

Packages that depend on google_maps_utils