diff --git a/index.html b/index.html index fa9111afb12e42b4e712876585e1ecda9c9a4138..d7df347b0c5e36cd184fe586a4c2a8745ece114c 100644 --- a/index.html +++ b/index.html @@ -12,6 +12,9 @@ <!-- Turfjs --> <script src='https://unpkg.com/@turf/turf@6/turf.min.js'></script> + <!-- Coloring the map layers --> + <script src="javascript/colors.js"></script> + </head> <body class="standard"> diff --git a/javascript/colors.js b/javascript/colors.js new file mode 100644 index 0000000000000000000000000000000000000000..84736bd4393eef9b79cdb56dd9806a9db3fbe45b --- /dev/null +++ b/javascript/colors.js @@ -0,0 +1,25 @@ +// Her farges alle lagene i kartet + +var count = 0; + +var colors = [ +"blue", +"red", +"yellow", +"green", +"purple", +"orange", +]; + +function getStyle() { + var myStyle = { + "color": colors[count] + }; + + count++; + if (count == colors.length) { + count = 0; + } + + return myStyle +} diff --git a/javascript/geoJSON.js b/javascript/geoJSON.js index ab174703cc88c1588c73f75d9a0b6b8171ffb759..dc3abf40f19b9e625e9cac8185ad7475e0d797ac 100644 --- a/javascript/geoJSON.js +++ b/javascript/geoJSON.js @@ -69,18 +69,20 @@ var TC = { ] }; -var test1 = L.geoJSON(); -var test2 = L.geoJSON(); +var test1 = L.geoJSON(U, {style: getStyle()}); +var test2 = L.geoJSON(TC, {style: getStyle()}); -test1.addData(U); -test2.addData(TC); +//addMapLayer(test1, U); +//addMapLayer(test2, TC); +//test1.addData(U); +//test2.addData(TC); // Det jeg skal ha med i ferdig versjon: -var Arealdekke = L.geoJSON(); -var Bygg_f = L.geoJSON(); -var Bygg_l = L.geoJSON(); -var Samferdsel = L.geoJSON(); +var Arealdekke = L.geoJSON(null, {style: getStyle()}); +var Bygg_f = L.geoJSON(null, {style: getStyle()}); +var Bygg_l = L.geoJSON(null, {style: getStyle()}); +var Samferdsel = L.geoJSON(null, {style: getStyle()}); fetch("javascript/exampleData/Arealdekke_klippa.geojson").then(function(response) { return response.json();