How to include leaflet-routing-machine into angular 2 typescript webpack application

后端 未结 2 701
野的像风
野的像风 2021-01-13 06:07

I used this seed to get started with Angular 2 Typescript and Webpack: https://github.com/haoliangyu/angular2-leaflet-starter.

I\'m new to most of the used tools an

2条回答
  •  有刺的猬
    2021-01-13 06:18

    I haven't worked with either Angular 2, nor TypeScript, but I suspect that TypeScript doesn't like that LRM attaches itself to the L object/namespace.

    Note that LRM also exports itself as a normal CommonJS module, so you can do something like this instead of using L.Routing.Control:

    var L = require('leaflet');
    var Routing = require('leaflet-routing-machine');
    
    var map = L.map(...);
    var routingControl = Routing.control({ ... });
    

提交回复
热议问题