I am trying to use Leaflet and Leaflet Routing Machine. I used following commands to install leaflet and leaflet routing machine,
npm i leaflet
npm i --save-dev @types/leaflet
npm i leaflet-routing-machine
npm i --save-dev @types/leaflet-routing-machine
Importing leaflet and using it is fine but when I am trying to use leaflet routing machine it it giving me errors.
Following is my code,
L.Routing.control({
waypoints: [
L.latLng(latitude, longitude),
L.latLng(latitude, longitude),
],
show: false,
lineOptions: {styles: [{color: randomColor, opacity: 1, weight: 5}],},
createMarker: function () {
return null;
},
}).addTo(this.map);
I am using webstorm as IDE I get 2 errors for both lineOptions
and createMarker
. I have the same code in plain JavaScript and it is working fine but for Angular it is giving me this errors.
For lineOptions
it says following and when I added those missing params, the error was gone but I don't want to put those params.
TS2739: Type '{ styles: { color: string; opacity: number; weight: number; }[]; }' is missing the following properties from type 'LineOptions': extendToWaypoints, missingRouteTolerance
And for createMarker
it says following,
TS2345: Argument of type '{ router: MapBox; waypoints: LatLng[]; show: false; createMarker: () => null; }' is not assignable to parameter of type 'RoutingControlOptions'. Object literal may only specify known properties, and 'createMarker' does not exist in type 'RoutingControlOptions'.
Since it is working in JavaScript why it is not working in Angular?