Giter Club home page Giter Club logo

spyme's Introduction

Spyme

Track your visits location using the Geolocation Browser API easily

Location is stored in the session, it doesn't generate any model so you can persist it in anyway you like.

You get:

  • better geolocation - Browser geolocation has much better exactness than IP-based geocoding.
  • persist it the way you want it - As Spyme doesn't define any persisting model, you can map it to your model in any way you like.

How it works

When someone visits your site Spyme will check if the browser support the Geolocation API and if the user accepts to be tracked it automatically stores the the location in the session.

Use current_location to access the Location object for the current visit.

Power up

Use Geocoder with Spyme to track your model objects near the visit current location.

Example:

Venue.near(current_location.coords, 20) # venues within 20 miles current visit location

Installation

Add this line to your application's Gemfile:

gem 'spyme'

Lastly, include the javascript file in app/assets/javascripts/application.js after jQuery.

//= require jquery
//= require spyme

Location

Spyme automatically stores the current location at the session you can access in your controller with this helper method

current_location

Sometimes the user deny the tracking or the browser doesn't support geolocation, you can check if the current location is valid

current_location.valid?

Also the Spyme::Model::Location object has some useful methods

to_hash

current_location.to_hash

returns { latitude: # tracked_latitude, longitude: # tracked_longitude }

coords

current_location.coords

returns [ # tracked_latitude, # tracked_longitude]

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

spyme's People

Contributors

jvillarejo avatar dependabot[bot] avatar victorsosa avatar krisl avatar

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.