I know this is an issue that comes up here often and is fixed by fixing import statements. I currently have
import { LeafletModule } from 'node_modules/@asymmetrik/ngx-leaflet';
import * as L from 'leaflet';
import { } from '@types/leaflet';
I am referencing options and as such:
options = {
layers: [
this.googleHybrid
],
zoom: 1.49,
zoomSnap: 0,
center: L.latLng([180, -180])}
I feel like I am running into this issue because of importing everything from leaflet as L. Any thoughts?
Edit: I should also add that this is only coming up in testing.
What does "Can't bind to 'x' since it isn't a known property of 'y'" mean? link. This error often means that you haven't declared the directive "x" or haven't imported the NgModule to which "x" belongs. Perhaps you declared "x" in an application submodule but forgot to export it.
Solution for Angular Can't bind to 'ngIf' since it isn't a known property of 'div' There are multiple ways to fix this. Incorrect ngIf syntax One way, This is due to an error caused due to misspelling capital 'I' for div. To solve this, Import CommonModule or BroswerModule or both into app.
This happens when Angular.io hasn't properly loaded the LeafletModule into your application. Usually, you'd do the following:
First, Import LeafletModule
into your application module:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { LeafletModule } from '@asymmetrik/ngx-leaflet';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
LeafletModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
And then, if you are using ngx-leaflet in a sub module of the application module, you need to import it into that one too:
import { NgModule } from '@angular/core';
import { LeafletModule } from '@asymmetrik/ngx-leaflet';
@NgModule({
declarations: [
],
imports: [
LeafletModule
],
providers: []
})
export class MyModule { }
There's a tutorial that address how to get up and running with Angular CLI, but it doesn't address the situation where you have sub modules of the application module using ngx-leaflet.
A couple other notes:
LeafletModule
. Most build pipelines will dereference packages automatically.@types/leaflet
import. Most build pipelines will automatically pull in type information if needed.import * as L from 'leaflet';
You can also import specific items as needed e.g., import Map from {leaflet};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With