Преглед изворни кода

Add maps page, starting on a mechanism to save interesting locations.

Robert Marshall пре 3 година
родитељ
комит
b0c20e02a5

+ 16 - 0
src/Website/Controllers/MapsController.cs

@@ -0,0 +1,16 @@
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Website.Controllers {
+	[Authorize]
+	public class MapsController : Controller {
+		public IActionResult Index() {
+			return View();
+		}
+
+		[HttpPost]
+		public IActionResult CreateMap(string name) {
+			throw new System.NotImplementedException();
+		}
+	}
+}

+ 32 - 0
src/Website/Views/Maps/Index.cshtml

@@ -0,0 +1,32 @@
+
+@{
+	ViewBag.Title = "Maps";
+	Layout = "_Layout";
+}
+
+@section head {
+	<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css"
+	  integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
+	  crossorigin=""/>
+	<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
+	  integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
+	  crossorigin=""></script>
+}
+
+<label>Load map: <select><option>Map</option></select></label>
+
+<div id="map"></div>
+
+<form asp-action="CreateMap">
+	<label>Name: <input type="text" /></label>
+	<button type="submit">Add</button>
+</form>
+
+<script>
+	var map=L.map("map").setView([0,0], 2);
+	L.tileLayer('https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png', {
+        maxZoom: 19,
+		attribution: '&copy; <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a>'
+    }).addTo(map);
+	L.control.scale({imperial: true, metric: true}).addTo(map);
+</script>

+ 1 - 0
src/Website/Views/Shared/_Layout.cshtml

@@ -14,6 +14,7 @@
 		</style>
 	</noscript>
 	<link rel="icon" type="image/png" href="/images/logo.png"/>
+	@await RenderSectionAsync("head", false)
 </head>
 <body>
 <header class="header">

+ 14 - 0
src/Website/wwwroot/css/map.scss

@@ -0,0 +1,14 @@
+#map{
+	height: 80vh;
+	margin: 0 10px;
+
+	.leaflet-control{
+		opacity: 0;
+	}
+
+	&:hover{
+		.leaflet-control{
+			opacity: 1;
+		}
+	}
+}

+ 1 - 0
src/Website/wwwroot/css/style.scss

@@ -3,6 +3,7 @@
 $fa-font-path: "../webfonts";
 @import "../../node_modules/@fortawesome/fontawesome-free/scss/fontawesome.scss";
 @import "../../node_modules/@fortawesome/fontawesome-free/scss/solid.scss";
+@import "map.css";
 
 * {
 	box-sizing: border-box;