首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError:无法读取属性'offsetWidth‘的null

TypeError:无法读取属性'offsetWidth‘的null
EN

Stack Overflow用户
提问于 2016-03-14 18:22:48
回答 1查看 235关注 0票数 0

这是我为gmaps创建的函数

代码语言:javascript
复制
function createMap (qc,mess,ele){
        var myLatLng = qc;

          // Create a map object and specify the DOM element for display.
          var map = new google.maps.Map(document.getElementById(ele), {
            center: myLatLng,
            scrollwheel: false,
            zoom: 4
          });

          // Create a marker and set its position.
          var marker = new google.maps.Marker({
            map: map,
            position: myLatLng,
            title: mess
          });
    }

以下是我的PHP从我的数据库中生成的内容

代码语言:javascript
复制
<div id="1_map"></div>
 <script>
 var qc_1 = {lat:44.6309454, lng:-123.0913114}; 
createMap(qc_1,"text Message", "#1_map");
</script>

加载顺序是Google调用,javascript文件与createMap,然后PHP生成的文本。

Uncaught :无法读取属性'offsetWidth‘的null

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-14 18:32:42

document.getElementById(ele)不需要哈希符号,我不认为。

试一试

createMap(qc_1,"text Message", "1_map");

createMap(qc_1,"text Message", "#1_map");

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35995150

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档