Created
May 12, 2020 15:56
Create GeoJson from Firestore Database in Google Firebase
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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