0
我試圖把一個傳單地圖geojson和所有工作正常,直到我使用默認藍光標記。Leaflet:如何在geojson圖層上使用自定義標記?
現在,我想使用一個自定義標記(有點巴紐圖標),我已經改變了我的代碼在遵循
var my_json;
$.getJSON('../Dati/my-geojson.geojson', function(data) {
my_json = L.geoJson(data, {
pointToLayer: function(feature, latlng) {
var smallIcon = L.Icon({
options: {
iconSize: [27, 27],
iconAnchor: [13, 27],
popupAnchor: [1, -24],
iconUrl: 'icone/chapel-2.png'
}
});
return L.marker(latlng, {icon: smallIcon});
},
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.ATT1 + '<br />'
+ feature.properties.ATT2);
}
});
my_json.addTo(markers.addTo(map));
TOC.addOverlay(my_json, "My layer name in TOC");
map.removeLayer(my_json);
});
,我可以在Firebug看到錯誤是
TypeError: this.options.icon is undefined
var anchor = L.point(this.options.icon.options.popupAnchor || [0, 0]);
事情出錯了,但我不知道如何解決它。
任何建議,可以理解
切薩雷