Angular2 component for Baidu map
npm install angular2-baidu-map
import {Component, OnInit} from '@angular/core';
import {BaiduMap, OfflineOptions} from 'angular2-baidu-map';
@Component({
selector: 'map-presentation',
template: `
<h1>Test Baidu-Map<h1>
<baidu-map ak="put your ak here" [options]="opts" [offline]="offlineOpts" (onMapLoaded)="loadMap($event)"></baidu-map>
`,
styles: [`
baidu-map{
width: 500px;
height: 400px;
display: block;
}
`],
directives: [BaiduMap]
})
export class MainApp implements OnInit {
opts: any;
offlineOpts: OfflineOptions;
ngOnInit() {
this.opts = {
center: {
longitude: 121.506191,
latitude: 31.245554
},
zoom: 17,
markers: [{
longitude: 121.506191,
latitude: 31.245554,
title: 'Where',
content: 'Put description here'
}]
};
this.offlineOpts = {
retryInterval: 5000,
txt: 'NO-NETWORK'
};
}
loadMap(e) {
console.log(e);//e here is the instance of BMap.Map
}
}
For more information, see documentation