Coder Social home page Coder Social logo

d3rrick / lrm-google Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dergutewolf/lrm-google

0.0 1.0 0.0 187 KB

Support for Google Directions API in Leaflet Routing Machine

Home Page: http://kahkhang.github.io/lrm-google/

HTML 30.92% JavaScript 69.08%

lrm-google's Introduction

#Leaflet Routing Machine / Google Directions API

Extends Leaflet Routing Machine with support for Google Directions API.

For more information on the use of this router, the Leaflet Routing Machine tutorial on alternative routers is recommended.

Installing lrm-graphhopper

Use Bower to install the lrm-google package.

bower install --save lrm-google

Include the appropriate javascript dependencies in your html file.

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=<YOUR GOOGLE DIRECTIONS API KEY HERE>"></script>
<script src="bower_components/lrm-google/lrm-google.js"></script>

Using lrm-google

You will need a valid Google Directions API in order to use this router.

Basic Usage:

L.Routing.control({
  waypoints: [
    L.latLng(1.350794, 103.835950),
    L.latLng(1.392755, 103.913670)
  ],
  router: L.Routing.google(),
  lineOptions: {
        styles: [
            {color: 'black', opacity: 0.3, weight: 11},
            {color: 'white', opacity: 0.9, weight: 9},
            {color: 'blue', opacity: 1, weight: 3}
        ]
    }
}).addTo(map);

Specifying custom routing options (See the Directions Service API for more details):

L.Routing.control({
  waypoints: [
    L.latLng(1.350794, 103.835950),
    L.latLng(1.392755, 103.913670)
  ],
  router: L.Routing.google({
    travelMode: google.maps.TravelMode.TRANSIT,
    unitSystem: google.maps.UnitSystem.METRIC,
    provideRouteAlternatives: true
  }),
  lineOptions: {
        styles: [
            {color: 'black', opacity: 0.3, weight: 11},
            {color: 'white', opacity: 0.9, weight: 9},
            {color: 'blue', opacity: 1, weight: 3}
        ]
    }
}).addTo(map);

##Demo

See the Demo for an example of usage.

##Known issues

The displayed icons of instruction steps do not correspond to the direction of the instruction (Working on that).

lrm-google's People

Contributors

kahkhang avatar

Watchers

@d3rrick 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.