I am trying to utilize your heat map feature to track vehicle history. I have your example working, but am struggling to connect with my live data.
I have a sql table name UC_FileGPS with the following columns:
File_ID, Timestamp, Latitude, Longitude, VehID
I am trying to get a heatmap for a single File_ID (which can have many rows of data).
I think I have the pieces, but haven't been able to connect them properly yet. My main question is around the following code:
I have to put the full path to the sql table or else I get errors about data types not matching. But putting in the code I have listed, I get a null reference error. Any help would be greatly appreciated!
My Controller looks like this:
public ActionResult FileDetails(int? id)
{
if (id == null)
{
Warning("No file selected. Try again.");
return RedirectToAction("Index");
}
var file = context.UC_Files.Find(id);
if (file == null)
{
Warning("File not found.", true);
return RedirectToAction("Index");
}
var fileGPS = new FileGPSModel
{
FileInformation = file,
UcInformation = context.UC_IDs
.Where(u => u.UC_ID == file.UC_ID)
.FirstOrDefault(),
gpsData = context.UC_FileGPS
.Where(f => f.File_ID == file.ID)
.ToList()
};
return View(fileGPS);
}
My Model looks like this:
public class FileGPSModel
{
public UC_IDs UcInformation { get; set; }
public UC_Files FileInformation { get; set; }
public List gpsData { get; set; }
}
My View looks like this:
Forgive me, I am new to MVC.
I am trying to utilize your heat map feature to track vehicle history. I have your example working, but am struggling to connect with my live data.
I have a sql table name UC_FileGPS with the following columns: File_ID, Timestamp, Latitude, Longitude, VehID
I am trying to get a heatmap for a single File_ID (which can have many rows of data). I think I have the pieces, but haven't been able to connect them properly yet. My main question is around the following code:
I have to put the full path to the sql table or else I get errors about data types not matching. But putting in the code I have listed, I get a null reference error. Any help would be greatly appreciated!
My Controller looks like this: public ActionResult FileDetails(int? id) { if (id == null) { Warning("No file selected. Try again."); return RedirectToAction("Index"); }
My Model looks like this: public class FileGPSModel { public UC_IDs UcInformation { get; set; } public UC_Files FileInformation { get; set; } public List gpsData { get; set; }
}
My View looks like this:
@if (Model.gpsData != null) { @(Html.GoogleMap() .Name("map") .Height(600) .ApiKey(ViewData["mapKey"].ToString()) .Center(c => c.Latitude(Model.FileInformation.Lat) .Longitude(Model.FileInformation.Lon)) .MapTypeId(MapType.Satellite) .Zoom(13) .Layers(layer => layer.AddHeatmapLayer() .Dissipating(true) .MaxIntensity(0) .Radius(0) .BindTo<'MyDatabasePath'.UC_FileGPS, HeatmapLayer> (Model.gpsData, mappings => mappings.For<'MyDatabasePath'.UC_FileGPS> (binding => binding.ItemDataBound ( (heatmap, gpsData) => { heatmap.AddPoint(new Location(gpsData.Latitude, gpsData.Longitude)); } ) ) ) ) ) }