1
votes

Is there any way to load a GeoJson file with "simplestyle" (for example, created with geojsonio) directly into Leaflet, so it could use the color, stroke and other properties? It seems that it is supported in the mapbox, but what about leaflet itself?

Thanks,

Alex

1

1 Answers

1
votes

This isn't supported out-of-the-box by Leaflet but you could write your own logic using the pointToLayer function of L.GeoJSON:

Function that will be used for creating layers for GeoJSON points (if not specified, simple markers will be created)

http://leafletjs.com/reference.html#geojson-pointtolayer

new L.GeoJSON(collection, {
    pointToLayer: function (feature, latlng) {
        // Return a custom marker
    }
});

In that function you have access to each feature's properties so you can return a custom marker based on them. Hope that helps, also found the following gist on github which shows a implementation which might do what you are looking for:

https://gist.github.com/tmcw/3861338