Hi!
I have an external GeoJSON file with a couple of polygon features. You can see it here
http://bl.ocks.org/d/41b25d26989d211bd86744dd4ffb82f2I'm sorry if this has been asked before but I didn't find a good answer.
I want to add one polygon feature from that GeoJSON to my leaflet map, not all the features. How would I go about doing that?.
As of now this is how my script looks like. Not that much at the moment since I don't really know where to start. So any pointers in a direction would be appreciated.
<script>
var map = L.map('map').setView([43.64701, -79.39425], 15);
//Load Geojson from external, local file
$.getJSON("polygons.geojson",function(data){
// add GeoJSON layer to the map once the file is loaded
geojsonLayer = L.geoJson(data).addTo(map);
map.fitBounds(geojsonLayer.getBounds());
});
</script>
The end goal is to add one polygon at a time. Then extract coordinates from that polygon and then calling an API with those coordinates to get a image from that area. Then simply add that as a layer to leaflet.
I know how to do it all, except for the load only one polygon at a time from the GeoJSON.
//Michael