Closed stot3 closed 5 years ago
Can I see a full code sample por favor?
import { AngularFirestore } from 'angularfire2/firestore';
import { AngularFireStorage } from 'angularfire2/storage';
import { GeoFirestore } from 'geofirestore';
import { firestore } from 'firebase/app';
geoRetailerScripts(){
const arr: Promise<any>[] = []
const geoFire: any = new GeoFirestore(this.afs.firestore)
this.afs.collection("RetailersCoordinates").snapshotChanges().pipe(
take(1),
map(
val => val.map( (data :any) => {
const location = {
latitude : data.payload.doc.data().latitude != undefined ? data.payload.doc.data().latitude : null,
longitiude: data.payload.doc.data().longitiude != undefined ? data.payload.doc.data().longitiude : null,
}
return { ...data.payload.doc.data(), ...location}
})
),
tap( val => val.forEach(
(data) => {
//this.afs.collection("RetailersCoords").doc(data.id).set({position: point})
if(data.latitude != undefined)
{
arr.push(geoFire.collection("RetailersCoords").add({coordinates: new firestore.GeoPoint(data.latitude, data.longitiude), ...data}))
}
}
))
).subscribe( val =>
{
Promise.all(arr).catch( err => console.error(err))
}
)
}
this.afs.firestore is firebase.firestore()
This is working in 3.1.0, but 3.2 >= it will not.
Can i see you import statements as well?
Can i see you import statements as well?
I gotcha, I updated it.
This is peculiar and difficult for me to debug like this... Is there a repo that you have that has this issue, or some small example you can create so I can see what's going on? (it looks like what you're doing is correct)
Later on tonight, I will make a StackBlitz for you, or if I can get off a little early, I will do that for you.
That would be awesome, thank you.
So for the life of me I can not get your blitz to work. But I'm not even talking about geofirestore, if i just call firebase.firestore()
it throws an error saying:
ERROR TypeError: firebase.firestore is not a function
(Here is what I updated your loadGeofire()
method to)
loadGeoFire() {
firebase.firestore();
}
I'll try to make a simple stackblitz with it working so you can use that as a reference, but this is still SUPER weird.
Cool, figured it out. This isn't a geofirestore issue, this is a firebase issue. From what I can tell from issues opened on the firebase-js-sdk repo this started with firebase 5.11.x.
Bump your firebase to version 6.x.x and you should be all set. (Let me know if that works and I'll close the issue)
Hey I really appreciate it I bumped the version I stackblitz and it worked a-okay, the problem is angularfire, the library that angular uses for firebase is not up to snuff with 6.X. I appreciate the time you put in to help me with this. I’m going to figure out what I can do to help with the angularfire team.
On May 15, 2019, at 11:52 AM, Michael Solati notifications@github.com wrote:
Cool, figured it out. This isn't a geofirestore issue, this is a firebase issue. From what I can tell from issues https://github.com/firebase/firebase-js-sdk/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+not+a+function opened on the firebase-js-sdk repo this started with firebase 5.11.x.
Bump your firebase to version 6.x.x and you should be all set. (Let me know if that works and I'll close the issue)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/geofirestore/geofirestore-js/issues/105?email_source=notifications&email_token=ACBPZGLFHUKGCRMFSAGK4F3PVQWSHA5CNFSM4HM3JY22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVPDJ7Y#issuecomment-492713215, or mute the thread https://github.com/notifications/unsubscribe-auth/ACBPZGNWXPSAB7TDPTCIRMDPVQWSHANCNFSM4HM3JY2Q.
There's an issue opened with @angular/fire and I added my comments to it. Even if 6.x.x is not a dependency that doesn't mean it won't work. Here's a simple stackblitz using @angular/fire, firebase 6.0.2 and my creating a geofirestore instance with no issues....
After upgrading firebase, shifting from angularfire to @angular/fire and geofirestore, I finally got everything to work. I figured out also what led me down this rabbit hole. Although this is building and working in VS there are still red lines in the GeoFirestore instantiation, it made me think there was a problem and there wasn't.
It seems like whatever VS is referencing, it seems like old documentation or something, I'm not sure what VS uses, but when you hover over the GeoFirestore reference, it references old docs.
Also, here is my package.json
{ "name": "sales-portal", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build --prod", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@agm/core": "^1.0.0-beta.5", "@agm/js-marker-clusterer": "^1.0.0-beta.5", "@agm/snazzy-info-window": "^1.0.0-beta.3", "@angular-devkit/core": "7.3.1", "@angular/animations": "^7.2.4", "@angular/cdk": "^7.3.2", "@angular/cli": "7.3.1", "@angular/common": "^7.2.4", "@angular/compiler": "^7.2.4", "@angular/compiler-cli": "^7.2.4", "@angular/core": "^7.2.4", "@angular/fire": "^5.1.3", "@angular/forms": "^7.2.4", "@angular/http": "^7.2.4", "@angular/language-service": "^7.2.4", "@angular/material": "^7.3.2", "@angular/platform-browser": "^7.2.4", "@angular/platform-browser-dynamic": "^7.2.4", "@angular/router": "^7.2.4", "@ng-bootstrap/ng-bootstrap": "^4.0.3", "@types/googlemaps": "^3.30.16", "@types/papaparse": "^4.5.2", "@types/simplemde": "^1.11.7", "core-js": "^2.5.7", "firebase": "^6.0.2", "geofirestore": "^3.3.0", "googlemaps": "^1.12.0", "hammerjs": "^2.0.8", "js-marker-clusterer": "^1.0.0", "material-design-icons": "^3.0.1", "ngx-markdown": "^7.1.4", "papaparse": "^4.4.0", "plotly.js": "^1.40.0", "rxfire": "^3.0.1", "rxjs": "^6.4.0", "simplemde": "^1.11.2", "simplemde-antd": "^1.0.0", "snazzy-info-window": "^1.1.1", "tslib": "^1.9.0", "typescript": "^3.1.6", "zone.js": "^0.8.29" }, "devDependencies": { "@angular-devkit/build-angular": "~0.13.0", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "^10.7.1", "codelyzer": "^4.3.0", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.4.2", "karma-jasmine": "^1.1.2", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.2", "tslint": "~5.7.0" } }
Ok, this is an issue I CAN fix and will do today. I would say just // @ts-ignore
it for now. But I'll post back when I deployed a fix.
I'm very happy I can point something out to help this project better, I absolutely love this library, and would love to help in anyway possible. I'm sorry I sent you on a goose chase.
Geofirestore version 3.3.1 is going through CI and will be autodeployed to NPM. That should take care of any issues you have (I tested it with firbase 6 as well as the newest version of @angular/fire using firebase 6 in an angular 7 project).
There is a problem with new GeoFirestore(), first I am using geofire@3.3.0, I am in the middle of upgrading from an older previous version. I was instantiating geofirestore and it tells me that collection() is not a method, I was wondering what was I doing wrong so I passed in a string to the collection method with the collection Ref, which is in the visual studio documentation btw, that did not work. So I passed in the CollectionReference that I wanted, and the only thing that is valid with the newer GeoFirestore is passing in a firestore reference. I passed it in, but I am unable to reference a collection. Can someone fix this, or at least make the documentation clear, either direction? I am helplessly confused, so I am going to have to downgrade now.