Git Product home page Git Product logo

geofire-js's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geofire-js's Issues

Stuck On How To Handle Results

Awesome library, looks great! I'm trying to use it instead of what I'm currently doing (run through a firebase array of clubs close to a user, calculate distances with the Haversine formula, and put clubs within a certian distance into an array, then ng-repeat through that array to show to the user).

So with GeoFire I got the query working, and I can get the unique IDs of each club within the radius logged to the console. But how can I ng-repeat or show that to the user?

Right now my geofire and club data looks like:

 "geoFire": {
       "uniqueClubID": {
               "g": "data",
               "i": "data"
                  }
}
"clubs": {
     "uniqueClubID": {
              "name": "club name here",
               "description": "This club does stuff"
              }
}

Any help would be greatly appreciated, thanks!

Oh, and I'm not trying to show a map, I'm just trying to show a list of the club names and descriptions to the user.

Retrieve country code of a visitor

Hi there,
Is it possible to retrieve a country information of a visitor without (the browser) asking the visitor to share their location with geofire?
Like, say, using visitor's IP to determine their location?
cheers

Upgrade RSVP dependency from 3.0.16 to 3.0.17

Requesting a minor point release upgrade of the dependent RSVP module from 3.0.16 to 3.0.17. 3.0.16 breaks Geofire's ability to be consumed by browserify but a fix was released with 3.0.17. See the issue and merge in RSVP repo.

Is there a way to query once for a given location and radius?

Is there a way to query once for a given location and radius? I don't want to get changes realtime in this use-case. Instead, I just need all the results once the query completes.

I'm looking for something similar to the once function in Firebase.

Demo fail

Got the following error on Ubuntu Chrome:
"Uncaught Error: Attempted to find predecessor key for a nonexistent key. What gives? " in firebase.js:1

Shows "buses currently in the circle" and their names, but doesn't put any pins on the map and nothing is clickable, though the map itself works properly.

Screenshot:
image

Polygon shaped geoqueries

What about support for polygon based geoQueries ? The current API seems to provide support only for circular geoQueries.

Accuracy

Hi,

What is the best possible accuracy? Can I get within 500m?

Cheers.

perf optimization

Since it's a real-time, so the performance of JS execution might be crucial at some point. There are obvious pieces of code that can be optimized by either using native methods or lodash library. For example:

  1. use Array.isArray() vs bject.prototype.toString.call(location) !== "[object Array]" (perf comparison)
  2. use either lodash forEach method of Object.keys() to loop thru the object because for..in is extremely slow.
  3. use obj[key] = undefined instead of delete key in order not to trigger code deoptimization of JS engines.

Firebase 2.1.1 support?

What will it take to approve support for the latest version of Firebase? Are there any changes in Firebase 2.1.x that would causes anything in GeoFire to break?

Example how to use Firebase Queries

Based on Docs:
'With the release of GeoFire 3.1.0, this library now uses the new query functionality found in Firebase 2.0.0.'
In particular I am interested in limitToLast query found in Firebase with expected usage:

geoFireRef.limitToLast(2).on("key_entered", function(key, location, distance) { ...

But it throws an error TypeError: geoFireRef.limitToLast is not a function
Is it possible to use Firebase queries in GeoFire?

Geofire once queries (key_entered)

Hi,

As you ask about enhancements, I got another interesting use case.

In my app, I want to send Pushs notification to users in the x miles around.
So, I use a Geofire query with key_entered.
But, I would like the query stop, once all the current child have been entered (like a .once() in Firebase). If new users come in the query, I don't want to send them a notification.

I could use a Firebase .once event and compare distance, but if a query would exist for that, I think it should be better.

What do you think?

Cheers,
Clément

Question: Number of GeoIndices?

Great library!
Design question...(may be just as much Firebase as GeoFire related)
Would you consider it feasible to add hundreds of thousands of small geo indices?
I have use case where I have a user generated item that needs to be tagged with geo locations. Sometimes it may be 5 sometimes 5000. There will be thousands of these user generated items per day and storing all their tags in a huge geoindex will require me to fetch way to may to the client only to filter most of them out.

GeoQuery is only returning nearby keys if a huge radius is set

My Geofire query only returns something if the radius is set to a seemingly arbitrary 1197 or above. Any less and nothing will be returned. When the data is returned and I log the distances, they are all less than 1, so this doesn't make any sense to me.

Any ideas for why this is occurring?

Code:

var firebaseRef = new Firebase("<firebase url>");
var geoFire = new GeoFire(firebaseRef);

var geoQuery = geoFire.query({
  center: [50.72, -1.88],
  radius: 1197 // the minimum radius that will return
});

geoQuery.on("key_entered", function(key, location, distance){
  console.log(key + ', ' + location + ', ' + distance);
});

Thanks!
Lawrence

Rename GeoFire Keys

It would be nice to be able to rename geoFire keys. Maybe something like GeoFire.rename("some key", "some new name key").then();

As of right now, you have to do GeoFire.remove("some key").then(function () { GeoFire.set("some new key").then() });

Create global error logger in GeoFireUtils

With a lot of other Firebase libraries, errors begin with the name of the library, such as "Firebase Simple Login: error message." We should adopt this practice for GeoFire. It will probably be easiest to just make a utility method logError(message) which appends to "GeoFire:" to the error message.

Promise Error

I am getting the following error:
Error: undefined is not an object (evaluating 'new RSVP.Promise')

Any idea why?

The documentation is confusing

How can i find list of posts made close to me or by users who are closest to me, for instance?

Here is how i setup my database:
1- users
*id
*email
*password
*longitude
*latitude

2- posts:
id
title
body
longitude
lattitude

How does geofire come in and what exact query do i write?

I have tried to implement geofire twice, all ending in failure because i dont understand the concept beyond the example in the docs

Add more bounding box dimensions to allow for longer geohashes

This is related to pull request #15.

The geohash length stored in GeoFire is limited by the length of g_BOUNDING_BOX_SHORTEST_EDGE_BY_GEOHASH_LENGTH, which is currently 7. For small queries (less than 0.6 km), we still can only use a geohash of length 7 which means we end up loading a lot of locations which could be well outside of our query. We should increase the length of g_BOUNDING_BOX_SHORTEST_EDGE_BY_GEOHASH_LENGTH to 10, which should give us a precision of 1m and eliminate this unnecessary memory footprint.

About sfVehicles Bug

When I opened the sfVehicles index.html, then I switched to another tab in Chrome, after a while, i switched back to sfVehicles index.html opened before, I found many vehicle icons on the map were shaking from left to right or up and down. I think it is a bug.

If GeoFire is being run in node, firebase is not included

If GeoFire is being run in node, firebase is not included.
This:

  var Firebase = require("firebase");

should be added to the following:

// Include RSVP if this is being run in node
if (typeof module !== "undefined" && typeof process !== "undefined") {
  var RSVP = require("rsvp");
}

Bower versions do not resolve

Command run bower install --save-dev angularGeoFire

Extract from build
bower rsvp#~3.0.9 ENORESTARGET No tag found that was able to satisfy ~3.0.9

Additional error details:
Available versions: 3.0.8, 3.0.6, 3.0.5, 3.0.4, 3.0.1, 3.0.0, 2.0.4, 2.0.1, 1.2.0, 1.1.1, 1.1.0, 1.0.0

this is in the v2 branch

limit results

Is it possible to limit results for a specific query?
Similar to .limitToLast() in the Firebase API

Sample security rules could be tighter

The sample Firebase security rules allow for anyone to come in and wipe out your geofire index, with a call to fb.set(null).

I know individual requirements will vary, but it might be a good idea to point out the risk of deletion and offer an alternative, such as allowing anyone to write assuming they aren't deleting.

{
  "rules": {
    "<your-geofire-node>": {
      // Allow anyone to read from this node
      ".read": true,
      // Index each location's geohash for faster querying
      ".indexOn": ["g"],
      // Schema validation
      "$key": {
        // Allow anyone to write to this node, assuming they respect the schema and they are not trying to delete
        ".write": "newData.exists()",
        ".validate": "newData.hasChildren(['g', 'l']) && newData.getPriority().length <= 22 && newData.getPriority().length > 0",
        "g": {
          ".validate": "newData.val() == newData.parent().getPriority()"
        },
        "l": {
          "0" : {
            ".validate": "newData.isNumber() && newData.val() >= -90 && newData.val() <= 90"
          },
          "1" : {
            ".validate": "newData.isNumber() && newData.val() >= -180 && newData.val() <= 180"
          },
          "$other": {
            ".validate": false
          }
        },
        "$other": {
          ".validate": false
        }
      }
    }
  }
}

Update object one node

I would like to update a node with new object, but the current method to do that is only for update location attributes of point, can we do something to improve that ?

Allow setting of promise library

It would be nice to support the setting of a desired promise library, such as Bluebird, to override the default RSVP lib. eg: GeoFire.Promise = require('bluebird');

Multi-paths update and Geofire

Hi,

As mentioned here, I think it should be great to easily multi update data paths and a geofire path at the same time. As the set of Geofire is pretty complex, it's hard to directly copy/paste the code to make it works.

Here the use case : (I use the same as the link above but add a path to know where a post is located). So the structure :

{
  posts: {
    post1: {
      from : user1,
      message: "Hi",
    },
    post2: {
      from : user2,
      message: "Hey",
    }
  },
  posts-location: {
    post1: {
      g : 'xxxxxxxx',
      l: {
         0 : latitude,
         1 : longitude
      }
    },
    post2: {
       g : 'xxxxxxxx',
       l: {
         0 : latitude,
         1 : longitude
      }
    }
  },
  users: {
    user1: {
      posts: {
        post1: true
      }
    },
    user2: {
      posts: {
        post2: true
      }
    }
  }
}

Now I can add a post at the same time at users and posts (with multi-path update). But I need to set the position after. In my use case, a post without a position is not valid data, it's for that the best should be to do the 3 updates at the same times (if one fails, all fail).

Deleting Geofire path is easy (using update(null)), we can multi-update for delete, but for set/update, I loop for a way to do that easily,

Cheers,
Clément

GeoFire using too much data on client side

So, we have a mobile app which filters 1000's of realtime position of cars and shows user's cars within a 5 mile radius of their current location. Geofire works as expected. Each driver app updates the position of that vehicle to Geofire. Geofire on client filters 5 mile radius of current user location.

However, geofire seems to be downloading all 1000's of cars realtime position to client and then sorting it at client side. how can we avoid this?

Ideally we send lat, long and radius and all these queries should happen at firebase server and not at client. This is likely to load client side with a lot of incoming data.

Is there a better way to query and avoid all realtime position being streamed to client?

Fix broken build

The build fails because of a bad peer dependency. Even after fixing that, the tests don't pass because Firebase is not compatible with the used PhantomJS version. It might be time to upgrade to Mocha and be done with all the PhantomJS stuff.

Add support for deleting keys with onDisconnect

I'd imagine a common scenario would be GPS tracking users from their own devices, the client should optionally clean up behind itself when the user disconnects and the data isn't "real time" anymore.

What is the recommended way of updating geolocation while preserving associated data?

I have the following structure:

screen shot 2014-08-27 at 00 02 03

I would like to update the location, while preserving the data

There is GeoFire.set(key, location) https://github.com/firebase/geofire-js#geofiresetkey-location

But when I call it the data would be lost.

I think I've found a workaround but it doesn't seem very intuitive to me:

        firebaseRef.child('data').once('value', function(snap) {
          var data = snap.val();
          geofire.set(name, [lat, long]).then(function() {
           firebaseRef.child('data').set(data);
          }, function(error) {
            console.log('Error: ' + error);
          });
        });
  1. Saving data locally
  2. Updating geofire
  3. Storing data back to Firebase

Seem like a lot of work. Is there a better way?

Video explanation: https://www.youtube.com/watch?v=i5u77q7l8dU

You data sets are updating niceely: https://publicdata-transit.firebaseio.com/sf-muni :)

Thanks!

Random Points Close to Location

So, weird question...

Is there a way to easily get some random location points around your location? I.E. you have userLocation, and you want to make a random location point within a one mile radius of that location. Would something like that be possible with geoFire?

Canceling query in callback of query.on('key_entered', callback) results in error

Hi there, I think I've run into a bug when canceling a query from within the key_entered callback when the query already has locations tracked. I've included a JS fiddle below - it triggers the debugger right before the error. Just step out and you'll end up in geofire.on(), and on line 1110 (geofire.js) in the next iteration of the for loop, locationDict is undefined.

_locationsTracked is being reset on the query.cancel() call. I think a solution might just be to check that _locationsTracked[key] still exists before trying to see if _locationsTracked[key].isInQuery is true.

For some reason, it's not displaying an error in the console, but stepping through definitely shows there's an error.

JS Fiddle

EDIT: to clarify, it's actually throwing an error in an angular app I'm running with a local bower install of geofire. It's using the following dependencies:

geofire#3.2.3
#2.3.2
rsvp#3.1.0

if that helps...

Improve computation of geohashes inside a query's bounding box

Within _listenForNewGeohashes(), we end up querying nine geohashes which encompass a GeoQuery. In cases where the query's radius is just greater than one of the values in g_BOUNDING_BOX_SHORTEST_EDGE_BY_GEOHASH_LENGTH, we end up loading a lot more data than we need to since most of the geohashes we are querying for are not even close to being in our query. We should use a smarter algorithm to compute a bounding box around a GeoQuery. This will probably involve doing more than nine geohash queries on geohashes of varying lengths.

How to do complex queries with geofire?

I am trying to use GeoFire, but even after reading all the examples here https://github.com/firebase/geofire-js/tree/master/examples I don't quite understand how it works.
with this snipped you can set a geo location for a single key:

geoFire.set("some_key", [37.785326, -122.405696]).then(function() {
  console.log("Provided key has been added to GeoFire");
}, function(error) {
  console.log("Error: " + error);
});

but how do I use geo locations for complex objects instead of simple string keys?
what if you have a restaurant with a name, average dish price and opening hours? do you need to store them in a second collection and somehow join them in your query?
I found this discussion #40 — it answers the question that you actually need to keep the geofire data in a seperate collection, but i am still wondering:
how do you make more complex queries such as "near my location, open now and $15 avg dish price" ? do you really need to load all ids of locations nearby and then send those ids back to the server in a second query to filter out the ones that match the complex query? how do you do that? is there any example?

thanks a lot for your help!

Extra condition in geoQuery?

Hey!

I am wondering if there is any way to handle extra conditions within the geoQuery? For example, I would like the query to also account for other variable?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.