Giter Club home page Giter Club logo

boxer's Introduction

boxer.js

A little framework for Mapbox GL JS

Install

Manually

After downloading le library in your project directory, include the following assets in your HTML:

<!-- add the mapbox assets -->
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.1/mapbox-gl.css' rel='stylesheet' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.1/mapbox-gl.js'></script>

<!-- add the mapbox assets -->
<script src='assets/raphhh/boxer-0.0.0/dist/boxer.min.js'></script>

Install dev

  1. $ git clone https://github.com/Raphhh/boxer.git
  2. $ npm install

Examples

Display a map

mapboxgl.accessToken = 'pk.eyJ1IjoicmFwaGhoIiwiYSI6ImNpaTZiajRxdTAxbmlzd2txbnFzOHJhZGQifQ.fazKIAAlHZWCM2RTSjU86w';

var application = new Boxer.Application();

application.on('map.ready', function(){
    alert('your map is ready :)')
});

application.register('map.init', new Boxer.Map.MapProvider(
        mapboxgl,
        {
            container: 'map', // container id
            style: 'mapbox://styles/mapbox/streets-v8', //stylesheet location
            center: [-74.50, 40], // starting position
            zoom: 9 // starting zoom
        }
))();

See the demo.

Watch GeoLocation

application.on('geo.success', function(geoPosition) {
    if(this.services.geoManager){
        this.services.geoManager.put('me', new Boxer.GeoJson.GeoPoint(geoPosition));
    }else{
        console.error('application.services.geoManager not initialized');
    }
});

application.register('geo.init', new Boxer.GeoLocation.WatcherProvider(navigator))();

See the demo.

Sync position with socket.io

application.on('geo.success', function(geoPosition) {
    if(application.services.socket){
        console.log('emit to socket', geoPosition);
        application.services.socket.emit('geo', geoPosition);
    }else{
        console.error('application.services.socket not initialized');
    }
});

application.register('socket.init', new Boxer.Socket.SocketProvider(io, 'http://localhost:8080'))();

See the demo.

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.