https://github.com/ayyshim/google_map_polyutil
https://github.com/ayyshim/google_map_polyutil
android dart dartlng decodes flutter flutter-plugin flutter-plugins latlngs meters polygon polyline polyutil tolerance
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ayyshim/google_map_polyutil
- Owner: ayyshim
- License: mit
- Created: 2020-01-17T10:04:46.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-13T12:05:22.000Z (over 4 years ago)
- Last Synced: 2023-08-20T22:15:35.027Z (over 1 year ago)
- Topics: android, dart, dartlng, decodes, flutter, flutter-plugin, flutter-plugins, latlngs, meters, polygon, polyline, polyutil, tolerance
- Language: Dart
- Size: 65.4 KB
- Stars: 8
- Watchers: 2
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# google_map_polyutil
Dart bridge between native google map utility class PolyUtil and your application.
Now you can use all PolyUtil methods that are available in google map utility class PolyUtil.
# Usage
Import `package:google_map_polyutil/google_map_polyutil.dart` and then you are all set to call all it's static methods.
# Methods available
* `containsLocation` [Future] : Computes whether the given point lies inside the specified polygon.
* `decode` [Future>] : Decodes an encoded path string into a sequence of LatLngs.
* `distanceToLine` [Future] : Computes the distance on the sphere between the point p and the line segment start to end.
* `encode` [Future] : Encodes a sequence of LatLngs into an encoded path string.
* `isClosedPolygon` [Future] : Returns true if the provided list of points is a closed polygon (i.e., the first and last points are the same), and false if it is not.
* `isLocationOnEdge` [Future] : Computes whether the given point lies on or near the edge of a polygon, within a specified tolerance in meters.
* `isLocationOnPath` [Future] : Computes whether the given point lies on or near a polyline, within a specified tolerance in meters.
* `simplify` Future> : Simplifies the given poly (polyline or polygon) using the Douglas-Peucker decimation algorithm.# Example
```dart
// Let's prepare dummy arguments.
List paths = [];
paths.add(LatLng(0,0));
paths.add(LatLng(0,1));
paths.add(LatLng(0,2));
paths.add(LatLng(0,4));// Coordinate you want to check if it lies within or near path.
LatLng point = LatLng(0, 3);String encodedString = "???_ibE?_seK?_ibE";
```### containsLocation
```dart
GoogleMapPolyUtil.containsLocation(
point: point,
polygon: paths
).then((result) => print(result));
```### decode
```dart
GoogleMapPolyUtil.decode(
encodedPath: encodedPath
).then((result) => print(result));
```### distanceToLine
```dart
GoogleMapPolyUtil.distanceToLine(
point: LatLng(0, 0),
start: LatLng(0, 0),
end: LatLng(0, 8)
).then((result) => print(result));
```### encode
```
GoogleMapPolyUtil.encode(
path: paths
).then((result) => print(result));
```### isClosedPolygon
```dart
GoogleMapPolyUtil.isClosedPolygon(
poly: path,
polygon: paths
).then((result) => print(result));
```### isLocationOnEdge
```
GoogleMapPolyUtil.isLocationOnEdge(
point: point,
polygon: paths
).then((result) => print(result));
```### isLocationOnPath
```dart
GoogleMapPolyUtil.isLocationOnEdge(
point: point,
polygon: paths
).then((result) => print(result));
```### simplify
```dart
GoogleMapPolyUtil.simplify(
poly: paths,
tolerance: 100
).then((result) => print(result));
```# Author
[Ashim Upadhaya](https://github.com/ayyshim)
> *Note : This plugin can only be used for android application. iOS support in not available yet.*