Issue
These are my packages:
"@types/leaflet": "^1.8.0",
"@types/leaflet-draw": "^1.0.5",
"leaflet-canvas-markers": "^1.0.7",
"leaflet": "^1.9.1",
"leaflet-draw": "^1.0.4",
These are my imports a the top of my Angular service file:
import * as L from 'leaflet';
import 'leaflet-canvas-markers';
import 'leaflet-draw';
In Angular 13 (Typescript 4.6.4) it was ok, but now I'm moving to Angular 14 (Typescript 4.7.4) and I'm getting this error:
Error: export 'Draw' (imported as 'L') was not found in 'leaflet' (possible exports: ...)
I've got the same behavior with "canvasMarker" npm library.
Error: export 'canvasMarker' (imported as 'L') was not found in 'leaflet' (possible exports: ...)
The code that raise the error within my Angular service is:
const leafletDrawPolyline = new L.Draw.Polyline(map, options);
After reading this, I tried in the following without success:
const leafletDrawPolyline = new (L.Draw as any).Polyline(map, options);
I understand it's a kind of import issue at Typescript level, but I don't know how to solve. Any suggestion?
Solution
This is an issue in leaflet 1.9.1. There is a bug report here: https://github.com/Leaflet/Leaflet/issues/8521.
For now you can fix the version to leaflet 1.8.x by setting the version in package.json as ~1.8.0
.
Updated:
This is now fixed in leaflet 1.9.2 so setting leaflet to version ^1.9.2
should now work.
Answered By - rmja
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.