Skip to content

Draw polygon programatically #997

Discussion options

You must be logged in to vote

This has nothing to do with Geoman. But I will give you some help:

var data = [{"Latitude":31.74627025070747,"Longitude":34.977035522460945},{"Latitude":31.804059692799363,"Longitude":34.97497558593751},{"Latitude":31.828565514766165,"Longitude":35.130844116210945},{"Latitude":31.705387248277066,"Longitude":35.13496398925782}];

var poly = undefined;

// loop through the data
data.forEach((d)=>{
   if(!poly){
     poly = L.polygon([L.latLng(d.Latitude, d.Longitude)]).addTo(map); // create polygon
   } else{
     poly.addLatLng(L.latLng(d.Latitude, d.Longitude)); // add latlngs to the polygon
   }
});

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Asafyesh1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants