2014-02-05 46 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); 
相關問題