Make the map center static when map reloads
This commit is contained in:
1 parent
cab7eada1f
commit
79488d75e8
4 files changed
+94
-14
No files matched your search
@@ -5,16 +5,20 @@ using YongeStreet.Services;
|
||||
|
||||
namespace YongeStreet.Controllers;
|
||||
|
||||
public record CityModel(string City, IList<CityRoadLengthStats> CityRoadLengthStats, DateOnly Date);
|
||||
public record MapLocation(double? lon, double? lat, int? zoom);
|
||||
|
||||
public record CityModel(
|
||||
string City,
|
||||
IList<CityRoadLengthStats> CityRoadLengthStats,
|
||||
DateOnly Date,
|
||||
MapLocation mapLocation);
|
||||
|
||||
public record IndexModel(List<CityOverview> Cities);
|
||||
|
||||
public record TmpModel(IList<string> Cities);
|
||||
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly DataService _dataService;
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger, DataService dataService)
|
||||
{
|
||||
@@ -22,11 +26,12 @@ public class HomeController : Controller
|
||||
_dataService = dataService;
|
||||
}
|
||||
|
||||
public IActionResult City(string city, string date)
|
||||
public IActionResult City(string city, string date, double? lon, double? lat, int? zoom)
|
||||
{
|
||||
var cityRoadLengthStats = _dataService.GetCityRoadLengthStats(city);
|
||||
var parsedDate = Util.ParseDateOnly(date) ?? new DateOnly(2025, 1, 1);
|
||||
return View(new CityModel(city, cityRoadLengthStats, parsedDate ));
|
||||
var mapLocation = new MapLocation(lon, lat, zoom);
|
||||
return View(new CityModel(city, cityRoadLengthStats, parsedDate, mapLocation));
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
@@ -35,9 +40,9 @@ public class HomeController : Controller
|
||||
return View(new IndexModel(cities));
|
||||
}
|
||||
|
||||
public IActionResult CityList_Partial(string? search)
|
||||
public IActionResult CityList_Partial(string? search)
|
||||
{
|
||||
var cities = _dataService.GetCityOverview(search??"");
|
||||
var cities = _dataService.GetCityOverview(search ?? "");
|
||||
return View(new IndexModel(cities));
|
||||
}
|
||||
|
||||
@@ -51,4 +56,4 @@ public class HomeController : Controller
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user