11

I'm trying to embed a Google Map in a way that does not use cookies, because of the EU cookie law.
I want to use the Embed API because it can display the place information (rating, directions button...).

I know the Maps JavaScript API does not use cookies and works through the domain maps.googleapis.com.
However, the Maps Embed API uses www.google.com, which sets a NID cookie.

If I try and replace the URL like so

<iframe
  width="600"
  height="450"
  frameborder="0" style="border:0"
  src="https://maps.googleapis.com/maps/embed/v1/place?key=MY_API_KEY&q=Space+Needle,Seattle+WA" allowfullscreen>
</iframe>

There's a 1s flash where it displays it properly but then there's the "Something's wrong" error overlayed.
In the console, this error is returned:

Google Maps JavaScript API error: UnauthorizedURLForClientIdMapError
https://developers.google.com/maps/documentation/javascript/error-messages#unauthorized-url-for-client-id-map-error
Your site URL to be authorized: https://maps.googleapis.com/maps/embed/v1/place?key=MY_API_KEY&q=Space+Needle,Seattle+WA

Is there a way to use the Embed API without cookies?

2 Answers 2

2

I have revisited this issue and I cannot reproduce the problem any longer. Tested with Brave (with Brave Shields down for the site) and Firefox (with disabled uBlock Origin extension).

It seems at this moment https://www.google.com/maps/embed does not use any cookies by itself. If the client is fresh on your site and views a page with a Google Maps embed, there won't be any new cookies set for the domain google.com. However, because the embed is an iframe, in the inspection tool, you will see any other cookie you have because of your interaction with all the google.com services you use. But these ones the client already has and are not related to your embedded map or your site in general.

This now means you can use the Google Maps embed code (obtained with Share) on a opt-in cookie restricted site with no problem.

1
  • Thanks so much for following up! This is great news. Commented Jun 7, 2024 at 15:57
0

You should have put your API_KEY where indicated. That URL in the iframes contains "MY_API_KEY", you should replace it with the key you get from the Google Developer Console.

2
  • I did that, I only removed from the question :)
    – SlimDeluxe
    Commented May 22, 2021 at 18:17
  • Well, it looks like that key is not authorized correctly then because the error sasy pretty much that.
    – Dakatine
    Commented May 24, 2021 at 10:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.