npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@2mann/geofire

v4.1.2

Published

Location-based querying and filtering using Firebase

Downloads

12

Readme

FORK NOTES

The purpose of this fork is to allow the set method to take additional data and put it in the firebase node (ie: timestamp)

We can now pass a third argument to set with an object and each property will be added to the geofire node

ex:

export function setUserLocation (uid, coords) {
  return geoFireRef.set(uid, coords, {
    t: database.ServerValue.TIMESTAMP,
  })
}

This payload will be surfaced via the key_added and key_moved callbacks as the fourth argument (all the raw data will be in that object including the geohash and coordinates)

ex:

this.geoQuery.on('key_entered', (key, coords, distance, payload) => {
  if (key !== this.props.currentUserId) {
    this.props.addUser({
      uid: key,
      timestamp: payload.t,
    })
  }
})

NOTE: it will always and only use the payload passed as the 3rd argument If you pass an array of points to set, there is no support for each node having its own payload, it will just use whatever is passed as third argument for each node. This can be changed but im lazy and i dont have a usecase for it ATM

GeoFire for JavaScript Build Status Coverage Status Version

GeoFire is an open-source library that allows you to store and query a set of keys based on their geographic location. At its heart, GeoFire simply stores locations with string keys. Its main benefit, however, is the possibility of retrieving only those keys within a given geographic area - all in realtime.

GeoFire uses the Firebase Realtime Database for data storage, allowing query results to be updated in realtime as they change. GeoFire selectively loads only the data near certain locations, keeping your applications light and responsive, even with extremely large datasets.

GeoFire is designed as a lightweight add-on to Firebase. To keep things simple, GeoFire stores data in its own format and its own location within your Firebase database. This allows your existing data format and Security Rules to remain unchanged while still providing you with an easy solution for geo queries.

A compatible GeoFire client is also available for Objective-C and Java.

Table of Contents

Downloading GeoFire

In order to use GeoFire in your project, you need to include the following files in your HTML:

<!-- Firebase -->
<script src="https://www.gstatic.com/firebasejs/3.7.0/firebase.js"></script>

<!-- GeoFire -->
<script src="https://cdn.firebase.com/libs/geofire/4.1.2/geofire.min.js"></script>

Use the URL above to download both the minified and non-minified versions of GeoFire from the Firebase CDN. You can also download them from the releases page of this GitHub repository.

You can also install GeoFire via npm or Bower. If downloading via npm, you will have to install Firebase separately (because it is a peer dependency to GeoFire):

$ npm install geofire firebase --save

On Bower, the Firebase dependency will be downloaded automatically:

$ bower install geofire --save

Documentation

Examples

You can find a full list of our demos and view the code for each of them in the examples directory of this repository. The examples cover some of the common use cases for GeoFire and explain how to protect your data using the Firebase Database Security Rules.

Example Usage

Assume you are building an app to rate bars and you store all information for a bar, e.g. name, business hours and price range, at /bars/<bar-id>. Later, you want to add the possibility for users to search for bars in their vicinity. This is where GeoFire comes in. You can store the location for each bar using GeoFire, using the bar IDs as GeoFire keys. GeoFire then allows you to easily query which bar IDs (the keys) are nearby. To display any additional information about the bars, you can load the information for each bar returned by the query at /bars/<bar-id>.

Migration Guides

Using an older version of GeoFire and want to upgrade to the latest version? Check out our migration guides to find out how!

Contributing

If you'd like to contribute to GeoFire, please first read through our contribution guidelines. Local setup instructions are available here.