diff --git a/index.html b/index.html index 983e2bf6f980ac516382062777bd7ba756c5caab..3d7cc584b81445eb9d17f4603c0a88206866b7ad 100644 --- a/index.html +++ b/index.html @@ -38,7 +38,7 @@ </div> <div id="buttons2" class="box2" style="display: none;"> <p style="width: 32vw;"></p> - <button class="button">TIN</button> + <button class="button" onclick="TIN()">TIN</button> <button class="button" onclick="voronoi()">Voronoi</button> </div> </div> @@ -277,6 +277,7 @@ <script src="javascript/extract.js"></script> <script src="javascript/mapChange.js"></script> <script src="javascript/voronoi.js"></script> + <script src="javascript/tin.js"></script> <!-- Imported js --> <!-- <script src="https://unpkg.com/shpjs@latest/dist/shp.js"></script> --> diff --git a/javascript/mapChange.js b/javascript/mapChange.js index 916c5bb2890d95ec4021a1b254a9a849e6100046..229307115f9e236237be68aa13571f5b654a7d6b 100644 --- a/javascript/mapChange.js +++ b/javascript/mapChange.js @@ -23,6 +23,36 @@ var points = { "name": "NTNU Dragvoll" } }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [10.388918, 63.4203714] + }, + "properties": { + "name": "NTNU Øya" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [10.4347967, 63.4235678] + }, + "properties": { + "name": "NTNU Tyholt" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [10.4143153, 63.433756] + }, + "properties": { + "name": "NTNU Solsiden" + } + }, { "type": "Feature", "geometry": { @@ -32,6 +62,106 @@ var points = { "properties": { "name": "NTNU Moholt" } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [10.4032871, 63.4340888] + }, + "properties": { + "name": "NTNU Olavskvartalet" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [10.4071882, 63.4107064] + }, + "properties": { + "name": "NTNU Lerkendal og Valgrinda" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [10.3861107, 63.4288662] + }, + "properties": { + "name": "NTNU Kalvskinnet" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [10.4540302, 63.4473022] + }, + "properties": { + "name": "NTNU Ringve" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [10.3483128, 63.4415347] + }, + "properties": { + "name": "NTNU Heggdalen" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [10.4492127, 63.4521411] + }, + "properties": { + "name": "NTNU Østmarka" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [10.3981586, 63.4373727] + }, + "properties": { + "name": "NTNU Brattørkaia" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [10.3992594, 63.4152944] + }, + "properties": { + "name": "NTNU Elgeseter" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [10.4837531, 63.4393659] + }, + "properties": { + "name": "NTNU Rotvoll" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Point", + "coordinates": [10.4660445, 63.42338] + }, + "properties": { + "name": "NTNU Tunga" + } } ] }; @@ -92,6 +222,9 @@ function changeMap() { if (isVoronoi) { voronoi(); } + if (isTIN) { + TIN(); + } // Legger til kartlagene som lå i kartet før en byttet kartmodus: while (layersOnMap.length > 0) { diff --git a/javascript/tin.js b/javascript/tin.js new file mode 100644 index 0000000000000000000000000000000000000000..992474dc133444f3df53d697ec457b3d69fd10a3 --- /dev/null +++ b/javascript/tin.js @@ -0,0 +1,16 @@ +// Variabler: + +var isTIN = false // Vises TIN'et i kartet? +// Selve TIN'et: +var TINPolygons = turf.tin(NTNU_points.toGeoJSON()); +var TINGeoJSON = L.geoJSON(TINPolygons, {style: {"color": "orangered"}}); + +function TIN() { + if (isTIN) { + map.removeLayer(TINGeoJSON); + isTIN = false; + } else { + TINGeoJSON.addTo(map); + isTIN = true; + } +}