Ultimate Guide: Extract Google Maps Data with JavaScript
Google Maps is not just a navigation tool. It's a massive business database: name, address, phone, rating, reviews, hours, website — it’s all there, one listing at a time. This ultimate guide to extracting data from Google Maps with JavaScript shows you how to leverage this wealth of information, whether you know how to code or not.
Why Extract Data from Google Maps?
Before we talk about code, let’s ask the question: why scrape Google Maps?
The reasons vary by business. Here are the most common ones.
Generate Targeted Leads
This is the number one use case. A web agency looks for restaurants without websites. A software provider targets medical practices in a region. An HR service provider prospects SMEs with fewer than 50 employees.
Google Maps provides access to thousands of listings by sector and geographic area. Extracting this data means building a list of qualified prospects in just a few minutes — without purchasing a database.
Analyze the Competition
Scraping is not just for prospecting. A restaurant chain can analyze ratings, reviews, and the density of competitors in an area before opening a new location.
How many restaurants are within a 2 km radius? What is their average rating? How many reviews do they have? This data informs concrete strategic decisions.
Identify New Trade Areas
A company looking to expand geographically can map potential demand before investing. Extracting Google Maps data from a city or region provides a clear picture of the local economic fabric.
Understanding the Basics of the Google Maps API
The Google Maps API is the official entry point for programmatically accessing Google Maps data. It offers several useful services for data extraction.
Getting an API Key
To get started, you need to create an account on Google Cloud Platform. Then, enable the Maps JavaScript API in your project. Google generates a unique API key — this key authorizes your requests.
Without an API key, no requests go through. With a key, you can call the various services of the API from your JavaScript code.
Main Available Services
The Google Maps API offers several services that can be utilized in JavaScript:
- Geocoding: converts an address into GPS coordinates (latitude, longitude)
- Places: searches for establishments by type and geographic area
- Directions: calculates routes between two points
- Distance Matrix: measures distances and travel times between multiple points
For commercial data extraction, the Geocoding and Places services are the most useful.
Concrete Examples of Data Extraction with JavaScript
Here are three practical examples for extracting data from Google Maps with JavaScript.
1. Convert an Address to GPS Coordinates (Geocoding)
The Geocoding service transforms a textual address into geographic coordinates. Useful for geolocating prospects or points of sale.
var geocoder = new google.maps.Geocoder();
geocoder.geocode(
{ address: '10 Rue de la Paix, Paris' },
function(results, status) {
if (status === 'OK') {
var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
console.log("Latitude: " + latitude + ", Longitude: " + longitude);
} else {
console.log("Geocoding failed: " + status);
}
}
);
This code returns the GPS coordinates of a Parisian address. You can loop through a list of addresses to geolocate an entire file.
2. Find Establishments Near a Location (Places API)
The nearbySearch service searches for establishments within a given radius around a geographic point. This is at the heart of data extraction for prospecting.
var placesService = new google.maps.places.PlacesService(map);
var request = {
location: new google.maps.LatLng(48.8566, 2.3522), // Paris
radius: 5000, // 5 km radius
type: ['restaurant']
};
placesService.nearbySearch(request, function(results, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
results.forEach(function(place) {
console.log(
"Name: " + place.name +
", Address: " + place.vicinity +
", Rating: " + place.rating
);
});
}
});
This code lists restaurants within a 5 km radius around Paris, with their name, address, and Google rating.
Note: nearbySearch returns a maximum of 20 results per request. You can paginate up to 3 pages, totaling 60 results per search. To cover an entire city, you need to break the area into several sub-areas and multiply the requests.
3. Retrieve Establishment Details (Place Details)
nearbySearch provides basic information. To access the phone number, website, hours, and reviews, you need to call getDetails on each place_id.
var request = {
placeId: 'ChIJD7fiBh9u5kcRYJSMaMOCCwQ', // Place ID of the establishment
fields: ['name', 'formatted_address', 'formatted_phone_number',
'website', 'rating', 'reviews', 'opening_hours']
};
placesService.getDetails(request, function(place, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
console.log("Name: " + place.name);
console.log("Phone: " + place.formatted_phone_number);
console.log("Website: " + place.website);
console.log("Rating: " + place.rating);
}
});
Each call to getDetails consumes an API credit. With thousands of establishments, the bill can add up quickly.
4. Track Movements on a Map
Another use case: listen for position changes on an interactive map. Useful for tracking applications or dynamic mapping.
google.maps.event.addListener(map, 'center_changed', function() {
var center = map.getCenter();
console.log(
"Center: Latitude=" + center.lat() +
", Longitude=" + center.lng()
);
});
This code displays the coordinates of the center of the map with each user movement.
The Limits and Constraints of the Google Maps API
The Google Maps API is powerful, but it imposes significant constraints to be aware of before diving in.
Quotas and Billing
Google charges for the Places API based on usage. Here are the indicative rates (in USD, Google rates):
- Nearby Search: $0.032 per request
- Place Details: $0.017 per request (basic fields) to $0.085 (advanced fields)
- Geocoding: $0.005 per request
To extract 10,000 establishments with their full details, the cost can exceed $500. Google offers a monthly credit of $200, but it runs out quickly on large volumes.
The 120 Results Limit
nearbySearch returns 20 results per page, with a maximum of 3 pages, totaling 60 results per request. To cover an entire city, you need to multiply the search points and requests. This is feasible but complex to implement correctly.
Error Management
Exceeding the quota triggers OVER_QUERY_LIMIT errors. The application stops or returns incomplete data. You need to implement robust error management: retry with exponential backoff, cache already obtained results, correct pagination.
Terms of Use
The Google Maps TOS explicitly prohibits permanently storing Places data (except for exceptions). Extracting data for resale or redistribution violates the terms of use. Use the data for your internal purposes — prospecting, analysis, competitive intelligence.
Optimizing API Requests to Reduce Costs
Here are some best practices to limit the bill.
Only request the necessary fields. The Places API charges differently based on the fields requested. If you don’t need reviews or photos, don’t include them in the fields parameter.
Cache results. If you query the same area multiple times, store the results in a local database. Avoid redundant requests.
Smartly segment areas. To cover a large city, use a grid of points spaced 2-3 km apart instead of starting from a single central point. This maximizes coverage without exceeding the 60 results per request.
Use pagination correctly. nearbySearch returns a next_page_token when there are more results. Wait 2 seconds before calling the next page — Google imposes this delay.
When the API is Not Enough: The No-Code Alternative
Coding a Google Maps scraper in JavaScript takes time. Managing quotas, pagination, errors, storage — it’s a project in itself. And the API bill can become significant on large volumes.
For sales and marketing teams wanting Google Maps leads without writing a line of code, IBLead is a direct alternative.
IBLead is a pre-indexed database of 50M+ businesses from Google Maps, covering 37 countries. Everything is already extracted and indexed — you filter by city, sector, Google rating, number of reviews, website technologies, and export to CSV in 2 minutes.
No API to configure. No quotas to manage. No code to maintain.
The database is updated weekly. The export is instant — the data is already there, no need to wait for a scrape.
Each listing contains 50+ fields: name, address, phone, email, website, Google rating, number of reviews, hours, GPS coordinates, social media, and detected technologies on the website (160+ recognized technologies — WordPress, Shopify, Google Ads, Mailchimp, etc.).
For €44 for 10,000 leads, or €0.004 per contact, it’s a concrete option for teams prospecting at volume.
free credits — 200 credits included
FAQ — Frequently Asked Questions
Is it legal to scrape Google Maps?
Using the official Google Maps API is legal within the terms of use of Google. However, scraping Google Maps HTML directly (without going through the API) violates the TOS and can lead to your IP being blocked or legal action. For commercial use, the official API or a pre-indexed database like IBLead are compliant options.
What is the result limit of the Google Maps Places API?
The nearbySearch API returns 20 results per page, with a maximum of 3 pages, totaling 60 results per request. To bypass this limit, you need to multiply search points in a geographic area and aggregate the results. This is the main technical constraint for extracting data at scale.
How much does the Google Maps API cost for data extraction?
Google offers a monthly credit of $200 (about €185). Beyond that, rates vary: about $0.032 per Nearby Search request and $0.017 to $0.085 per Place Details request. For 10,000 establishments with complete details, the cost can exceed $500. Pre-indexed solutions like IBLead are often cheaper at large volumes.
Can we extract Google Maps reviews via the API?
Yes, the Place Details API returns up to 5 reviews per establishment. To access more reviews, you need to use other methods. IBLead extracts up to 500 reviews per listing — full text, rating, date, and author — which no direct competitor offers.
What is the difference between the Google Maps API and a tool like IBLead?
The Google Maps API is a real-time service: you send a request, Google returns the current data. It’s flexible but costly and limited in volume. IBLead is a pre-indexed database: the data is already extracted, filtered, and ready for export. No code, no quota, instant export. Both approaches meet different needs — the API for dynamic applications, IBLead for high-volume commercial prospecting.
Extracting data from Google Maps with JavaScript is entirely feasible. The official API provides access to reliable data, with clear code examples and comprehensive documentation. But it has its limits: quotas, costs, complexity of pagination, strict terms of use.
For developers building mapping applications or internal tools, the API remains the right option. For sales teams wanting qualified prospect lists quickly, a pre-indexed database like IBLead is more straightforward and less costly at scale.
Ready to get started?
Access every Google Maps business, enriched with emails and legal data.
Try IBLead freeRelated articles
10 Proven Tips to Get Customers to Leave More Google Reviews on Maps
Learn 10 actionable strategies to increase Google Maps reviews. Timing, incentives, QR codes, and response tactics that actually work.
7 Cold Email Mistakes to Avoid: Examples & Templates
Avoid these 7 cold email mistakes to avoid examples that kill response rates. Real examples, AIDA templates, and proven fixes for better outreach.
ABM Google Maps Data: The Complete Strategic Guide
Learn how abc account based marketing google maps data drives 208% more revenue. Build precise target lists with 50M+ pre-indexed businesses.