Calculate Route
POST /map/calculate_route.php
Calculate the optimal route between two locations.
Request Body
Destination location (same structure as origin)
Response
Route calculation success status
Calculated route information
Destination location details
Total distance in kilometers
Estimated duration in minutes
Array of coordinates forming the route path
Optional turn-by-turn directions
Request Example
curl -X POST https://76.13.114.194/map/calculate_route.php \
-H "Content-Type: application/json" \
-d '{
"origin": {
"latitud": 4.6814,
"longitud": -74.0479,
"direccion": "Carrera 15 #85-30"
},
"destination": {
"latitud": 4.6533,
"longitud": -74.0602,
"direccion": "Calle 72 #10-20"
}
}'
Response Example
{
"success": true,
"route": {
"origen": {
"latitud": 4.6814,
"longitud": -74.0479,
"direccion": "Carrera 15 #85-30"
},
"destino": {
"latitud": 4.6533,
"longitud": -74.0602,
"direccion": "Calle 72 #10-20"
},
"distancia_km": 4.2,
"duracion_minutos": 15,
"puntos": [
{
"latitud": 4.6814,
"longitud": -74.0479
},
{
"latitud": 4.6750,
"longitud": -74.0510
},
{
"latitud": 4.6650,
"longitud": -74.0550
},
{
"latitud": 4.6533,
"longitud": -74.0602
}
],
"instrucciones": "Siga por Carrera 15 hacia el sur..."
}
}
Calculate Distance
POST /map/calculate_distance.php
Calculate the distance between two points without full route details.
Request Body
Starting location with latitud and longitud
Destination location with latitud and longitud
Response
Calculation success status
Request Example
curl -X POST https://76.13.114.194/map/calculate_distance.php \
-H "Content-Type: application/json" \
-d '{
"origin": {"latitud": 4.6814, "longitud": -74.0479},
"destination": {"latitud": 4.6533, "longitud": -74.0602}
}'
Response Example
{
"success": true,
"distance": 4.2
}
Display Route on Map
Use the route points to draw a polyline on the map:
import 'package:google_maps_flutter/google_maps_flutter.dart';
Polyline createRoutePolyline(RouteModel route) {
final points = route.puntos.map((location) {
return LatLng(location.latitud, location.longitud);
}).toList();
return Polyline(
polylineId: PolylineId('route'),
points: points,
color: Colors.blue,
width: 5,
geodesic: true,
);
}
// Usage in GoogleMap widget:
GoogleMap(
polylines: {createRoutePolyline(route)},
// ... other properties
);
Alternative Routes
Currently, the API returns a single optimal route. Support for alternative routes may be added in future versions.
Traffic Consideration
The duration estimate considers:
- Time of day: Rush hour vs. off-peak
- Day of week: Weekday vs. weekend
- Historical data: Average speeds on specific roads
- Real-time updates: Current traffic conditions (if available)
Error Responses
Invalid coordinates or missing parameters
See Also