Technical

Google Maps on Your Website: Embed vs API, Costs and Keeping Your API Key Safe

A simple map embed is free. Distance calculators and address autocomplete need the Maps API — and an exposed, unrestricted key can be abused. Here's what to know.

In this article · 8 sections
  1. Option 1: The simple embed (free)
  2. Option 2: Maps Platform APIs (usage-billed)
  3. Keeping costs under control
  4. Securing your API key
  5. Privacy considerations
  6. Alternatives
  7. Frequently Asked Questions
  8. Is embedding a Google Map on my contact page free?
  9. Why did I get a Google Cloud bill?
  10. Can I hide the API key completely?
  11. Does a map embed help local SEO?
  12. Need maps or a fare calculator?

Most business websites show a Google Map on the contact page. Taxi and delivery websites often go further: address autocomplete, route maps and automatic distance-based fare calculators. These features use different Google Maps products, with different costs and security needs. Getting this wrong can mean an unexpected bill — or a key that strangers use at your expense.

Option 1: The simple embed (free)

For showing your location, use Google Maps' Share → Embed a map option, which gives an <iframe> code. The Maps Embed API is free to use and doesn't require complex setup. Tips:

  • Embed your actual Business Profile location so the map shows your name and reviews.
  • Add loading="lazy" to the iframe so it doesn't slow the page.
  • Also show the address as text and a "Get Directions" link.

This is all most service businesses need. See contact page design.

Option 2: Maps Platform APIs (usage-billed)

For interactive features, you need the Google Maps Platform, a Google Cloud project with billing enabled, and an API key. Common APIs:

APITypical use
Maps JavaScript APIInteractive maps with custom markers and routes
Places API (Autocomplete)Suggesting addresses as users type pickup/drop locations
Routes / Distance MatrixCalculating distance and travel time for fare estimates
Geocoding APIConverting addresses to coordinates

These are billed per request beyond Google's free usage allowances. Google changed its pricing model in 2025, moving from a single monthly credit to free usage thresholds for each product. Check the current Maps Platform pricing page and set budgets before going live.

Keeping costs under control

  • Only call APIs when needed — for example, calculate distance when the user clicks "Get fare", not on every keystroke.
  • Use autocomplete sessions correctly so a series of suggestions is billed as one session.
  • Cache results for repeated routes (e.g., Ludhiana → Delhi Airport) where Google's terms allow.
  • Set budget alerts in Google Cloud Billing.
  • Set daily quotas per API in the Google Cloud console so costs can't run away.

Securing your API key

Keys used in website JavaScript are visible to anyone who views your page source. That's normal for browser-side Maps keys — but they must be restricted, or anyone can copy and use them on their own sites.

  1. Application restriction: for browser keys, restrict to HTTP referrers — your domain only, e.g. https://yourbusiness.com/*.
  2. API restriction: allow only the APIs that key needs.
  3. Separate keys: one browser key (for maps and autocomplete) and one server key (for distance calculations from your PHP code), each restricted appropriately. Server keys should be restricted by your server's IP address where possible and kept out of public files.
  4. Rotate keys if one has been exposed without restrictions — create a new key, update the site, then delete the old one.
  5. Never commit keys to public code repositories.

Privacy considerations

If you collect customers' locations (for example "use my location" for pickup), ask permission, explain why, and mention it in your privacy policy. See DPDP checklist.

Alternatives

For some uses, alternatives such as OpenStreetMap-based maps can reduce cost. For taxi fare calculators, many operators combine a Google distance lookup with their own fixed fares for popular routes. See taxi website features.

Frequently Asked Questions

Is embedding a Google Map on my contact page free?

Yes, the standard embed is free.

Why did I get a Google Cloud bill?

API usage exceeded free allowances, possibly due to inefficient calls, bots, or an unrestricted key being used elsewhere. Check usage reports and restrict the key.

Can I hide the API key completely?

Browser-side map keys are always visible; restrictions are the protection. Server-side calls keep their key hidden.

Does a map embed help local SEO?

It helps visitors. Your Google Business Profile and consistent details matter far more for rankings.

Need maps or a fare calculator?

Joboo Web builds secure, cost-controlled maps and fare tools. See web development or contact us.

Share this article

Joboo Web

Web design, SEO & digital marketing team · Ludhiana, Punjab

Joboo Web has helped Indian businesses grow online since 2019 — building fast websites and running SEO, Google Ads and social campaigns for clients in 80+ cities. About us →

Keep reading

💬