Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用JavaScript API在此处创建标记映射?_Javascript_Here Api - Fatal编程技术网

如何使用JavaScript API在此处创建标记映射?

如何使用JavaScript API在此处创建标记映射?,javascript,here-api,Javascript,Here Api,我试图在这里的地图中创建标记,有些像谷歌地图,但我没有找到如何创建标记。 类似于代码吼叫 marker.setLabel('label')我在文档中没有找到一种简单的方法来实现这一点。我用DomMarker解决了这个问题。解决方案如下 function createMarker(point, ico, label = ''){ var html = document.createElement('div'), divIcon = document.createElement(

我试图在这里的地图中创建标记,有些像谷歌地图,但我没有找到如何创建标记。 类似于代码吼叫


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;
}