map_services 0.0.2
map_services: ^0.0.2 copied to clipboard
A Flutter package for mapping services including distance calculation, reverse geocoding, and routing.
map_services is a Flutter package that provides easy-to-use services for common mapping tasks such as distance calculation, reverse geocoding, and route fetching.
Features #
- Reverse Geocoding: Convert coordinates (Latitude/Longitude) into human-readable addresses using Nominatim (OSM).
- Distance Calculation: Calculate the distance between two geographical points using the Haversine formula.
- Radius Check: Easily determine if a point is within a specified radius of another point.
- Route Fetching: Get route points between two locations using OSRM.
- Address Search: Search for addresses using the Photon API.
Getting started #
Add map_services to your pubspec.yaml:
dependencies:
map_services:
path: path/to/map_services
Usage #
Distance Calculation #
final mapServices = MapServices();
final pointA = LatLong(14.5995, 120.9842); // Manila
final pointB = LatLong(14.5547, 121.0244); // Makati
double distance = mapServices.getDistanceInKm(pointA: pointA, pointB: pointB);
print('Distance: $distance km');
bool isClose = mapServices.isWithinRadius(center: pointA, target: pointB, radiusKm: 10.0);
print('Is within 10km: $isClose');
Address Search #
final results = await MapServices.searchAddress('Manila');
for (var result in results) {
print('Found: ${result.address} at ${result.latitude}, ${result.longitude}');
}
Detail examples can be found in the /example folder.