Google Maps Setup
To enable location-based features in your web application, you need to set up Google Maps API. Follow these steps to configure it properly.
Obtaining a Google Maps API Key
- Visit the Google Cloud Console
- Create a new project or select an existing one
- Navigate to the APIs & Services > Credentials section
- Click "Create Credentials" and select "API Key"
- Restrict the API key for better security (optional but recommended)
- Copy your newly created API key
Adding the API Key to Your Project
- Open the
.envfile in your project's root directory - Locate the Google Maps API key variable
- Paste your API key into this variable

Enabling Required Google APIs
- For full functionality, you'll need to enable
Maps JavaScript APIfor your project from Google Cloud Console, go to "APIs & Services" > "Library"
Restricting Google Maps API Key
To prevent abusive use of google maps api key, you have to add http referrers to your project's google maps api key in the google cloud console. To restrict follow the steps below :-
- Select your project in Google Cloud Console (as shown in the below image) and navigate to "APIs & Services" > "Credentials".

- Create a new API Key (image attached below for help).

-
Name your Maps API key, select
Application RestrictionsasWebsites, now add your website's url withouthttps://(make sure to add/*at the end) and clickDone.Note :- (optionally you can add
localhost:3000/*, if you want to test google maps in your local environment. But make sure you remove it while deploying website in production environment)

- Scroll down and select
API RestrictionstoRestrict Key, click and open the dropdown and type forMaps Javascript APIand select that checkbox, hit save button after you seeMaps Javascript APIinSelected APIsi.e. the restricted api keys list.

- After saving the restrictions, click on show key and copy the api key you've just restricted.Now paste it in your website code's
.envfile as value ofNEXT_PUBLIC_GOOGLE_MAPS_API.

Verifying Setup
After configuring your Google Maps API key:
- Restart your development server
- Check if maps are displaying correctly in your application
- Test location-based features like property search by location
If you encounter any issues, verify that:
- Your API key is correctly entered in the
.envfile - You've enabled all required APIs
- Your billing is set up correctly on Google Cloud (required for API usage)