我正在使用 Leaflet,但我的标记很少。因此,当将鼠标悬停在标记上时,会打开一个弹出窗口,在该弹出窗口中,有一个复选框。所以我需要的是,每当用户单击该复选框时,它应该更改弹出内容。例如,
复选框名称为更多信息。默认弹出窗口包含悬停后的纬度和经度。当用户单击该复选框时,弹出窗口应显示城市、州以及纬度和经度。我在复选框中创建了一个带有onchange
事件内部函数的复选框,但它没有调用创建的角度函数,而是在寻找 JavaScript 函数。我怎样才能调用 Angular 函数,或者是否有任何其他解决方法来实现它?
我用过以下方法,
<input type="checkbox" onchange="showDetails(this);"/>
<input type="checkbox" onchange={{showDetails(this);}}/>
我的示例代码看起来像这样
L.Routing.control({
waypoints: waypoints,
lineOptions: {
styles: [{color: '#453f30', opacity: 1, weight: 5}],
addWaypoints: false,
extendToWaypoints: false,
missingRouteTolerance: 0,
},
plan: L.Routing.plan(waypoints, {
createMarker: function (i, wp) {
return L.marker([latitude, longitude], {
icon: icon,
}).bindPopup('<input type="checkbox" onchange={{showDetails(this);}}/>More Info', {
closeButton: true,
}).on("mouseover", function (event) {
event.target.openPopup();
});
}
})
}).addTo(this.map);