I need to make a query in a API (JavaScript) method of google maps , however by controller
, is it possible?
I have a ajax
request that assembles a grid and inside it I make a query in the dbo.Atlas
table by setting latitude and longitude to return the address, but this table does not have all the address registers and in this case, procedure in addition to returning on the screen, also save in the database, so next time have that 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;
}