Closed mewajda closed 4 years ago
Interesting. Can you tell me which version of the Firebase SDK you're using as peer dependency?
I added a test case for the point.data
and tested with Firebase 4.2.1, but should work with >= 5.2.
Do you have any other output or errors you can share?
Here is a snippet of my package.json
"@agm/core": "1.0.0-beta.3",
"@angular/common": "6.1.4",
"@angular/core": "6.1.4",
"@angular/forms": "6.1.4",
"@angular/http": "6.1.4",
"@angular/platform-browser": "6.1.4",
"@angular/platform-browser-dynamic": "6.1.4",
"@angular/router": "6.1.4",
"@ionic-native/core": "5.0.0-beta.14",
"@ionic-native/splash-screen": "5.0.0-beta.14",
"@ionic-native/status-bar": "5.0.0-beta.14",
"@ionic/angular": "4.0.0-beta.3",
"angularfire2": "5.0.0-rc.12",
"core-js": "2.5.7",
"firebase": "5.4.1",
"geofirex": "0.0.6",
"rxjs": "6.2.2",
"zone.js": "0.8.26"
I have the same problem...
Having similar issue now after upgrading to Angular 6, previously working in Angular 5. When I call
const collection = georef.collection("incidents");
collection.setPoint(incident.uid, "location", point.latitude, point.longitude);
Here is the exception
index.esm.js:1386 Uncaught TypeError: this.app.firestore.GeoPoint is not a constructor
at GeoFirePoint.get [as geoPoint] (index.esm.js:1386)
at GeoFirePoint.get [as data] (index.esm.js:1407)
Here is my package.json
"@agm/core": "^1.0.0-beta.3",
"@agm/js-marker-clusterer": "^1.0.0-beta.3",
"@agm/snazzy-info-window": "^1.0.0-beta.3",
"@angular/animations": "6.1.8",
"@angular/cdk": "^6.4.7",
"@angular/common": "6.1.8",
"@angular/compiler": "6.1.8",
"@angular/core": "6.1.8",
"@angular/fire": "^5.0.2",
"@angular/forms": "6.1.8",
"@angular/http": "6.1.8",
"@angular/material": "^6.4.7",
"@angular/platform-browser": "6.1.8",
"@angular/platform-browser-dynamic": "6.1.8",
"@angular/router": "6.1.8",
"@fortawesome/fontawesome": "^1.1.8",
"@fortawesome/fontawesome-free-regular": "^5.0.13",
"@fortawesome/fontawesome-free-solid": "^5.0.13",
"@ng-bootstrap/ng-bootstrap": "^3.2.2",
"@types/googlemaps": "^3.30.11",
"@types/nodemailer": "^4.6.2",
"agm-direction": "^0.7.3",
"bootstrap": "^4.1.1",
"core-js": "^2.4.1",
"firebase": "^5.5.3",
"firebase-admin": "^6.0.0",
"firebase-functions": "^2.0.5",
"firebase-tools": "^4.2.1",
"geofirex": "0.0.6",
"guid-typescript": "^1.0.7",
"hammerjs": "^2.0.8",
"howler": "^2.0.13",
"js-marker-clusterer": "^1.0.0",
"nodemailer": "^4.6.8",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.2.2",
"snazzy-info-window": "^1.1.1",
"zone.js": "^0.8.26"
Also have the exact same issue using cloud functions it fails when saving data, example:
export const addLiveUpdate = functions.https.onCall(async (data, context): Promise<HttpReturn<any>> => {
const userUid = context.auth.uid
const username = data.username as string
// Optinal values.
const imageUrl = data.imageUrl ? data.imageUrl as string : ''
const updatedText = data.updatedText ? data.updatedText as string : ''
const user = await fetchUser(userUid)
const geoPoint = user.geoPoint as GeoPoint
const point = new GeoFirePoint(
// Failing here.
app,
geoPoint.latitude,
geoPoint.longitude
)
const liveUpdate: LiveUpdate = {
userUid,
username,
imageUrl,
updatedText,
createdTimeISO: new Date().toISOString(),
position: point.data,
}
await geofire.collection('liveUpdates').setDoc(userUid, liveUpdate)
//await firestore().collection('liveUpdates').doc(userUid).set(liveUpdate)
const httpReturn: HttpReturn<any> = {
statusCode: 200,
message: 'Live updated added.',
}
return httpReturn
});
Same problem in Angular ^7.2.2 and AngularFire ^5.2.1 Firebase ^6.3.1
console.log(this.geo.point(0,0).data)
Uncaught TypeError: this.app.firestore.GeoPoint is not a constructor
at GeoFirePoint.get [as geoPoint] (index.esm.js:1386)
at GeoFirePoint.get [as data] (index.esm.js:1407)
geoPoint.geoPoint
latitude, longitude and hash all work however.
this.app.firestore does not have a GeoPoint constructor method
Initialized this.geo as
this.geo = geofirex.init(this.db.firestore.app);
And this.db is an AngularFirestore passed through the constructor from AngularJS Magic.
private db: AngularFirestore,
As of 5 version of AngularFire
import { firestore } from 'firebase/firestore'; ... new firestore.GeoPoint ... From https://github.com/angular/angularfire2/issues/1604
Fixed by adding this to the GeoFirePoint constructor inside the GeoFireX index.esm.js
// Bug Fix for #13 Geopoint was moved from app onto app.firestore
if (typeof(app.firestore.GeoPoint) === 'undefined' && app.firebase_ && app.firebase_.firestore.GeoPoint) {
app.firestore.GeoPoint = app.firebase_.firestore.GeoPoint;
}
Although there is probably a more appropriate fix. Any advice?
this.app.firebase_.SDK_VERSION says "6.3.1" if that helps any.
I am following your video about Firestore Geoqueries and when I try to add a point to my collection I get the following error when trying to call 'point.data'. I am using ionic 4
Exception: TypeError: this.app.firestore.GeoPoint is not a constructor at GeoFirePoint.get [as geoPoint] (http://localhost:4200/home-home-module.js:1405:20) at GeoFirePoint.get [as data] (http://localhost:4200/home-home-module.js:1426:32) at GeoFirePoint.remoteFunction (:2:14)]
As a workaround I am doing
collection.add({ name: 'test', position: { geohash: p.hash, geopoint: new firebase.firestore.GeoPoint(p.latitude, p.longitude) } });