第二次打开谷歌地图时,生成错误,指出您已在此页面上多次包含 Google 地图 JavaScript API
我正在使用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.
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
再次调用地图加载函数会产生问题,因此我在角度应用程序的根部创建了一个静态函数。现在,当应用程序加载时,地图加载函数仅被调用一次,并且我在模式实例打开时获取初始化的地图对象。
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.