Closed davepartner closed 8 years ago
It is a bit hard to parse all this code in a GitHub issue. Can you please put together a JSFiddle or Plunkr with the failing code?
I have done it, here is the code: https://jsfiddle.net/daveozoalor/6mk10erg/1/
I just need to know how to write and retrieve the geofire query correctly. The rest is easy.
Unfortunately your JSFiddle doesn't actually run and it's non-trivial to update it to do so.
From looking at the code though, it looks like although you create a GeoQuery
, you never actually set up an event listener. We've got some documentation on how this works which should help clear things up. You may also want to look at this code which attaches listeners to a GeoQuery
from the SF Muni example.
Instead of helping correct the code where I specifically mentioned, you are telling me it doesn't run. I have to paste in all the codes from the app I'm building for it to run. All I'm asking you is to help write a sample geofire.js code to do a certain thing. You didn't. Then I showed you how I approached it, you didnt even try to make a correction. Now you are referring me to the docs. You guys think your docs are self explanatory, but it isn't. If it was, I wouldn't be here. This is my 3rd month on geofire and I still cant figure out how it to make it work with already existing data.
Here is what I am asking: I my users can post 'messages' and get a list of latest 'messages'
Here is the nature of the data:
https://shsjdhsdjs.firebaseio.com/messages
{ title: "This is the title", body: "This is the body", longitude: 12.4343, latitude: 65.3232 }
I already have the users location at
var longitude = 12.2323; var latitude = 43.434;
This already works fine with firebase. But I want to integrate geofire so that Users can only see messages within x radius, say 10km.
How do I write the geofire query for this? I've gone through the docs, but no examples talked about what I just mentioned the way I can understand it. I know this will take you only a few lines to accomplish. Please just write the code here and that's it. No more talks. No more referring me to other links. Please just do this. Thanks.
GeoFire uses geostrings, not lat/long pairs, to do its querying. If you want to be able to query existing data you're going to have to do some kind of backfill/migration.
Hey @mbleigh , why close this issue? Someone is complaining about a serious problem and you are closing the issue. Its not an existing data, I just presented a sample data in the way I understand it. Read my question, understand the problem, and tell me the solution.
Don't close an issue until it is solved. You spend quality time building a product like geofire, when a customer finally asks a question, you show up and close it? If you know the answer, why not just write the code before closing it? That means you don't even respect the time you spent building the geofire of a thing.
I can't speak for others, but I would close this issue specifically due to the aggressive and negative tone of your messages @daveozoalor. If you have specific feedback about our documentation or the library (i.e. this description is confusing or this method is broken) then please file a bug with a simple and actionable message and we'll be happy to address it.
If you look at the documentation @jwngr linked you, you'll see it explains how to perform a query like this and there are lots of other resources for building things on Geofire (examples, stackoverflow, etc.) This bug tracker is to specifically track issues that will result in changes to the files in this repository. Since your question is more vague / general, it's probably best asked on StackOverflow or the Firebase Mailing list.
We sincerely appreciate you digging into Firebase and GeoFire, but this conversation doesn't embody the type of caring and respectful communication we're trying to cultivate on this and our other repos and as such the issue has been closed.
[retracted]
Dave, please keep the comments civil. The devs are extremely busy, just like you, and deserve the same respect and consideration. If you're not happy with the support you're getting here, please reach out to me directly and I'll see what I can do to improve the process and to get you some answers, glad to help!
Feel free to repost your comment in a more constructive form here in the repo or email me directly with your questions. My email is katowulf of the google clan.
I dont really know how to use query with geofire.js properly.
Here is what I'm trying to do:
NB: I am using framework7 and the code below works perfectly well without geofire. However I just want to add geofire location feature. Thanks.
Here is my code with an attempt at geofire.js, that is not working:
if (navigator.geolocation) { navigator.geolocation.watchPosition(showPosition); } else { myApp.alert("Geolocation is not supported by this browser."); }
//passing the longitude and latitude values into geofire geoFire.set("location", [longi, lati]).then(function() { myApp.alert("Provided key has been added to GeoFire"); //pushing both the message and the geofire location key to firebase messagesRef.push({ //userid user_id: localStorage.user_id, // Message text text: messageText, //user name name: name, // Day day: !conversationStarted ? 'Today' : false, time: !conversationStarted ? (new Date()).getHours() + ':' + (new Date()).getMinutes() : false }) }, function(error) { console.log("Error: " + error); }); }
`The first error I'm getting is Uncaught TypeError: Cannot read property 'then' of undefined" That error is refering to the 'then' in this line:
geoFire.set("location", [longi, lati]).then(function() {
Apart from this error, i dont think I got the query correctly.//here is the code that attempts to retrieve a list of messages within x radius
`var geoQuery = geoFire.query({ center: [10.38, 2.41], radius: 10.5 });
//updating message details to firebase. myMessages.addMessage({
` Thanks alot as you help correct the code.