सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
एक डार्ट पैकेज जो Google मैप्स एकीकरण के लिए आवश्यक गणितीय उपकरण प्रदान करता है, जिसमें दूरी और बिंदु के लिए भौगोलिक गणनाओं के लिए SphericalUtils, मूल गणितीय संचालन के लिए MathUtils, और बहुभुज और बहुपथ निर्माण के लिए PolyUtils शामिल हैं। मानचित्रण अनुप्रयोगों में आवश्यक जटिल भौगोलिक गणनाओं को सरल बनाने के लिए डिज़ाइन किया गया है, यह Android, iOS, Web, macOS, Windows और Linux जैसे विभिन्न प्लेटफॉर्मों को समर्थन देता है। पैकेज हल्का है और स्थान-आधारित सेवाओं के लिए उच्च शुद्धता पर ध्यान केंद्रित है।
उपयोग
मानचित्र निर्देशांकों के बीच की दूरी की गणना करना
हेडिंग और बियरिंग निर्धारित करना
बहुभुज और बहुलाइन ज्यामिति के साथ काम करना
भौगोलिक सीमाओं की पुष्टि करना
मानचित्र ओवरले लॉजिक को बढ़ाना
मार्ग निर्देश और नैविगेशन विशेषताएं बनाना
मुख्य विशेषताएँ
गोलीय ज्यामिति के गणना
अक्षांश/देशांतर संचालन के लिए समर्थन
बहुभुज और बहुलाइन उपयोगी कार्य
क्रॉस-प्लेटफॉर्म संगतता
हल्का और निर्भरता-मुक्त
सटीक भूस्थितिजनित गणित
इनके लिए उपयुक्त
मानचित्र-आधारित एप्लिकेशन विकसित कर रहे डेवलपर्स
सटीक दूरी के गणना की आवश्यकता वाले अनुप्रयोग
रूटिंग और जियोफ़ेन्सिंग टूल्स
स्थान-जागरूक यूआई घटक
Google Maps का उपयोग करने वाले Flutter प्रोजेक्ट
भूस्थानिक डेटा प्रसंस्करण
विचार योग्य बातें
गणित और ज्यामिति उपकरणों तक सीमित
कोई सीधा मानचित्र रेंडरिंग या UI घटक नहीं
Google Maps SDK के साथ हस्तचालित एकीकरण की आवश्यकता है
वास्तविक समय के ट्रैकिंग के लिए नहीं बनाया गया है
अन्य मानचित्रण पैकेज के साथ उपयोग करने के लिए सबसे अच्छा
अमान्य निर्देशांक के लिए कोई बिल्ट-इन त्रुटि संभाल नहीं है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Google Maps Utils for Dart/Flutter
A faithful Dart port of the core geometry classes from Google's
android-maps-utils library.
✨ Features
Namespace
What it does
GoogleMapsUtils.spherical
Distances, headings, offsets, interpolation, areas, and bounding boxes on a sphere
GoogleMapsUtils.poly
Polyline encoding/decoding, Douglas-Peucker simplification, point-in-polygon, and on-path/on-edge tests
GoogleMapsUtils.math
Low-level haversine, Mercator projections, clamping, and wrapping helpers
All calculations use the same spherical algorithms as the original Android Java/Kotlin library — results are identical.
final from = Point<double>(0.0, 0.0);
final to = Point<double>(10.0, 5.0);
final distance = GoogleMapsUtils.spherical.computeDistanceBetween(from, to);
// 1241932.5985192063 meters
Heading (Bearing)
final heading = GoogleMapsUtils.spherical.computeHeading(from, to);
// 26.302486345342523 degrees (clockwise from North)
// Move 1000 meters east (heading 90°) from the originfinal origin = Point<double>(0.0, 0.0);
final destination = GoogleMapsUtils.spherical.computeOffset(origin, 1000.0, 90.0);
// Returns the Point at the new location
Compute Offset Origin (Reverse Lookup)
// Given a destination, distance, and heading — find where you startedfinal origin = GoogleMapsUtils.spherical.computeOffsetOrigin(destination, 1000.0, 90.0);
// Returns Point? (null if no solution exists)
Interpolation (SLERP)
// Find the point 25% of the way between two locationsfinal quarter = GoogleMapsUtils.spherical.interpolate(from, to, 0.25);
Path Length
final path = <Point<double>>[
Point(0.0, 0.0),
Point(1.0, 1.0),
Point(2.0, 0.0),
];
final length = GoogleMapsUtils.spherical.computeLength(path);
// Total distance in meters along the path
// Decode a Google Encoded Polyline string into coordinatesfinal path = GoogleMapsUtils.poly.decode(
'wjiaFz`hgQs}GmmBok@}vX|cOzKvvT`uNutJz|UgqAglAjr@ijBz]opA');
// Returns List<Point<double>> with 17 points
Polyline Encoding
// Encode coordinates back to a compact stringfinal encoded = GoogleMapsUtils.poly.encode(path);
Douglas-Peucker Simplification
// Reduce points while preserving shape (tolerance in meters)final simplified = GoogleMapsUtils.poly.simplify(path, 5000.0);
// 17 points → 6 points
Point-in-Polygon
final point = Point<double>(-31.623060, -60.686690);
final polygon = <Point<double>>[
Point(-31.624115, -60.688734),
Point(-31.624115, -60.684657),
Point(-31.621594, -60.686717),
Point(-31.624115, -60.688734),
];
final isInside = GoogleMapsUtils.poly.containsLocationPoly(point, polygon);
// true// Also supports geodesic (great-circle) edges:final isInsideGeodesic = GoogleMapsUtils.poly.containsLocationPoly(
point, polygon, geodesic: true,
);
Point-on-Path Detection
final route = <Point<double>>[
Point(0.0, 0.0),
Point(0.0, 10.0),
];
// Is the point on or near the polyline? (default tolerance: 0.1m)final isOnPath = GoogleMapsUtils.poly.isLocationOnPath(
Point(0.0, 5.0), route, true, // geodesic
);
// true// Get which segment the point falls onfinal segmentIndex = GoogleMapsUtils.poly.locationIndexOnPath(
Point(0.0, 5.0), route, true,
);
// 0 (between route[0] and route[1])
Point-on-Edge (Polygon Boundary)
final square = <Point<double>>[
Point(0.0, 0.0),
Point(0.0, 10.0),
Point(10.0, 10.0),
Point(10.0, 0.0),
];
// Includes the closing segment (last→first)final isOnEdge = GoogleMapsUtils.poly.isLocationOnEdge(
Point(5.0, 0.0), square, true,
);
// true
Distance to a Line Segment
final p = Point<double>(-23.54545, -23.898098);
final start = Point<double>(0.0, 0.0);
final end = Point<double>(10.0, 5.0);
final dist = GoogleMapsUtils.poly.distanceToLine(p, start, end);
// 3675538.019968191 meters
Compute Area
final area = GoogleMapsUtils.spherical.computeArea(polygon);
// Area in square metersfinal signedArea = GoogleMapsUtils.spherical.computeSignedArea(polygon);
// Positive = counter-clockwise, negative = clockwise
Bounding Boxes
// Create bounds from a center point + radius// Returns a LatLngBounds record: (ne: Point<double>, sw: Point<double>)final bounds = GoogleMapsUtils.spherical.toBounds(-23.55, -46.63, 1000.0);
print(bounds.ne); // north-east cornerprint(bounds.sw); // south-west corner// Create bounds from a list of pointsfinal bounds = GoogleMapsUtils.spherical.toBoundsFromPoints(path);
// Get the center of a boundsfinal center = GoogleMapsUtils.spherical.centerFromLatLngBounds(bounds);
// Split bounds into a grid (division² sub-bounds)final tiles = GoogleMapsUtils.spherical.toSubBounds(bounds, division: 3);
// Returns 9 sub-bounds
Closed Polygon Check
GoogleMapsUtils.poly.isClosedPolygon(polygon); // true if first == last point
Custom Tolerance (On-Path / On-Edge)
// Default tolerance is 0.1 meters. Use custom tolerance for proximity:final isNear = GoogleMapsUtils.poly.isLocationOnPathTolerance(
point, polyline, true, 50.0, // 50 meters tolerance
);
// Same for edges:final isNearEdge = GoogleMapsUtils.poly.isLocationOnEdgeTolerance(
point, polygon, true, 50.0,
);
// With index:final idx = GoogleMapsUtils.poly.locationIndexOnPathTolerance(
point, polyline, true, 50.0,
);
Math Helpers (Low-Level)
// Clamp a value to a rangeGoogleMapsUtils.math.clamp(15.0, 0.0, 10.0); // 10.0// Wrap a value into [min, max) — useful for longitudeGoogleMapsUtils.math.wrap(190.0, -180.0, 180.0); // -170.0// Non-negative moduloGoogleMapsUtils.math.mod(-1.0, 360.0); // 359.0// Mercator projection (radians)final y = GoogleMapsUtils.math.mercator(latInRadians);
final lat = GoogleMapsUtils.math.inverseMercator(y);
// Haversine / inverse haversinefinal h = GoogleMapsUtils.math.hav(angleInRadians);
final angle = GoogleMapsUtils.math.arcHav(h);
// Haversine distance on unit spherefinal havDist = GoogleMapsUtils.math.havDistance(lat1, lat2, dLng);
3 of 78 classes from android-maps-utils have been converted — these are the most widely used. Need another class? Open an issue and I'll prioritize it.