Added "this is you" marker
[u/erikhf/frm.git] / src / components / map / map.ts
CommitLineData
a2d7d6b4
JHR
1import {Component, CORE_DIRECTIVES,} from 'angular2/angular2';
2import {Headers, Http} from 'angular2/http';
cb2c4ba8 3
1e6ce2f5 4
cb2c4ba8 5@Component({
28765058 6 selector: 'mou-map',
cb2c4ba8 7 directives: [CORE_DIRECTIVES],
28765058 8 templateUrl: './components/map/map.html'
cb2c4ba8
JHR
9})
10
11
28765058 12export class Map {
a2d7d6b4
JHR
13 result: Object;
14 map: Object;
15 constructor(http: Http){
1e6ce2f5 16 this.initMap();
a2d7d6b4
JHR
17
18 var authHeader = new Headers();
19 authHeader.append('Authorization', 'Basic YWRtaW46ZGlzdHJpY3Q=');
20 this.result = {organisationUnits:[]};
21 // http.get(dhisAPI+'/api/organisationUnits?paging=false', {headers: authHeader})
22 http.get('http://mydhis.com:8082/api/organisationUnits?paging=false', {headers: authHeader})
23 .map(res => res.json()).subscribe(
24 res => this.result = res,
25 error => this.logError(error)
26 );
1e6ce2f5
EHF
27 }
28
a2d7d6b4
JHR
29
30 initMap() {
31 this.map = new google.maps.Map(document.getElementById("map"),
32 {center: {lat: 59, lng: 11}, zoom: 12});
33
34 let marker = new google.maps.Marker({
35 position: {lat: 59, lng: 11},
36 map: this.map,
37 title: 'This is YOU!'
38 });
39
40 let infowindow = new google.maps.InfoWindow({
41 content: "This is You"
42 });
43
44 marker.addListener('click', function () {
45 infowindow.open(this.map, marker);
46 });
47
48 //Other map functions
cdcaf46c 49
a2d7d6b4
JHR
50 }
51
52 logError(error) {
53 console.error(error);
54
cb2c4ba8 55 }
28765058 56
cb2c4ba8 57}