I am building an app that given latitude and longitude from a form, creates a database using C# and SQlite, however I searched many things and non of them helped me in my purpose. What I want is, given a database in SQlite (in C#), put a marker in the map using leaflet, this is, given the coordinates in latitude, longitude, put a marker in the map and exibit.
I use the following generated table:
using maps.Models;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace maps.Migrations
{
/// <inheritdoc />
public partial class InitCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Locals",
columns: table => new
{
ID = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
latitude = table.Column<double>(type: "REAL", nullable: false),
longitude = table.Column<double>(type: "REAL", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Locals", x => x.ID);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Locals");
}
}
}
And I want to make the map and put the marker using an script in cshtml as in:
<body>
<div id = "map" style = "width:700px; height:580px"></div>
<script>
var map = L.map('map').setView([51.5, -0.09], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
var seekPlace = L.Control.geocoder().addTo(map);
</script>
</body>
Does anyone know exactly the procedure for doing this task? Observe also that I am using a MVC model at ASP.NET.