Installation
This guide will help you install and configure the Angular Google Maps component.Install the Package
The easiest way to install is using Angular CLI:Get a Google Maps API Key
You need a Google Maps API key to use the component. Follow these steps:- Go to the Google Maps Platform
- Create a new project or select an existing one
- Enable the Maps JavaScript API
- Create credentials (API key)
- (Optional) Restrict your API key to prevent unauthorized use
Load the Google Maps API
Recommended: Dynamic Library Import
Add the Dynamic Library Import script to yourindex.html:
YOUR_API_KEY_HERE with your actual API key.
Alternative: Legacy Script Tag
You can also use the legacy script tag, though it’s not recommended:Import Components
Standalone Components
For standalone components, import what you need:NgModule
For NgModule-based apps, importGoogleMapsModule:
Verify Installation
Create a simple map to verify everything is working:Troubleshooting
Map Not Displaying
- Check API Key: Ensure your API key is valid and has the Maps JavaScript API enabled
- Check Console: Look for errors in the browser console
- Check Billing: Ensure billing is enabled on your Google Cloud project
- Check Restrictions: If you’ve restricted your API key, ensure your domain is allowed
TypeScript Errors
If you get TypeScript errors aboutgoogle.maps types:
tsconfig.json:
Next Steps
- Learn about the GoogleMap component
- Add markers to your map
- Explore overlays like polylines and polygons