Giter VIP home page Giter VIP logo

geomapping's Introduction

GeoMapping

npm version

Get started:

Installation:
npm install geomapping

Include GeoMapping script, you can also load a config file.

<script src="myPath/geomapping.js"></script>
<script src="myPath/geomap-config.js"></script>

Init geoMapping:

var geoMap = new GeoMapping(geomapConfig);

See example of config

Methods:

  • getPoints(): Return all points with x and y position.
  • getPointById(id): Return the point object.
  • filterPointsByData(key, value): Return points object filtered by your params.
  • addPoint(lat, lng, id, data): Add it to the list of points.
  • removePoint(id): Remove it from the list of points.
  • getLatLngOnMap(x, y): Get lat and lng of a point in the map.
  • getPointXYOnMap(lat, lng): Get x and y of a coord in the map.
  • trackPosition(errorCallback): Track user GPS position, use "UPDATE_POSITION" event to get map point coords.
  • stopTrackPosition(): Stop tracking position.

Example:

var points = geoMap.getPoints();
var myPoint = geoMap.addPoint(43.604652, 1.444209, "Toulouse", {
    dpt: "Haute Garonne",
    postal: 31000
});
if(!myPoint.isOutOfMap){
    createHotspot(myPoint.x, myPoint.y);
}
geoMap.getPointById("Toulouse");
geoMap.filterPointsByData("postal", 31000);
geoMap.trackPosition(function(errorMessage){
    // Error code here
});

Events:

  • READY : when the lib is ready.
  • ADD : when a point is added.
  • REMOVE : when a point is removed.
  • UPDATE_POSITION : when the user move when tracking position is activated.
  • STOP_POSITION : when tracking is stopped.

Example:

geoMap.on(GeoMapping.EVENTS.READY, function(){
    console.log('READY !!');
});

geoMap.on(GeoMapping.EVENTS.ADD, function(data){
    console.log('NEW POINT ADDED !!', data);
    updatePoints();
});

Library Dev:

Compil via rollup:

  • Dev live reload: npm run watch
  • Build: npm run build

Test: Open ./test/index.html

npm run test do not work for the moment (No DOM to load Image)

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.