Added "this is you" marker
authorJulie Hill Roa <julie.hill.roa@gmail.com>
Mon, 16 Nov 2015 06:58:36 +0000 (07:58 +0100)
committerJulie Hill Roa <julie.hill.roa@gmail.com>
Mon, 16 Nov 2015 06:58:36 +0000 (07:58 +0100)
src/components/map/map.ts

index b926e92..c1421d7 100644 (file)
@@ -1,4 +1,5 @@
-import {Component, CORE_DIRECTIVES} from 'angular2/angular2';
+import {Component, CORE_DIRECTIVES,} from 'angular2/angular2';
+import {Headers, Http} from 'angular2/http';
 
 
 @Component({
@@ -9,13 +10,48 @@ import {Component, CORE_DIRECTIVES} from 'angular2/angular2';
 
 
 export class Map {
-    constructor(){
+    result: Object;
+    map: Object;
+    constructor(http: Http){
         this.initMap();
+
+        var authHeader = new Headers();
+        authHeader.append('Authorization', 'Basic YWRtaW46ZGlzdHJpY3Q=');
+        this.result = {organisationUnits:[]};
+       // http.get(dhisAPI+'/api/organisationUnits?paging=false', {headers: authHeader})
+        http.get('http://mydhis.com:8082/api/organisationUnits?paging=false', {headers: authHeader})
+            .map(res => res.json()).subscribe(
+            res => this.result = res,
+            error => this.logError(error)
+        );
     }
 
-    initMap(){
-        let map = new google.maps.Map(document.getElementById("map"),
-            {center:{lat:59,lng:11},zoom:12});
+
+    initMap() {
+        this.map = new google.maps.Map(document.getElementById("map"),
+            {center: {lat: 59, lng: 11}, zoom: 12});
+
+        let marker = new google.maps.Marker({
+            position: {lat: 59, lng: 11},
+            map: this.map,
+            title: 'This is YOU!'
+        });
+
+        let infowindow = new google.maps.InfoWindow({
+            content: "This is You"
+        });
+
+        marker.addListener('click', function () {
+            infowindow.open(this.map, marker);
+        });
+
+        //Other map functions
+        
+    }
+
+    logError(error) {
+        console.error(error);
+
     }
 
 }