我想在google地图标记的infowindow上做按钮点击事件信息窗口。以下是我的代码,但click事件不会调用函数
function createmarker(map, marker) {
var request = $http({
method: "post",
url: "example.com",
data: {
email: localStorage.getItem("email_id")
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});
request.success(function(response) {
for (i = 0; i < response.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(response[i].curlat, response[i].curlng),
map: map,
animation: google.maps.Animation.DROP
});
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
var infowindow = new google.maps.InfoWindow({
content: "<input type='button' value='View' onclick='joinFunction()'>" + "<input type='button' value='Join' onclick='alert(\"infoWindow\")'>"
});
// infowindow.setContent( '<button onclick="viewFunction()">View</button>');
infowindow.open(map, marker);
}
})(marker, i));
} //for loop close
}); //http close
}; //create marker close
function joinFunction() {
}
答案 0 :(得分:1)
您可以使用:
进行设置 infowindow.setContent('<input type="button" value="View" onclick="joinFunction()"><input type="button" value="Join" onclick="alert(\"infoWindow\")">');
它会起作用