styled
authorJulie Hill Roa <julie.hill.roa@gmail.com>
Thu, 3 Dec 2015 11:48:54 +0000 (12:48 +0100)
committerJulie Hill Roa <julie.hill.roa@gmail.com>
Thu, 3 Dec 2015 11:48:54 +0000 (12:48 +0100)
src/components/map/map.ts

index c2e8872..f93be3b 100644 (file)
@@ -19,6 +19,7 @@ export class Map {
     parent:Object;
     currentPos:Object;
     uprunned:boolean;
+    // COLORS:Object;
 
     constructor(http:Http) {
         this.newactive = new EventEmitter();
@@ -32,6 +33,7 @@ export class Map {
         this.parent = null;
         this.currentPos = null;
         this.uprunned = false;
+        // this.COLORS = {'red','brown',',yellow','green',',pink','purple','gray','black'};
 
     }
 
@@ -161,15 +163,35 @@ export class Map {
                 "properties": {
                     "name": item.name,
                     "id": item.id,
-                    "color": "yellow",
+                    "color": "gray",
+                    "icon": null
                 }
             };
+
             if (unit.geometry.type == 'Point') {
-                //ToDO: add en style på markeren !
+                unit.properties.icon = {
+                    path: google.maps.SymbolPath.CIRCLE,
+                    scale: 3
+                };
 
             }
-
+            console.log("her er iden: " +unit.properties.id);
             this.map.data.addGeoJson(unit);
+            this.map.data.setStyle(function(feature) {
+                let color = 'gray';
+                let icon;
+                if (feature.getProperty('icon')!== null) {
+                   icon = feature.getProperty('icon');
+                }
+                color = feature.getProperty('color');
+                return /** @type {google.maps.Data.StyleOptions} */({
+                    fillColor: color,
+                    strokeColor: color,
+                    strokeWeight: 2,
+                    icon: icon
+                });
+            });
+
 
             this.map.data.addListener('click', function (event) {
 
@@ -192,6 +214,7 @@ export class Map {
                     let id = event.feature.O.id;
                     instance.setParent(id);
 
+
                     instance.map.data.forEach(function (feature) {
                         if (!(feature.O.id == id && instance.LEVEL == 3)) {
                             instance.map.data.remove(feature);
@@ -256,7 +279,8 @@ export class Map {
                     }
                 }
             });
-        } else {
+        }
+        else {
             // ToDO:
             console.log("fiks meg! gi warning på topp av kart");
         }