Skip to content

Instantly share code, notes, and snippets.

@areindl
Created May 12, 2020 15:56
Show Gist options
  • Save areindl/a55e2b2b59b37febe4913f156bb4b3ba to your computer and use it in GitHub Desktop.
Save areindl/a55e2b2b59b37febe4913f156bb4b3ba to your computer and use it in GitHub Desktop.
Create GeoJson from Firestore Database in Google Firebase
// Install geojson from npm --> npm I -S geojson
import GeoJSON from 'geojson'
// Import your initalized Firebase/Firestore
// I have bundled it into a module
import { db } from '@/services/firebase'
// Query
db.collection('your_firestore_collection_id')
.get()
.then(querySnapshot => {
const myGeoJson = GeoJSON.parse(querySnapshot.docs.map(doc => doc.data()), { Point: ['lng', 'lat'] })
// no do anything with that JSON
console.log('print: ', myGeoJson)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment