Get started with geojson CDN

MIT licensed

GeoJSON is a library for working with geospatial data in the JSON format.

Tags:
  • geojson
  • geojson.js

Stable version

Copied!

How to start using geojson CDN


// Include GeoJSON library from CDN
const GeoJSON = require('https://cdn.cdnhub.io/geojson/0.5.0/geojson.min.js');

// Define a GeoJSON Point feature
const pointFeature = {
  type: 'Feature',
  geometry: {
    type: 'Point',
    coordinates: [-122.4194, 37.7749] // San Francisco coordinates
  },
  properties: {
    name: 'San Francisco'
  }
};

// Define a GeoJSON Feature Collection
const featureCollection = {
  type: 'FeatureCollection',
  features: [pointFeature]
};

// Convert the feature collection to a string
const geojsonString = JSON.stringify(featureCollection);

// Create a new GeoJSON object from the string
const geojson = new GeoJSON.parser().parse(geojsonString);

// Log the feature collection to the console
console.log(geojson);
Copied!
Copied!

All versions