Skip to main content

Geocode Address

GET /map/geocode.php
Convert a street address to geographic coordinates (latitude/longitude).

Query Parameters

address
string
required
Street address to geocode (URL-encoded)

Response

success
boolean
Geocoding success status
location
object
Location with coordinates

Request Example

curl -X GET "https://76.13.114.194/map/geocode.php?address=Carrera%2015%20%2385-30%2C%20Bogot%C3%A1" \
  -H "Accept: application/json"

Response Example

{
  "success": true,
  "location": {
    "latitud": 4.6814,
    "longitud": -74.0479,
    "direccion": "Carrera 15 #85-30",
    "ciudad": "Bogotá",
    "pais": "Colombia"
  }
}

Reverse Geocode

GET /map/reverse_geocode.php
Convert geographic coordinates to a street address.

Query Parameters

lat
number
required
Latitude in decimal degrees
lng
number
required
Longitude in decimal degrees

Response

success
boolean
Reverse geocoding success status
location
object
Location with address information

Request Example

curl -X GET "https://76.13.114.194/map/reverse_geocode.php?lat=4.6814&lng=-74.0479" \
  -H "Accept: application/json"

Response Example

Success
{
  "success": true,
  "location": {
    "latitud": 4.6814,
    "longitud": -74.0479,
    "direccion": "Carrera 15 #85-30",
    "ciudad": "Bogotá",
    "pais": "Colombia"
  }
}

Use Cases

Address Input with Autocomplete

Geocode user-entered addresses:
class AddressSearchController {
  Future<Location?> searchAddress(String query) async {
    try {
      final location = await geocodeAddress(query);
      return LocationModel.fromJson(location);
    } catch (e) {
      print('Geocoding error: $e');
      return null;
    }
  }
}

Map Marker Click

Get address from map coordinates:
void onMapClick(double lat, double lng) async {
  final location = await reverseGeocode(lat, lng);
  showDialog(
    context: context,
    builder: (context) => AlertDialog(
      title: Text('Ubicación'),
      content: Text(location['direccion']),
    ),
  );
}

Current Location Display

Show user’s current address:
Future<String> getCurrentAddress() async {
  final position = await Geolocator.getCurrentPosition();
  final location = await reverseGeocode(
    position.latitude,
    position.longitude,
  );
  return location['direccion'];
}

Colombian Address Format

Colombian addresses follow a specific format:
  • Calle/Carrera: Street type
  • Number: Street number
  • #: Separator
  • Cross street: Intersecting street
  • -: Separator
  • Building number: Specific building/house number

Examples

  • Carrera 15 #85-30 - Career 15, at intersection with Street 85, building 30
  • Calle 72 #10-20 - Street 72, at intersection with Career 10, building 20
  • Diagonal 50 #25-15 - Diagonal 50, building at 25-15

Error Responses

400
Bad Request
Invalid coordinates or missing address
404
Not Found
Address or coordinates could not be resolved
500
Internal Server Error
Geocoding service error

Notes

The geocoding service uses OpenStreetMap or Google Maps API (depending on configuration). Ensure coordinates are within Colombia for best results.
Geocoding may have rate limits. Cache results when possible to avoid repeated API calls.

See Also

Build docs developers (and LLMs) love