介绍
利用Angular模块封装的QQ地图API
安装
npm install ng-qqmap --save
使用
app.module.ts
import { NgQQMapModule } from 'ng-qqmap';
@NgModule({
imports: [
...
NgQQMapModule.forRoot('你的KEY'),
],
API
范例
import { Component, ViewChild, AfterViewInit } from '@angular/core';
import { NgQQMap } from 'ng-qqmap';
@Component({
selector: 'qq-map-component',
template: `<div #container style="width:500px;height:300px;"></div>
<button (click)="map()">Creaete</button>`,
})
export class QQMapComponent implements AfterViewInit {
constructor(
private qqMap: NgQQMap
) {}
@ViewChild( 'container' ) container:any;
ngAfterViewInit() {
let map = this.qqMap.Map( this.container.nativeElement );
console.log( map );
}
}