这是我为gmaps创建的函数
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从我的数据库中生成的内容
<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
发布于 2016-03-14 18:32:42
document.getElementById(ele)不需要哈希符号,我不认为。
试一试
createMap(qc_1,"text Message", "1_map");
不
createMap(qc_1,"text Message", "#1_map");
https://stackoverflow.com/questions/35995150
复制相似问题