我正試圖在我的地圖上顯示DrawingManager,但我一直得到這個錯誤
。Did you include prop libraries={['drawing']}。in the URL? 未定義的?
不變數
C:/Users/summo/Documents/GitHub/pint-web-frontend/node_modules/invariant/browser。 js:38。
new DrawingManager。
C: /Users/summo/Documents/GitHubsrc/components/drawing/DrawingManager。 tsx:72。
69 | constructor(props: DrawingManagerProps) {
70 | super(props)
71 !
> 72 | invariant(
| ^ 73 | !google.maps.drawing,
74 | `Did you include prop libraries={['drawing]} in the URL? %s`。
75 | google.maps.drawing.
View 編譯
? 17堆疊框架被折疊。
然后
C:/Users/summo/Documents/GitHubsrc/useJsApiLoader。 tsx:54。
51 | return
52 | } else {
53 | loader.load()。 then(function then() {
> 54 | setLoaded(true)
| ^ 55 | })
56 | .catch(function onrejected(error) {
57 | setLoadError(error)
View 編譯了
這個螢屏只在開發中可見。它不會出現如果應用程式在生產中崩潰。
打開你的瀏覽器的開發者控制臺以進一步檢查此錯誤。 點擊'X'或點擊ESC以解散this資訊。
這是我目前的代碼:
import React from "reaction";
import {
GoogleMap。
LoadScript,
Data,
DrawingManager。
} from "@react-google-maps/api"。
const containerStyle = {
width: "100%"。
高度: "600px",
};
function MyComponent(props) {
return (
<LoadScript
googleMapsApiKey="API_KEY"}。
>
<GoogleMap。
mapContainerStyle={containerStyle}。
center={{}>
lat: props.lat_centro,
lng: props.long_centro,
}}
zoom={16}
>
{/* 子組件,如標記、資訊視窗等。*/}
<DrawingManager />
<>/span></>
</GoogleMap>/span>
</LoadScript>
);
}
export default React.memo(MyComponent)。
還沒有找到任何可以幫助解決這個問題的檔案,而且在3個小時內有一個任務要交。誰來救救我吧
忽略了。 "看起來你的帖子主要是代碼,請增加一些細節。" "看起來你的帖子主要是代碼,請增加一些細節。" "看起來你的帖子主要是代碼,請再補充一些細節。"
uj5u.com熱心網友回復:
通過猜測修復了:不得不在LoadScript道具中添加libraries={["drawing"]}。在這里發布之前,我在其他地方都試過了。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/311664.html
標籤:
上一篇:FusedLocationProviderClient總是報告LocationAvailability為假。
下一篇:在谷歌網站上添加有動態資料的地圖
