我目前正在使用 HERE Maps Javascript SDK 开发 React 应用程序。
我的问题:
当我点击标记时,我想在标记上打开一个信息气泡。
取而代之的是
这个奇怪的工件被渲染,地图最终会卡普特:
这是相关的源代码:
const addEventsToMap = (events, H, hMap, ui) =>{
let markers = [];
events.map((el)=>{
var icon = new H.map.DomIcon(svgMarkup),
coords = {lat: el.Latitude, lng: el.Longitude},
marker = new H.map.DomMarker(coords, {icon: icon});
marker.setData("Hello world")
marker.addEventListener('tap', event=>{
const bubble = new H.ui.InfoBubble({lat:el.Latitude, lng:el.Longitude},
{
content: event.target.getData()
})
ui.addBubble(bubble);
}, false)
hMap.addObject(marker);
console.log(el);
})
}
React.useLayoutEffect(() => {
// `mapRef.current` will be `undefined` when this hook first runs; edge case that …Run Code Online (Sandbox Code Playgroud)