Skip to content

New module: geo.js

Choose a tag to compare

@github-actions github-actions released this 10 Nov 22:31
· 74 commits to main since this release

geo.js (new) - read GeoJSON from a URL or a local file.

  • getGeoJSON(url, responseFunction, tokenkey?, tokenvalue?) follows getJSON's { status, data } callback, but sends no headers unless a token is given, so static hosts like raw.githubusercontent.com work without a CORS preflight. GitHub file-page links are rewritten to their raw URL.
  • readGeoJSONFile(id, responseFunction) reads an <input type="file">; parseGeoJSON(input) validates a string or object.
  • Any input - FeatureCollection, Feature, bare geometry or an array - comes out as a FeatureCollection whose features always have properties. Invalid features are skipped and logged instead of failing the whole file.
  • getBBox, getCenter, getPropertyKeys, getCoordinates and toLatLng for summarising data and feeding a map or table.