0

我正在从谷歌文档上的共享 CSV 中提取标记数据。我可以在传单中将它们映射好。我想使用我自己的 PNG 标记。我还想按数据类别分配不同的标记(如果 'employees' 字段 = <10,则使用 employee10.png )

4

1 回答 1

0

文档页面上有一个带有自定义图标的标记示例:http: //leafletjs.com/examples/custom-icons.html

var greenIcon = L.icon({
    iconUrl: 'leaf-green.png',
    shadowUrl: 'leaf-shadow.png',

    iconSize:     [38, 95], // size of the icon
    shadowSize:   [50, 64], // size of the shadow
    iconAnchor:   [22, 94], // point of the icon which will correspond to marker's location
    shadowAnchor: [4, 62],  // the same for the shadow
    popupAnchor:  [-3, -76] // point from which the popup should open relative to the iconAnchor
});

定义所有图标,然后在创建标记时使用它们。例如,

var employeesLowIcon = L.icon({ ... });
var employeesHighIcon = L.icon({ ... });
var markerIcon = employees < 10 ? employeesLowIcon : employeesHighIcon;
L.marker([51.5, -0.09], {icon: markerIcon }).addTo(map);
于 2014-02-05T18:24:27.340 回答