make packages for dart and npm

This commit is contained in:
Hamza-Ayed
2026-04-16 17:48:43 +03:00
parent 9f2a03a979
commit 34dd9ee35a
21 changed files with 1292 additions and 56 deletions
@@ -0,0 +1,34 @@
import 'package:maplibre_gl/maplibre_gl.dart';
class PolylineUtils {
/// Decode a Google-encoded polyline string into a list of LatLng coordinates.
static List<LatLng> decode(String encoded) {
List<LatLng> points = [];
int index = 0, len = encoded.length;
int lat = 0, lng = 0;
while (index < len) {
int b, shift = 0, result = 0;
do {
b = encoded.codeUnitAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lat += dlat;
shift = 0;
result = 0;
do {
b = encoded.codeUnitAt(index++) - 63;
result |= (b & 0x1f) << shift;
shift += 5;
} while (b >= 0x20);
int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));
lng += dlng;
points.add(LatLng(lat / 1E5, lng / 1E5));
}
return points;
}
}