2

如何更改带有集群的 tomtom map API 的标记图标?以下是我的代码。我是这个 API 的新手。并且还帮我更改集群图标

var addressPoints = [
    [40.191891, -85.401695, '<b style="color:red;">Townsville</b>'],
    [33.830517, -116.545601, '<b style="color:red;">Townsville</b>'],
    [34.496212, -93.057220, '<b style="color:red;">Townsville</b>'],
    [34.521530, -93.042267, '<b style="color:red;">Townsville</b>'],
    [37.541290, -77.434769, '<b style="color:red;">Townsville</b>'],
    [32.698437, -114.650398, '<b style="color:red;">Townsville</b>'],
    [37.063969, -111.236816, '<b style="color:red;">Townsville</b>'],
    [33.580944, -112.237068, '<b style="color:red;">Townsville</b>']
];

// Creating the map
var map = tomtom.map('map', {
    key: 'AVjNSUnrzh6XFxaTHO79YVHFw0H0KfyA',
    basePath: 'sdk'
}).setView([40.191891, -85.401695], 5);

//
var markerOptions = {
    icon: tomtom.L.icon({
        iconUrl: 'https://eyeonjewels.com/includes/images/retailer-large-icon.png',
        iconSize: [50, 64],
    })
};

// Placing markers
var markers = tomtom.L.markerClusterGroup();
addressPoints.forEach(function (point) {
    var title = point[2];
    marker = tomtom.L.marker(new tomtom.L.LatLng(point[0], point[1]), { title: title });
    marker.bindPopup(title);
    markers.addLayer(marker);
});
map.addLayer(markers);

请帮我更改标记图标。

4

1 回答 1

2

尝试在设置标记时添加它,如下所示 -

marker = tomtom.L.marker(new tomtom.L.LatLng(point[0], point[1]), { title: title, icon: markerOptions.icon });

在此处阅读有关它的更多信息

于 2019-02-05T10:57:02.177 回答