我会尝试更精确。我正在尝试从自定义按钮打开一个附加到标记的“信息窗口”。虽然它通过直接单击标记来工作,但我无法将其分配给按钮。该页面当前如下所示:map_example
谁能检查下面的代码并告诉我我做错了什么?
function zagrebControl(controlDiv, map) {
controlDiv.style.paddingLeft = '0px';
controlDiv.style.paddingRight = '6px';
controlDiv.style.paddingTop = '0px';
controlDiv.style.paddingBottom = '6px';
controlDiv.style.marginBottom = '0px';
controlDiv.style.width = '80px';
var zagrebUI = document.createElement('DIV');
zagrebUI.style.backgroundColor = 'white';
zagrebUI.style.borderStyle = 'solid';
zagrebUI.style.borderWidth = '1px';
zagrebUI.style.cursor = 'pointer';
zagrebUI.style.textAlign = 'center';
zagrebUI.title = 'click to set the map to zagreb';
controlDiv.appendChild(zagrebUI);
var controlText = document.createElement('DIV');
controlText.style.fontFamily = 'Arial,sans-serif';
controlText.style.fontSize = '12px';
controlText.style.paddingLeft = '4px';
controlText.style.paddingRight = '4px';
controlText.style.paddingTop = '1px';
controlText.style.paddingBottom = '0px';
controlText.innerHTML = 'ZAGREB';
zagrebUI.appendChild(controlText);
google.maps.event.addDomListener(zagrebUI, 'click', function() {
map.setCenter(v1); map.setZoom(7)
});
google.maps.event.addListener(zagrebUI, 'click', function() {
infowindow.setContent('<object width="640" height="360">...</object>');
infowindow.open(map, m1)
});
我的标记代码如下所示:
google.maps.event.addListener(m1, 'click', function() {
infowindow.setContent('<object width="640" height="360">...</object>');
infowindow.open(map, m1);
});
谢谢你。