I used this seed to start with Angular 2 Typescript and Webpack: https://github.com/haoliangyu/angular2-leaflet-starter .
I am new to most of the tools and technologies used (Angular 2, Typescript, Webpack). Although I understand this more and more, it seems that I still have not understood how third-party non-print JS libraries are included:
I would like to include sheetlet-routing-machine.js in my project. As far as I know, while there are type designations for leaflets, there is no typographic designation for a leaflet machine.
I installed the package via npm install and added the necessary quick start code to display the route.
map.service.ts
/// <reference path="../../typings/leaflet/leaflet.d.ts"/> import {Injectable} from 'angular2/core'; import {Map} from 'leaflet'; Injectable() export class MapService { map: Map; // holds reference to the normal leaflet map object showRoute(){ L.Routing.control({ waypoints: [ L.latLng(47.569198, 7.5874886), L.latLng(47.5685418, 7.5886755) ] }).addTo(this.map); } }
The error I get on npm start :
ERROR in ./app/services/map.service.ts (56,11): error TS2339: Property 'Routing' does not exist on type 'typeof L'.
As I understand it, I should not include the JS file in index.html, as this should be done automatically by webpack. Next to the fact that I'm not at all sure how to include third-party libraries without typing (answers like this did not help), it seems that my business is a little different, the L object is a standard sheet and does not know the Routing property. That I somehow understand, since I do not see how the routing library extends the library of leaflets.
Any suggestions?
source share