demarches-normaliennes/app/javascript/shared/create-feature-collection.js

20 lines
410 B
JavaScript
Raw Normal View History

export default function createFeatureCollection(latLngs) {
return {
2018-10-13 10:55:40 +02:00
type: 'FeatureCollection',
features: latLngs.map(featurePolygonLatLngs)
};
2018-10-13 10:55:40 +02:00
}
function featurePolygonLatLngs(latLngs) {
return {
type: 'Feature',
properties: {
source: 'selection_utilisateur'
},
2018-10-13 10:55:40 +02:00
geometry: {
type: 'Polygon',
coordinates: [latLngs.map(({ lng, lat }) => [lng, lat])]
}
};
}