我正在使用 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/