javascript - 这里 API Maps 设置标记

标签 javascript maps here-api

我正在使用 HERE API map 。如何为具有聚类和边界的 map 添加自定义图标?如果我有单个标记,我知道如何做到这一点。但是如果我有一组标记,如何添加图标? 我认为它应该在这里的某个地方......

// Set Map Bounds
function setMapBounds(map) {
  let svgMarkup = '<svg></svg>';
  let svgMarkup2 = '<svg width="24" height="24" ' +
  'xmlns="http://www.w3.org/2000/svg">' +
  '<rect stroke="white" fill="#1b468d" x="1" y="1" width="22" ' +
  'height="22" /><text x="12" y="18" font-size="12pt" ' +
  'font-family="Arial" font-weight="bold" text-anchor="middle" ' +
  'fill="white">H</text></svg>';
  let icon = new H.map.Icon(svgMarkup);
  let icon2 = new H.map.Icon(svgMarkup2);
  let mapBounds = [];
  let urlMapBounds = '/api/catalog/catalog/map/info';

  getDataAjax(urlMapBounds, toRequestJson).done((response) => {
    totalCount = response.count;
    numOfPages = Math.ceil(totalCount / PORTION);

    // Set Top-left and Bottom-right invisible bound markers 
    mapBounds.push(new H.map.Marker({lat: response.leftUp.lat, lng: response.leftUp.lng}, {icon: icon}));
    mapBounds.push(new H.map.Marker({lat: response.rightBottom.lat, lng: response.rightBottom.lng}, {icon: icon}));

    // Add bound markers to the group
    let group = new H.map.Group();
        group.addObjects(mapBounds);
        map.addObject(group);
  
    // Get geo bounding box for the group and set it to the map
    map.setViewBounds(group.getBounds());

    // Run function of getting data for clustering
    getDataForClustering(map)
  });
}

最佳答案

查看 developer 中的示例您可以在门户中将多个标记分组到如下所示的函数中。

var cubsIcon = new H.map.Icon(
    svgMarkup.replace('${FILL}', 'white').replace('${STROKE}', 'orange')),
    cubsMarker = new H.map.Marker({lat: 41.9483, lng: -87.6555 },
      {icon: cubsIcon});

  map.addObject(cubsMarker);

关于javascript - 这里 API Maps 设置标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60394623/

相关文章:

javascript - 如果按钮包含 "sometext"如何隐藏 <li> - jQuery

javascript - 使用 jquery 根据文本框的值隐藏或过滤 div

android - 这里自动完成 : WRITE_EXTERNAL_STORAGE permission

android - 将 Here-SDK 从 3.2 更新到 3.3 后出错

javascript - 更新隐藏噪声标记的簇权重

javascript - 如何从内联类中获得最大值(value)

javascript - 如何避免从 promise 中提取解析,同时在回调之前启动流程?

svg - 我如何使用 SVG translate 将 d3.js 投影居中到给定的纬度和经度值?

ios - 使用 Google Maps API for IOS 的区域边界坐标

swift - 如何在 Xcode 中向 Google Maps API 添加叠加层