APIs Used
1. Maps JavaScript API
Purpose: Display the interactive Google Map in the React frontend.
Used for:
Showing the map
Moving the map
Clicking on the map
Dragging the marker
Selecting latitude/longitude
Frontend example:
https://maps.googleapis.com/maps/api/js2. Places Autocomplete API
Purpose: Show address/location suggestions while the customer types.
Example:
Customer types:
"isb"
Google returns:
Islamabad, Pakistan
Islamabad International Airport
Islamabad Capital Territory
...Current Laravel endpoint:
GET /checkout/autocomplete?query=isbCurrent Google endpoint:
https://maps.googleapis.com/maps/api/place/autocomplete/jsonImportant: Google returned:
REQUEST_DENIED
You must enable Billing on the Google Cloud ProjectTherefore, billing must be enabled on the Google Cloud project connected to the API key.
3. Geocoding API
Purpose: Convert an address into latitude and longitude.
Example:
"Islamabad, Pakistan"
↓
lat: 33.6844
lng: 73.0479Current Laravel service:
GoogleMapsGeocodingServiceEndpoint:
https://maps.googleapis.com/maps/api/geocode/json
4. Routes API / Distance Calculation
Purpose: Calculate driving distance and travel time between restaurant and customer.
Example:
Restaurant
↓
driving
↓
Customer
↓
8.4 kmFor a simple delivery radius, such as:
Restaurant radius = 10 kmwe can use the existing Haversine calculation locally instead of making a Google request.
This can reduce API usage.
Recommended Checkout Flow
Customer enters address
↓
Places Autocomplete
↓
Customer selects suggestion
↓
Get latitude + longitude
↓
Check delivery area
↓
┌───────────────────────┐
│ Within delivery area? │
└───────────────────────┘
↓ ↓
YES NO
↓ ↓
Continue Reject
checkout deliveryGoogle APIs vs Local Calculation
Requirement | Recommended |
|---|---|
Display map | Maps JavaScript API |
Address suggestions | Places Autocomplete |
Address → coordinates | Geocoding API |
Simple 10 km radius | Haversine calculation |
Actual driving distance | Routes API |
Address validation | Address Validation API |
Important
Google Maps Platform requires billing to be enabled for the project for the Google service currently being used.
error:
REQUEST_DENIED
You must enable Billing on the Google Cloud Project