【发布时间】:2014-11-10 01:46:11
【问题描述】:
我正在尝试在 Leaflet 地图上放置一个 geojson 并且一切正常,直到我使用默认的蓝光标记。
现在我想使用一个自定义标记(一个小 .png 图标),并且我在下面更改了我的代码
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]);
出了点问题,但我不知道如何解决。
任何建议将不胜感激
切萨雷
【问题讨论】:
标签: leaflet