-1
I need to make a query on a method of API (Javascript) of google maps, however by controller
, it is possible ?
I have a requisition ajax
that mounts a grid and within it I make a query in the table dbo.Atlas
setting latitude and longitude to return the address, but this table does not have all the registration addresses and in this case, would need to perform this procedure in addition to return on the screen, also save in the database, so next time have this record in the table.
Codes:
public ActionResult ListaPosicoes(string pocsag)
{
dalOperador dalOper = new dalOperador();
List<modOperadorDashLatLng> listaPosMapa = new List<modOperadorDashLatLng>();
listaPosMapa = dalOper.pubEventosProcessadosDashMapa(pocsag);
dalAtlasEndereco dalAtlas = new dalAtlasEndereco();
foreach (var evento in listaPosMapa)
{
if (evento.latitude != 0 && evento.longitude != 0)
{
evento.endereco = dalAtlas.pubTrasformaLatLongEndereco(evento.latitude.ToString(), evento.longitude.ToString());
if (string.IsNullOrEmpty(evento.endereco))// caso não exista na tabela dbo.Atlas
{
evento.endereco = ""; // Endereço que deveria retornar na API do google.Maps passando como parametros a latitude e longitude
//Inserir na tabela dbo.Atlas passando endereço, latitude e longitude.
}
}
else
{
evento.endereco = "Não válido";
}
}
var pontosMapa = Json(listaPosMapa, JsonRequestBehavior.AllowGet);
pontosMapa.MaxJsonLength = int.MaxValue;
return pontosMapa;
}
Use Httpclient to request
– Leandro Angelo