2014-02-05 48 views
0

我从Google文档的共享CSV中提取标记数据。我可以将它们映射到小册子中。我想使用我自己的PNG标记。我也想通过分配数据类别不同的​​标记(如“雇员”字段= < 10然后使用employee10.png)如何在小册子中使用自定义标记?

回答

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); 
相关问题