Skip to content

Instantly share code, notes, and snippets.

@piggynl
Last active September 26, 2022 06:20
Show Gist options
  • Save piggynl/013895ebf16a315b25918f90130d355f to your computer and use it in GitHub Desktop.
Save piggynl/013895ebf16a315b25918f90130d355f to your computer and use it in GitHub Desktop.
Convert polygons to polylines in exported drawn Items from Draw Tools in IITC.
var drawnItems = [{"type":"polygon","latLngs":[{"lat":0,"lng":0},{"lat":0,"lng":60},{"lat":30,"lng":30}],"color":"#a24ac3"}];
drawnItems = drawnItems.map(o => o.type !== "polygon" ? o : { ...o, type: "polyline", latLngs: [...o.latLngs, o.latLngs[0]] });
copy(JSON.stringify(drawnItems));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment