GithubHelp home page GithubHelp logo

chanakadrathnayaka / types-leaflet-routing-machine Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 2.0 31 KB

Documentation of @types/leaflet-routing-machine

Home Page: https://www.npmjs.com/package/@types/leaflet-routing-machine

SCSS 8.02% HTML 91.98%
leaflet-routing-machine typescript

types-leaflet-routing-machine's Introduction

TypeScript definition for leaflet routing machine

Leaflet Routing Machine is an amazing plugin developed by @perliedman in order to draw routes on a leaflet map. TypeScript definition helps you to use this plugin in your typescript projects.

How to use leaflet-routing-machine.js in an Angular project

  1. Install leaflet
        npm i leaflet
    
  2. Install TypeScript definition of leaflet
        npm i --save-dev @types/leaflet
    
  3. Install leaflet routing machine
        npm i leaflet-routing-machine
    
  4. Install TypeScript definition of leaflet routing machine
        npm i --save-dev @types/leaflet-routing-machine
    
  5. Import leaflet.css & leaflet-routing-machine.css into the project
    • Open angular-cli.json
    • Add leaflet & leaflet-routing-machine css file into style attribute.
        "styles": [
            "../node_modules/leaflet/dist/leaflet.css",
            "../node_modules/leaflet-routing-machine/dist/leaflet-routing-machine.css"
        ]
  6. Import leaflet into the component
    • Add below import statements top of your component
        import * as L from 'leaflet';
        import 'leaflet-routing-machine';

How to use leaflet routing machine in your typescript project

import * as L from 'leaflet';
import 'leaflet-routing-machine';

const map: L.Map = L.map('map-container');

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

L.Routing.control({
    router: L.Routing.osrmv1({
        serviceUrl: `http://router.project-osrm.org/route/v1/`
    }),
    showAlternatives: true,
    lineOptions: {styles: [{color: '#242c81', weight: 7}]},
    fitSelectedRoutes: false,
    altLineOptions: {styles: [{color: '#ed6852', weight: 7}]},
    show: false,
    routeWhileDragging: true,
    waypoints: [
        L.latLng(57.74, 11.94),
        L.latLng(57.6792, 11.949)
    ]
}).addTo(map);

Do you want any modification or report an issue?

This type definition is provided as a fundamental solution for configure and display a route by using leaflet routine machine. This definition may not be enough for advanced use cases such as Interaction, Support for other routing machine back ends. If you need any support with such scenario feel free to contact me via [email protected].


Visit me

types-leaflet-routing-machine's People

Contributors

chanakadrathnayaka avatar

Stargazers

 avatar

Watchers

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