在infowindow.setContent我有按钮时,我想在单击时更改标记颜色按钮,我尝试了此代码 google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(locations[i][0] + locations[i][3] + " <button class='btn btn-primary btn-sm map-checked-box mr-1' onclick='myFunction();' data-id='"+ locations[i][3] +"'>Print</button> "); infowindow.open(map, marker); } })(marker, i )); } function myFunction() { infowindow.setContent('<div style="background-color: green">' + locations[i][0] + locations[i][3] + "</div>");} 我正在调用 myfunction() 但它在这一行中不起作用我想我在函数中定位错误infowindow.setContent(locations[i][0] + locations[i][3] + " <button class='btn btn-primary btn-sm map-checked-box mr-1' onclick='myFunction();' data-id='"+ locations[i][3] +"'>Print</button> ");
添加回答
举报
0/150
提交
取消