Какие части кода мне нужно изменить, чтобы он работал на моей стороне?
Контроллер:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using WebApplication1.Models;
namespace WebApplication1.Controllers
{
public class MapsController : Controller
{
private test2Entities db = new test2Entities();
// GET: Maps
public ActionResult Index()
{
return View(db.Maps.ToList());
}
#region [Map]
[HttpPost]
public JsonResult GetMap()
{
var data1 = Map();
return Json(data1, JsonRequestBehavior.AllowGet);
}
public IEnumerable Map()
{
return (from p in db.Maps
select new
{
Name = p.Name,
Latitude = p.Latitude,
Longitude = p.Longitude,
Location = p.Location,
Description = p.Description,
Id = p.Id
}).ToList()
.Select(res => new Map
{
Name = res.Name,
Latitude = res.Latitude,
Longitude = res.Longitude,
Location = res.Location,
Description = res.Description,
Id = res.Id
});
}
#endregion
}
}
Просмотр:
@model IEnumerable
@{
Layout = null;
}
$(document).ready(function () {
var map = L.map('map', {
center: [10.1102278, 77.8958904],
minZoom: 4,
zoom: 6
});
$.ajax({
type: "POST",
url: '/Maps/GetMap',
success: function (data) {
var result = JSON.stringify(data);
for (var i = 0; i < result.length; ++i) {
var popup ='Name: '+ data.Name + '
Latitude: ' + data.Latitude + '
Longitude: ' + data.Longitude+ '
Location: ' + data.Location;
L.marker([data.Latitude, data.Longitude])
.bindPopup(popup)
.addTo(map);
}
},
error: function (xhr) {
console.log(xhr.responseText);
alert("Error has occurred..");
}
});
L.tileLayer('http://{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors | Tiles Courtesy of MapQuest

',
subdomains: ['otile1', 'otile2', 'otile3', 'otile4']
}).addTo(map);
});
Подробнее здесь: https://stackoverflow.com/questions/627 ... flet-map-i