Skip to content

Instantly share code, notes, and snippets.

@jarodium
Created December 5, 2022 22:27
Show Gist options
  • Save jarodium/e9f42def7fdedd6d5ab42d0b56851349 to your computer and use it in GitHub Desktop.
Save jarodium/e9f42def7fdedd6d5ab42d0b56851349 to your computer and use it in GitHub Desktop.
turf-sandbox snippet
// simply return a valid GeoJSON and it will be rendered on the map
const polyRecursos = turf.polygon([[
[-7.9433882,37.0254615],[-7.9435303,37.0252195],[-7.9434177,37.0251639],[-7.9432889,37.0251296],[-7.9430636,37.0251125],[-7.9431414,37.0253202],[-7.9433882,37.0254615]
]],
{stroke: '#0FF', fill: '#0FF', 'fill-opacity': 0.3, 'stroke-width': 6}
);
const poly = turf.polygon([[
[-7.9434775157632815,37.024837920790766],
[-7.943964787435284,37.02506342920393],
[-7.943758275262718,37.025227729409856],
[-7.9434775157632815,37.024837920790766],
]],
{stroke: '#0FF', fill: '#F00', 'fill-opacity': 0.3, 'stroke-width': 1}
);
const poly2 = turf.polygon([[
[-7.9434775157632815,37.024837920790766],
[-7.943758275262718,37.025227729409856],
[-7.943476532754342,37.02528758028777],
[-7.9431950536466776,37.02522694460116],
[-7.9434775157632815,37.024837920790766],
]],
{stroke: '#0FF', fill: '#0F0', 'fill-opacity': 0.3, 'stroke-width': 1}
);
const poly3 = turf.polygon([[
[-7.9434775157632815,37.024837920790766],
[-7.9431950536466776,37.02522694460116],
[-7.942989261093976,37.02506206987835],
[-7.9434775157632815,37.024837920790766],
]],
{stroke: '#0FF', fill: '#00F', 'fill-opacity': 0.3, 'stroke-width': 1}
);
const polyA = turf.polygon([[
[-7.943865454856418,37.025100822795046],
[-7.944011228149995,37.025535161088605],
[-7.943719681562841,37.025535161088605],
[-7.943865454856418,37.025100822795046],
]],
{stroke: '#0FF', fill: '#F00', 'fill-opacity': 0.3, 'stroke-width': 2}
);
const poly2A = turf.polygon([[
[-7.943865454856418,37.025100822795046],
[-7.943719681562841,37.025535161088605],
[-7.9434671954221345,37.02541877989344],
[-7.9433214237955205,37.02521720217224],
[-7.943865454856418,37.025100822795046],
]],
{stroke: '#0FF', fill: '#0F0', 'fill-opacity': 0.3, 'stroke-width': 2}
);
const poly3A = turf.polygon([[
[-7.943865454856418,37.025100822795046],
[-7.9433214237955205,37.02521720217224],
[-7.943321425462467,37.02498444093447],
[-7.943865454856418,37.025100822795046],
]],
{stroke: '#0FF', fill: '#00F', 'fill-opacity': 0.3, 'stroke-width': 2}
);
return turf.featureCollection([poly, poly2, poly3,polyA, poly2A, poly3A]);
//return turf.featureCollection([poly, poly2, poly3, polyRecursos]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment