javascript 谷歌地图 api v3 未捕获的类型错误:无法读取 null 的属性“offsetWidth”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11550500/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 13:38:06  来源:igfitidea点击:

google maps api v3 uncaught typeError: Cannot read property 'offsetWidth' of null

javascripthtmlgoogle-maps-api-3geolocation

提问by Ilan Biala

Im going through a HTML5 book that includes geolocation, which I've been able to figure out. However, the next step is to include a map using the google maps API. I've already gotten an API key and have structured everything just like the book and the google documentation said, but I can't seem to figure out this problem. On line 29 in the main.js file on http://ilanshomekitchen.x10.mx/projects/Geolocation/, there is an: "Uncaught TypeError: Cannot read property 'offsetWidth' of null. I've searched google and so far nothing has worked. I even defined the height and width of the map in the css file on the site.

我正在阅读一本包含地理定位的 HTML5 书籍,我已经能够弄清楚了。但是,下一步是使用谷歌地图 API 包含地图。我已经获得了一个 API 密钥,并且已经按照本书和谷歌文档所说的方式构建了所有内容,但我似乎无法弄清楚这个问题。在http://ilanshomekitchen.x10.mx/projects/Geolocation/上的 main.js 文件的第 29 行,有一个:“未捕获的类型错误:无法读取 null 的属性‘offsetWidth’。我已经搜索过谷歌,到目前为止没有任何效果。我什至在网站的 css 文件中定义了地图的高度和宽度。

Any ideas?

有任何想法吗?

回答by PoulsQ

i've been on your page and i saw this :

我一直在你的页面上,我看到了这个:

<div id="map>

Close the property like that :

像这样关闭属性:

<div id="map">

It could fix some problems :)

它可以解决一些问题:)