如何使用JavaScript API在这里映射中做标记标记?



我正在尝试在这里的地图中创建标记标记,有些像谷歌地图,但我没有找到方法。 类似于代码波纹管的东西。

marker.setLabel('label')

我在文档中没有找到一个简单的方法来做到这一点。我用DomMarker解决了这个问题。解决方案如下。

function createMarker(point, ico, label = ''){
var html = document.createElement('div'), 
divIcon = document.createElement('div'), 
divText = document.createElement('div'),
imgIco = document.createElement('img');
imgIco.setAttribute('src', ico);
divIcon.appendChild(imgIco);
divText.innerHTML = label;
html.appendChild(divIcon);
html.appendChild(divText);
var domIcon = new H.map.DomIcon(html);
var marker = new H.map.DomMarker(point, {
icon: domIcon
});
return marker;
}

最新更新