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

27 lines
708 B
TypeScript
Raw Normal View History

2016-05-17 18:26:49 +03:00
import {Component, ElementRef} from '@angular/core';
import * as GoogleMapsLoader from 'google-maps';
2016-05-02 16:55:58 +03:00
@Component({
selector: 'google-maps',
styleUrls: ['./googleMaps.scss'],
templateUrl: './googleMaps.html',
2016-05-02 16:55:58 +03:00
})
export class GoogleMaps {
2016-05-02 17:43:45 +03:00
constructor(private _elementRef:ElementRef) {
2016-05-02 16:55:58 +03:00
}
2016-05-02 17:43:45 +03:00
ngAfterViewInit() {
2016-05-11 17:38:01 +03:00
let el = this._elementRef.nativeElement.querySelector('.google-maps');
2016-05-02 18:17:54 +03:00
2016-05-06 19:48:48 +03:00
// TODO: do not load this each time as we already have the library after first attempt
2016-05-02 17:43:45 +03:00
GoogleMapsLoader.load((google) => {
2016-05-02 18:17:54 +03:00
new google.maps.Map(el, {
2016-05-02 17:43:45 +03:00
center: new google.maps.LatLng(44.5403, -78.5463),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
});
}
2016-05-02 16:55:58 +03:00
}