Home - arnaudleclerc/ng-azure-maps GitHub Wiki
An AzureMapsModule
can be imported from the ng-azure-maps
namespace. This class exposes a forRoot
method which can be called by your angular module and where the configuration of the library can be given.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AzureMapsModule } from 'ng-azure-maps';
import { environment } from '../environments/environment';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AzureMapsModule.forRoot({
authOptions: environment.authOptions
})
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
The module can also be lazy loaded using the forChild
method.
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MapComponent } from './map/map.component';
import { AzureMapsModule } from 'ng-azure-maps';
import { environment } from '../../environments/environment';
import { RouterModule, Routes } from '@angular/router';
const routes: Routes = [{ path: "", component: MapComponent }];
@NgModule({
declarations: [MapComponent],
imports: [
CommonModule,
RouterModule.forChild(routes),
AzureMapsModule.forChild({
authOptions: environment.authOptions
})
]
})
export class MapModule { }
AAD and SubscriptionKey authentication are supported.
Please note that all the directives can be used either as html tag or applied to an html element as an attribute tag. For example, the map can be displayed using <azure-map></azure-map>
or <div azure-map></div>
.