Cannot find namespace 'google'.
@amuramoto 已经在做这个了。
开始于 2022年7月12日。
评估
这个 Issue 还没有评估数据。
描述
Operating system
macOS 12.04
Browser Version
Firefox 100.0.2
How severe is the bug?
moderate
Bug description
This bug is about the code excerpt from https://developers.google.com/maps/documentation/javascript/react-map#add-map
Using the given code block (see below), will lead to
Cannot find namespace 'google'. and Property 'google' does not exist on type 'Window & typeof globalThis'. The imports linked in this repository does also not solve the problem.
const ref = React.useRef<HTMLDivElement>(null);
const [map, setMap] = React.useState<google.maps.Map>();
React.useEffect(() => {
if (ref.current && !map) {
setMap(new window.google.maps.Map(ref.current, {}));
}
}, [ref, map]);
Steps to reproduce
Follow the steps on https://developers.google.com/maps/documentation/javascript/react-map#typescript
Console log output
Uncaught TypeError: window.google is undefined
Source code as suggested by the guide
import React from 'react';
import { Wrapper, Status } from '@googlemaps/react-wrapper';
export const Map: React.FC<{}> = () => {
const ref = React.useRef<HTMLDivElement>(null);
const [map, setMap] = React.useState<google.maps.Map>();
React.useEffect(() => {
if (ref.current && !map) {
setMap(new window.google.maps.Map(ref.current, {}));
}
}, [ref, map]);
return <div ref={ref} />;
};
export const MyMap: React.FC = () => {
return (
<>
<Map />
</>
);
};
- 主要语言
- TypeScript
- 星标
- 804
- 派生
- 826
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
googlemaps/js-samples 的其他 Issue
-
Advanced Markers Animation Unused Variable可能已有人在做 @treckstar 于 832 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 68/100
googlemaps/js-samples#1794 ·
-
Driver未关闭
难度 5/5 一周以上 新手友好度 5/100
googlemaps/js-samples#1940 ·
-
难度 2/5 1-3 小时 新手友好度 35/100
googlemaps/js-samples#1932 ·
-
难度 4/5 3-5 天 新手友好度 32/100
googlemaps/js-samples#1914 ·
-
难度 4/5 3-5 天 新手友好度 25/100
googlemaps/js-samples#1827 · 1 条评论 ·
查看 googlemaps/js-samples 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
home-assistant/frontend#55841 ·
维护者通常 1 天内回复
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
难度 1/5 1 小时以内 新手友好度 76/100
lingdojo/kana-dojo#33905 · 1 条评论 · 5 个 reaction ·
维护者通常 1 天内回复
-
bug(semester-planning): the edit application dialog cannot save with an empty «Annet fra bedriften»未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
blocklist removal
难度 2/5 1-3 小时 新手友好度 66/100
MetaMask/eth-phishing-detect#311215 ·
维护者通常 1 天内回复
-
Explore filter: multi-select value list with allowNewOptions stops accepting values and drops earlier ones可能已有人在做 @isaac-jaynes-imperva 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
apache/superset#46146 · 1 条评论 ·
维护者通常 2 天内回复