I have a Geojson Linestring file that I would like to style. I load it with L.mapbox.featureLayer() but I guess there is no styling option. I try to load it with L.geoJson but does not find the way to do it through url:
var myStyle = {
"color": "#ff7800",
"weight": 5,
"opacity": 0.65
};
L.geoJson(myGeojson, {
style: myStyle
}).addTo(map);
What should I add to load the Geojson from url?
I have a Geojson Linestring file that I would like to style. I load it with L.mapbox.featureLayer() but I guess there is no styling option. I try to load it with L.geoJson but does not find the way to do it through url:
var myStyle = {
"color": "#ff7800",
"weight": 5,
"opacity": 0.65
};
L.geoJson(myGeojson, {
style: myStyle
}).addTo(map);
What should I add to load the Geojson from url?
Share Improve this question edited Mar 19, 2014 at 18:22 Inclanfunk asked Mar 12, 2014 at 15:45 InclanfunkInclanfunk 1471 gold badge1 silver badge6 bronze badges1 Answer
Reset to default 7L.geoJSON
takes an object, not a URL. You can use jQuery's getJSON
to load the data, then call L.geoJSON
when it's ready:
$.getJSON("orders.json", function(data) {
L.geoJson(data, {
style: myStyle
}).addTo(map);
}
See http://api.jquery./jquery.getjson/ for more details.