第二次打开谷歌地图时,生成错误,指出您已在此页面上多次包含 Google 地图 JavaScript API

发布于 2025-01-18 05:40:59 字数 456 浏览 3 评论 0原文

我正在使用NPM软件包 Google-Maps [https://www.npmjs.com/package/google-maps]。 并使用Angular材料模式显示Google Map,但是每次我第二次打开地图时,错误会产生:

您已在此页面上多次包含了Google Maps JavaScript API。这可能会导致意外错误。

”“在此处输入图像描述”

我尝试在模态关闭后(在ngondestroy函数中)从HTML的头部删除Google Maps API,但它不起作用。

I am using the npm package google-maps [https://www.npmjs.com/package/google-maps].
and using angular material modal to show google map but whenever I open the map a second time an error generates saying:

You have included the Google Maps JavaScript API multiple times on this page. This may cause unexpected errors.

enter image description here

I have tried removing the google maps APIs from the head of the HTML after the closing of the modal (in the ngOndestroy function), but it's not working.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

污味仙女 2025-01-25 05:40:59

再次调用地图加载函数会产生问题,因此我在角度应用程序的根部创建了一个静态函数。现在,当应用程序加载时,地图加载函数仅被调用一次,并且我在模式实例打开时获取初始化的地图对象。

Calling the map load function again was creating the problem so, I created a static function at the root of the angular application. Now map load function is called only once when the application load and I fetch initialized map object on the opening of the modal instance.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文