【发布时间】:2017-03-31 13:35:52
【问题描述】:
它是said in documentation, that I can set content to node, not only to string,在 InfoWindow 中。
不幸的是,当我尝试设置节点时,它不起作用:
var point;
point = new google.maps.LatLng(43.65654, -79.90138);
// html = 'hello world';
html = $('<div>hello world</div>');
var marker = new google.maps.Marker({
position: point,
map: map
});
google.maps.event.addListener(marker, 'click', function () {
infowindow.setContent(html);
infowindow.open(map, marker);
});
Jsfiddle 在这里:https://jsfiddle.net/pmek2zhs/3/
单击标记,您将看不到任何内容。如果您将 html 变量赋值更改为已注释的变量赋值,它将起作用。
【问题讨论】:
标签: javascript jquery google-maps infowindow