Skip to content

Latest commit

 

History

History
83 lines (65 loc) · 1.9 KB

README.md

File metadata and controls

83 lines (65 loc) · 1.9 KB

angular2-baidu-map

NPM version

Angular2 component for Baidu map

Install via npm

npm install angular2-baidu-map

Usage

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

LICENSE

MIT License