I'm working on a development that plots multiple longitude and latitude locations from the SQL SERVER database that load on a map after typing some search data. Below is the screen with the problem that does not load my Google Map, I'm using the GoogleMaps.LocationService API.
MyinitMap()functionisgivingBug,IalreadychangedtheAPIkeytomakesureitcouldbethis,butitwasnottheproblem.
ThefilesI'mworkingonare:
TrackerReport.cs
publicclassRastreadorRelatorio{publicstringPrefixoRastreador{get;set;}publicstringOPM{get;set;}publicstringPrefixoViatura{get;set;}publicstringPlaca{get;set;}publicstringIgnicao{get;set;}publicstringLatitude{get;set;}publicstringLongitude{get;set;}publicDateTimeDataHora{get;set;}publicstringPosicaoGPS{get;set;}}
ReportController.cs
private string MontarInformacoesManutencao(RelatorioViewModel relatorio)
{
if (relatorio.situacao == "7")
{
string opm = "";
string placa = "";
string prefixoViatura = "";
string prefixoRastreador = "";
if (!string.IsNullOrEmpty(relatorio.opm))
{
opm = relatorio.opm;
}
if (!string.IsNullOrEmpty(relatorio.placa))
{
placa = relatorio.placa;
}
if (!string.IsNullOrEmpty(relatorio.prefixoViatura))
{
prefixoViatura = relatorio.prefixoViatura;
}
if (!string.IsNullOrEmpty(relatorio.prefixoRastreador))
{
prefixoRastreador = relatorio.prefixoRastreador;
}
var viaturas = rastreadorDezRepository.GetLstRastreador(Convert.ToInt16(relatorio.situacao), opm, placa, prefixoViatura, prefixoRastreador, relatorio.dtaInicio, relatorio.dtaFim);
string titulo = MontarTituloRelatorio(relatorio.situacao);
html += "<tr><td valign=\"top\" colspan=\"12\"><b> " + titulo
+ "</b></td></tr><br/><tr><td colspan=\"12\" class=\"first\"><table class=\"list-table\">";
var numEvento = 0;
List<RastreadorRelatorio> ListarLatLong = new List<RastreadorRelatorio>();
foreach (var item in viaturas)
{
var ignicao = "";
if (item.Ignicao == "L")
{
ignicao = "Ligado";
}
else
{
ignicao = "Desligado";
}
string Mapear = item.Latitude.ToString() + " " + item.Longitude.ToString();
RastreadorRelatorio PlotarLatLong = new RastreadorRelatorio();
PlotarLatLong.PrefixoViatura = Mapear;
var locationService = new GoogleLocationService();
var point = locationService.GetLatLongFromAddress(Mapear);
PlotarLatLong.Latitude = point.Latitude.ToString();
PlotarLatLong.Latitude = point.Latitude.ToString();
ListarLatLong.Add(PlotarLatLong);
numEvento += 1;
html += "<tr>";
html += "<td valign=\"top\" colspan='12'><b>Número Rastreador </b> " + item.PrefixoRastreador + "</td>";
html += "<td valign=\"top\" colspan='12'><b>OPM </b> " + item.OPM + "</td>";
html += "<td valign=\"top\" colspan='12'><b>Prefixo Viatura </b> " + item.PrefixoViatura + "</td>";
html += "<td valign=\"top\" colspan='12'><b>Placa </b> " + item.Placa + "</td>";
html += "<td valign=\"top\" colspan='12'><b>Ignição </b> " + ignicao + "</td>";
html += "<td valign=\"top\" colspan='12'><b>Latitude </b> " + item.Latitude + "</td>";
html += "<td valign=\"top\" colspan='12'><b>Longitude </b> " + item.Longitude + "</td>";
html += "</tr>";
html += "<tr>";
}
html += "</tr>";
html += "</table></td></tr>";
retorno += html;
string jsonString = JsonSerializer<List<RastreadorRelatorio>>(ListarLatLong);
RegisterArrayDeclaration(jsonString);
RegisterStartupScript(GetType(), Guid.NewGuid().ToString(), "initMap();", true);
}
}