更改标记图标

时间:2019-02-05 10:28:41

标签: javascript api tomtom map-api

如何更改具有群集的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);

请帮助我更改标记图标。

1 个答案:

答案 0 :(得分:2)

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

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

详细了解它 here