如何从angularfire2创建地质点?
我正在尝试使用如何从angularfire2创建地质点?,angular,firebase,angularfire,google-cloud-firestore,Angular,Firebase,Angularfire,Google Cloud Firestore,我正在尝试使用AngularFirestore创建新的GeoPoint,但我不断收到一个错误,指出该方法不可用。除了AngularFire之外,我如何在不导入整个firebasenpm模块的情况下执行此操作 import { Component, OnInit } from "@angular/core"; import {AngularFirestore, AngularFirestoreCollection} from "angularfire2/firestore";
AngularFirestore
创建新的GeoPoint
,但我不断收到一个错误,指出该方法不可用。除了AngularFire
之外,我如何在不导入整个firebase
npm模块的情况下执行此操作
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);
}
}
从“@angular/core”导入{Component,OnInit};
从“angularfire2/firestore”导入{AngularFirestore,AngularFirestoreCollection};
@组成部分({
选择器:“应用程序firebase菜单栏”,
templateUrl:“./firebase菜单栏.component.html”,
样式URL:[“/”firebase菜单栏.component.css“]
})
导出类FirebaseMenuBarComponent{
私人物品收集:AngularFirestoreCollection;
私人收藏;
私人征集;
私人产品收藏;
构造函数(专用数据库:AngularFirestore){
//this.production=db.collection('/production').snapshotChanges();
这个.db.firestore.GeoPoint(40100);
}
}
您必须使用本机firebase/firestore模块,而不是angularfire模块。
您不应该害怕导入firebase(按照AngularFire存储库中的建议,通过“firebase/app”导入),因为AngularFire只是它的包装
以下是创建地质点的Firestore API参考:
进口:
import {AngularFirestore} from 'angularfire2/firestore'
import * as firebase from 'firebase/app'
创建和保存地质点:
const locationData = new firebase.firestore.GeoPoint(40, 100)
this.db.collection('foo').doc('whateverId').udpate({location: locationData})
从第5版开始
import { firestore } from 'firebase/firestore';
...
new firestore.GeoPoint ...
从