I would like to load a geoJSON (polygon) file into my leaflet map. I have seen examples where geoJSON is embedded into the javascript code but I can't find any examples showing how it is done with an external file.
html, body, #map { height: 100%; } body { padding: 0; margin: 0; }
var map = L.map('map').setView([38.57, -94.71], 4);L.tileLayer('http://{s}.tile.cloudmade.com/9067860284bc491e92d2342cc51d47d9/998/256/{z}/{x}/{y}.png', {attribution: 'Map data © OpenStreetMap Imagery © CloudMade'}).addTo(map);var featureStyle = { "color": "#ff7800", "weight": 5, "opacity": 0.2};L.geoJson(usStates).addTo(map);
`
أكثر...
html, body, #map { height: 100%; } body { padding: 0; margin: 0; }
var map = L.map('map').setView([38.57, -94.71], 4);L.tileLayer('http://{s}.tile.cloudmade.com/9067860284bc491e92d2342cc51d47d9/998/256/{z}/{x}/{y}.png', {attribution: 'Map data © OpenStreetMap Imagery © CloudMade'}).addTo(map);var featureStyle = { "color": "#ff7800", "weight": 5, "opacity": 0.2};L.geoJson(usStates).addTo(map);
`
أكثر...