Skip to content

Instantly share code, notes, and snippets.

@maptastik
Created December 1, 2018 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maptastik/4eff9b6c93c26e56541b533031e06dfc to your computer and use it in GitHub Desktop.
Save maptastik/4eff9b6c93c26e56541b533031e06dfc to your computer and use it in GitHub Desktop.
Sometimes you just need the point coordinates for all the points in a GeoJSON. This function pulls them into an array.
function createArrayOfPointCoordinates(pointsJson) {
let pointsCoordinatesArray = [];
let pointsFeatures = pointsJson.features;
for (let i = 0; i < pointsFeatures.length; i++) {
let pointsFeature = pointsFeatures[i];
if (pointsFeature.geometry != null) {
let pointsFeaturesCoordinates = pointsFeature.geometry.coordinates;
pointsCoordinatesArray.push(pointsFeaturesCoordinates);
}
}
return pointsCoordinatesArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment