Google 地图 Iframe 提供 "XMLHttpRequest cannot load"

Google Maps Iframe gives "XMLHttpRequest cannot load"

当使用 iframe 显示客户设置的 Google 地图时,我不断收到

"XMLHttpRequest cannot load https://accounts.google.com/ServiceLogin?service=mymaps&passive=1209600&continue=https://www.google.com/maps/d/gen204?a%3D58%26width%3D525%26height%3D295%26s%3D7&followup=https://www.google.com/maps/d/gen204?a%3D58%26width%3D525%26height%3D295%26s%3D7. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://www.google.com' is therefor now allowed access.

我知道在访问 json 对象时使用 JSONP,但据我所知,这并不是我真正想做的。

iframe 的代码很简单:

<iframe src="https://www.google.com/maps/d/embed?mid=CLIENTS_IDmsa=0&ie=UTF8&t=h&z=11&output=embed"></iframe>

我是否需要某种密钥才能使用此地图?

地图已显示,但我想摆脱控制台中的错误。

有什么指点吗?

您提供的 url:https://www.google.com/maps/d/embed?mid=CLIENTS_IDmsa=0&ie=UTF8&t=h&z=11&output=embed 不适用于 public。一个有效的 iframe src 应该是这样的:

<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d2624.9983685732213!2d2.29432085!3d48.85824149999999!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x47e66e2964e34e2d%3A0x8ddca9ee380ef7e0!2sgoogle+map+paris+eiffel+tower!5e0!3m2!1sfr!2sbe!4v1387990714927" width="800" height="600" frameborder="0" style="border:0"></iframe>

还有一个可用的 jsfiddle example

这里有一个 documentation 用于 google 地图 iframe。

尽情享受!!