I am developing in a large angular 8 app that has many components that use leaflet. The existing components use leaflet and some plugins directly, imported like so:
import * as L from 'leaflet'
import 'leaflet.markercluster'
which has been working.
I'd like to gradually introduce ngx-leaflet
as we build out new components and refactor existing ones, but this is causing trouble. I created a simple map component following the documentation, which seems to work fine. However, existing components are now failing to render properly. A component using markercluster errors with
TypeError: L.MarkerClusterGroup is not a constructor
.
The L
object that the component is trying to use appears to be properly extended with the markercluster functionality, but down the callstack I see
runOutsideAngular @ core.js:39571
, which I suspect is stemming from some cross communication with ngx-leaflet
.
I haven't seen any examples or documentation trying to do what I'm describing- is it expected that leaflet used outside of the ngx-leaflet
directives will be problematic like this, or should I be able to isolate the library to the components that I'm intending to use it in?