I followed the steps from the main git: https://github.com/Asymmetrik/ngx-leaflet
first I installed the required libraries (leaflet, leaflet-draw, leaflet-ngx, and leaflet-draw-ngx)
then I declared the required directive imports in app.module.
In my view I set the following:
<div class="col-md-6" style="height: 400px;"
leaflet
leafletDraw
[leafletOptions]="options"
[leafletLayers]="layers"
[leafletLayersControl]="layersControl"
[leafletDrawOptions]="drawOptions">
</div>
but I get the following error:
> Uncaught Error: Template parse errors:
Can't bind to 'leafletDrawOptions' since it isn't a known property of 'div'. ("fletDraw [leafletOptions]="options" [leafletLayers]="layers" [leafletLayersControl]="layersControl" [ERROR ->][leafletDrawOptions]="drawOptions"> </div> <div class="col-md-6"> <table class="table table-striped c"): ng:///gxxxx.html@0:258
at syntaxError (compiler.es5.js?524d:1689)
at TemplateParser.parse (compiler.es5.js?524d:12802)
at JitCompiler._compileTemplate (compiler.es5.js?524d:26852)
at eval (compiler.es5.js?524d:26772)
at Set.forEach (<anonymous>)
at JitCompiler._compileComponents (compiler.es5.js?524d:26772)
at eval (compiler.es5.js?524d:26659)
at Object.then (compiler.es5.js?524d:1679)
at JitCompiler._compileModuleAndComponents (compiler.es5.js?524d:26658)
at JitCompiler.compileModuleAsync
I am new to angular 4, I'm I doing something wrong ? or is it related to ES version ?
Make sure you import the Leaflet and LeafletDraw modules into the module in which your component is defined (not just in AppModule).
In your AppModule.ts:
import { LeafletModule } from '@asymmetrik/ngx-leaflet';
import { LeafletDrawModule } from '@asymmetrik/ngx-leaflet-draw.module';
...
imports: [
...
LeafletModule.forRoot(),
LeafletDrawModule.forRoot()
]
...
In the component's module:
import { LeafletModule } from '@asymmetrik/ngx-leaflet';
import { LeafletDrawModule } from '@asymmetrik/ngx-leaflet-draw.module';
...
imports: [
...
LeafletModule,
LeafletDrawModule
]
...