Coder Social home page Coder Social logo

emilbjorklund / geomock Goto Github PK

View Code? Open in Web Editor NEW

This project forked from janmonschke/geomock

0.0 0.0 0.0 68 KB

Mocks the navigator.geolocation in the browser so you don't have to move around when testing your gps-enabled Website/App

Home Page: http://janmonschke.com/GeoMock/example.html

geomock's Introduction

GeoMock

Developing Geo-aware Apps/Games can be such a pain in the ass.

It can take ages until the device finally gets a decent signal or it's raining outside and you don't want to run around out in that bad weather to test your app or maybe you're just too lazy to walk a mile or two ;)

GeoMock can help in many ways when working with the Geolocation API: - Predefined locations can fire up through the normal Geolocation API after a certain delay or even immediately - It also allows you to define a set of waypoints that are being propagated through geolocation.watchPosition. - It can be used to test the way your app behaves when no signal could be retrieved

Usage

It seems like Firefox does not allow the geolocation object to be overridden, so Geomock does not work in Firefox. 
But it's been tested in all Webkit-based browsers and Opera.`

Simply include geomock.js in your website and it will replace the native Geolocation object. There is no need to change the API for tests because it mocks the Geolocation API.

To retrieve a location user navigator.geolocation.getCurrentPosition(success, error) or navigator.geolocation.watchPosition(success, error).

The mock-locations can be changed by accessing the navigator.geolocation.waypoints-Array.

The predefined delay is 1000ms. Change it like this navigator.geolocation.delay = 2000;.

To test failing requests, set navigator.geolocation.shouldFail to true.

Example

http://janmonschke.com/GeoMock/example.html

License

MIT

geomock's People

Contributors

fb3 avatar janmonschke 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.