ngx-admin/src/app/pages/maps/components/leafletMaps/leafletMaps.component.ts

34 lines
989 B
TypeScript
Raw Normal View History

2016-05-11 17:38:01 +03:00
import {Component, ViewEncapsulation, ElementRef} from '@angular/core';
import {BaCard} from '../../../../theme/components';
2016-05-02 18:17:54 +03:00
2016-05-17 18:26:49 +03:00
import './leafletMaps.loader';
2016-05-02 18:17:54 +03:00
@Component({
2016-05-03 10:51:59 +03:00
selector: 'leaflet-maps',
2016-05-02 18:17:54 +03:00
pipes: [],
providers: [],
encapsulation: ViewEncapsulation.None,
2016-05-17 18:26:49 +03:00
styles: [require('./leafletMaps.scss')],
2016-05-02 18:17:54 +03:00
template: require('./leafletMaps.html'),
2016-05-17 18:36:40 +03:00
directives: [BaCard],
2016-05-02 18:17:54 +03:00
})
export class LeafletMaps {
constructor(private _elementRef:ElementRef) {
}
ngAfterViewInit() {
2016-05-11 17:38:01 +03:00
let el = this._elementRef.nativeElement.querySelector('.leaflet-maps');
2016-05-02 18:17:54 +03:00
L.Icon.Default.imagePath = 'assets/img/theme/vendor/leaflet';
var map = L.map(el).setView([51.505, -0.09], 13);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.marker([51.5, -0.09]).addTo(map)
.bindPopup('A pretty CSS3 popup.<br> Easily customizable.')
.openPopup();
}
}