2017-11-27 4 views
0

AngularFirestoreを使用して新しいGeoPointを作成しようとしていますが、その方法が利用できないというエラーが表示され続けます。 AngularFireに加えて、firebase npmモジュール全体をインポートせずにどうすればいいですか?AngleFire2からGeoPointを作成する方法は?

import { Component, OnInit } from "@angular/core"; 
    import {AngularFirestore, AngularFirestoreCollection} from "angularfire2/firestore"; 
    @Component({ 
     selector: "app-firebase-menu-bar", 
     templateUrl: "./firebase-menu-bar.component.html", 
     styleUrls: ["./firebase-menu-bar.component.css"] 
    }) 
    export class FirebaseMenuBarComponent { 
     private itemsCollection: AngularFirestoreCollection<any>; 
     private AngularFirestoreCollection; 
     private draftCollection; 
     private productionCollection; 
     constructor(private db: AngularFirestore) { 
     // this.production = db.collection('/production').snapshotChanges(); 
     this.db.firestore.GeoPoint(40, 100); 
     } 
    } 

答えて

1

角度燃焼モジュールではなく、ネイティブのfirebase/firestoreモジュールを使用する必要があります。 AngerFireリポジトリで推奨されているように、firebaseを(firebase/app経由で)インポートすることを恐れてはいけません。なぜなら、angelfireは単に周囲のラッパーであるからです。ここで

はGeopointを作成するためのFirestore APIリファレンスです:https://firebase.google.com/docs/reference/js/firebase.firestore.GeoPoint

輸入:

import {AngularFirestore} from 'angularfire2/firestore' 
import * as firebase from 'firebase/app' 

Geopointの作成と保存:

const locationData = new firebase.firestore.GeoPoint(40, 100) 
this.db.collection('foo').doc('whateverId').udpate({location: locationData}) 
関連する問題