Created
May 12, 2020 15:56
-
-
Save areindl/a55e2b2b59b37febe4913f156bb4b3ba to your computer and use it in GitHub Desktop.
Create GeoJson from Firestore Database in Google Firebase
This file contains 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