Last updated:
0 purchases
geo triangle grid
A package for creating a triangle grid on a map. The grid is created by dividing the map into icosphere with 20 triangles and each triangle is divided into 4 smaller triangles and so on.
Features #
Create triangle from location (latitude, longitude)
Create location from triangle
Get center of triangle
Get triangles of specified depth in bounds
Getting started #
Install the package by adding the following to your pubspec.yaml:
geo_triangle_grid: ^1.1.1
copied to clipboard
Import the package in your code:
import 'package:geo_triangle_grid/geo_triangle_grid.dart';
copied to clipboard
Usage #
Here is a simple example of usage:
final location = LatLng(51.507351, -0.127758);
final triangleHash = TriangleGrid.latLngToHash(location);
print(triangleHash);
// prints: F203320022
final triangle = TriangleGrid.hashToLatLngTriangle(triangleHash);
print(triangle);
// prints: LatLng(latitude: 51.507351, longitude: -0.127758)
copied to clipboard
TriangleGrid.latLngToHash #
Converts a location to a triangle hash. The second parameter is optional and it is the length of the triangle grid.
If not provided, the default value is 20.
String TriangleGrid.latLngToHash(LatLng location, [ int depth = 20 ]);
copied to clipboard
TriangleGrid.hashToLatLngTriangle #
Converts a triangle hash to a triangle with points.
LatLngTriangle TriangleGrid.latLngToHash(String hash);
copied to clipboard
TriangleGrid.hashToLatLng #
Converts a triangle hash to a location.
LatLng TriangleGrid.hashToLatLng(String hash);
copied to clipboard
LatLngTriangle.center #
Gets the center of the triangle.
LatLng get LatLngTriangle.center;
copied to clipboard
Aditional methods #
Package also provides some additional methods to work with vectors and triangles. All of them have documentation, you can find them in the API Reference.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.