The application is showing InvalidKeyMapError because the Google Maps API key is either missing, invalid, or misconfigured.
Open your browser's developer console and look for debug messages like:
[DEBUG] GoogleMapsProvider: API Key status: { hasKey: true/false, keyLength: X, ... }
Create a file named .env in the root directory with:
VITE_GOOGLE_MAPS_API_KEY=your_actual_api_key_here
- Go to Google Cloud Console
- Navigate to "APIs & Services" > "Credentials"
- Verify your API key exists and is active
Go to "APIs & Services" > "Library" and enable:
- Maps JavaScript API (REQUIRED)
- Places API (if using places functionality)
- Geocoding API (if using geocoding functionality)
-
Click on your API key in Credentials
-
Application restrictions:
- For development: Select "HTTP referrers (web sites)"
- Add:
localhost:*,127.0.0.1:*,http://localhost:* - For production: Add your domain (e.g.,
https://yourdomain.com/*)
-
API restrictions:
- Select "Restrict key"
- Choose: Maps JavaScript API, Places API, Geocoding API
Causes:
- API key is undefined/empty
- API key is invalid/expired
- API key restrictions block your domain
- Required APIs not enabled
Solutions:
- Verify API key is correctly set in
.env - Check API key in Google Cloud Console
- Ensure Maps JavaScript API is enabled
- Check application restrictions allow your domain
Cause: API key restrictions don't allow your current domain Solution: Add your domain to HTTP referrers in Google Cloud Console
Cause: API key doesn't have required permissions Solution: Enable Maps JavaScript API in Google Cloud Console
Open this URL in your browser (replace YOUR_API_KEY):
https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=marker
If it loads without errors, your API key is working.
Check the browser console for detailed error messages:
InvalidKeyMapError= API key is wrong/missingRefererNotAllowedMapError= Domain restrictionsRequestDeniedMapError= API not enabled
After making changes:
npm run devLook for these success messages in console:
[DEBUG] GoogleMapsProvider: Google Maps fully loaded
[DEBUG] GoogleMapsProvider: Script loaded successfully
The application now includes detailed debugging that will show:
- Whether API key is loaded
- Key length and prefix (for security)
- Specific error messages
- Troubleshooting suggestions