簡體   English   中英

第二次打開谷歌 map 時,出現錯誤提示您已在此頁面上多次包含谷歌地圖 JavaScript API

[英]On opening google map second time, error is generating saying that You have included the Google Maps JavaScript API multiple times on this page

我正在使用 npm package谷歌地圖[https://www.npmjs.com/package/google-maps]。 並使用 angular 材料模態來顯示谷歌 map 但每當我第二次打開 map 時,就會生成一條錯誤消息:

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

在此處輸入圖像描述

在模式關閉后(在 ngOndestroy 函數中),我嘗試從 HTML 的頭部刪除谷歌地圖 API,但它不起作用。

再次調用 map 加載 function 會產生問題,因此,我在 angular 應用程序的根目錄下創建了一個 static function。 現在 map 加載 function 僅在應用程序加載時調用一次,我在打開模式實例時獲取初始化 map object。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM