admin管理员组文章数量:1356954
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.
本文标签: javascriptHow to load LgeoJson from urlStack Overflow
版权声明:本文标题:javascript - How to load L.geoJson from url? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743979165a2571003.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论