我有一个在Angular 2+应用中利用谷歌地图的组件。是否有一种不错的方法可以获得一个链接到标记的infowindow,它会在我的组件中触发一个方法?下面的 istringstream strm(raw_text);
Point p;
while( strm >> p )
是问题所在。如果我想搞制一个全局方法(希望避免这种情况),我可以交换到INSERT IGNORE INTO mytable VALUES(:date,:data1,:data2,:data3,:data4,:data5)
。
(click)
答案 0 :(得分:1)
找到了几件可以让这项工作没有疯狂的角度开销。关键是:
domready
)时,将点击监听器添加到已点击的锚点ID中以下代码:
//Add directions if we have a current location
let additionalContent = "";
if (this.positionMarker) {
additionalContent = `<br><a href='#' id='marker_${markerId}'>Directions</a>`;
}
//Add the marker listener to open the infowindow
google.maps.event.addListener(marker, 'click', () => {
this.infoWindow.setContent(content + additionalContent);
this.infoWindow.open(this.map, marker);
//Once infow window is open, add a click listener based on the ID in the anchor tag
if (additionalContent) {
google.maps.event.addListenerOnce(this.infoWindow, 'domready', () => {
document.getElementById(`marker_${markerId}`).addEventListener('click', () => {
this.startNavigating(marker.position.lat(), marker.position.lng());
});
});
}
});