【发布时间】:2021-07-07 05:49:27
【问题描述】:
我正在使用 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);
【问题讨论】:
标签: angular typescript leaflet leaflet-routing-machine