I noticed alot of people have had this question, however it is really hard to find the solution...
I have a geojson file describing points, polygons and lines. I want each point to have it's own marker icon, so in the feature properties I describe the icon url I want.
I am working with this example: http://leaflet.cloudmade.com/examples/geojson.html
and have modified lightRailStop to be
var lightRailStop = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"style": {
externalGraphic: "../../icons/transportation_plane.png",
graphicWith: 16,
graphicHeight: 26,
graphicYOffset: -26,
fillColor:'#669933',
fillOpacity:.8,
strokeColor:'red',
strokeWidth:6,
pointRadius:8
},
"icon": "../../icons/transportation_plane.png",
"popupContent": "This is my very special dynamic mrker I couldn't be more happy :D"
},
"geometry": {
"type": "Point",
"coordinates": [ 24.065321502681, 35.533841657399]
}
},{
"type": "Feature",
"properties": {
"popupContent": "20th & Welton Light Rail Stop"
},
"geometry": {
"type": "Point",
"coordinates": [-104.98689115047453, 39.747924136466565]
}
}
]};
and the leafletembed code to
lightRailGeojsonLayer.on("featureparse", function (e) {
var popupContent = "<p>I started out as a GeoJSON " + e.geometryType + ", but now I'm a Leaflet vector!</p>";
popupContent += "<p>This is the default look of a GeoJSON Point.</p>";
if (e.properties && e.properties.icon && e.geometryType == "Point" ){
e.layer.setIcon(L.Icon.extend(
{iconUrl: e.properties.icon}
));
}
if (e.properties && e.properties.popupContent) {
popupContent += e.properties.popupContent;
}
e.layer.bindPopup(popupContent);
});
I get the error ,
has no method 'createIcon'
What am I doing wrong? :S
I am using Leaflet 0.3.1 stable (February 14, 2012)
Posted the question on github as well, wasn't sure if anyone would see it though.. https://github.com/CloudMade/Leaflet/issues/311