Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Elnata COsta

Polylin google maps com json

Recommended Posts

Olá pessoal, eu preciso da ajuda de vocês pra inserir o Polylin no meu mapa, eu tenho o seguinte código:

			
    var qtd;
    var retorno;

     $.getJSON('http://voemercosul.com/v2/action.php/acars/trackAirplane', function(data){
            this.qtd = data.bindings.length;
            this.retorno = '';
 
            for (i = 0; i < this.qtd; i++){
               /* this.retorno += 'ID: ' + data.usuarios[i].id + '<br />';
                this.retorno += 'Nome: ' + data.usuarios[i].nome + ' - ';
                this.retorno += 'Cidade: ' + data.usuarios[i].cidade + '<br /><br />';*/
                /*SÃO ESSAS AS VARIÁVEIS QUE EU GOSTARIA DE INSERI NO POLYLIN DO MAPA*/
                this.retornolat = data.bindings.latitude;
                this.retornolon = data.bindings.longitude;
            }
            
            //flightPlanCoordinates2[i] = new google.maps.LatLng(this.retornolat, this.retornolon);
           //alert(flightPlanCoordinates2[i]);
            
        });
        
        
        // Objeto.
       var obj = new json();
      obj.resgatarValores();


var flightPlanCoordinates = [

/*EU GOSTARIA DE INSERIR OS VAROES RETORNADOS DO JSON AQUI MAS NÃO CONSIGO ME AJUDEM COM ISSO POR FAVOR*/

    //new google.maps.LatLng(37.772323, -122.214897),
    //new google.maps.LatLng(21.291982, -157.821856),
    //new google.maps.LatLng(-18.142599, 178.431),
    //new google.maps.LatLng(-27.46758, 153.027892)
  ];


flightPath2 = new google.maps.Polyline({
				path: flightPlanCoordinates2,
				strokeColor: "#04B431", strokeOpacity: 1.0, strokeWeight: 2
			});
			flightPath2.setMap(map);
			flightPath = new google.maps.Polyline({
				path: path,
				strokeColor: "#FF0000", strokeOpacity: 1.0, strokeWeight: 2
			});
			
			map.fitBounds(focus_bounds); 
			flightPath2.setMap(map);




		});

Então pessoal, eu queria inserir a latitude e a longitude que recebo do json no polylin do mapa. Alguem me ajude pf.. :upset:

Compartilhar este post


Link para o post
Compartilhar em outros sites

 

Já vi isso mano, eu não estou tendo problemas com o polyline em si, ele eu consigo fazer, o que eu não estou conseguindo fazer é pegar os dados do json, fazer um for e inserir dentro de "new maps.google.LatLng(lat, lng);

 

Eu fiz algumas modificações mas mesmo assim não funcion, olha só como ficou meu código:

 var qtd;
    var retorno;
   
    
    var pid = this.flightdetails.pilotid;
    var numvoo = this.flightdetails.flightnum;

     $.getJSON('http://voemercosul.com/v2/action.php/acars/trackAirplane?&pid='+ pid +'&flgnum='+ numvoo +'', function(data){
            this.qtd = data.bindings.length;
            this.retorno = '';
 
            for (i = 0; i < this.qtd; i++){
                
                
                this.retorno += 'new google.maps.LatLng(' + data.bindings[i].latitude + ', ';
                this.retorno += '' + data.bindings[i].longitude + '), ';
              
                               

            }
             alert(this.retorno);

  });
  
  
  var flightPlanCoordinates2 = [
       this.retorno;    
  ];
  var flightPath2 = new google.maps.Polyline({
    path: flightPlanCoordinates2,
    geodesic: true,
    strokeColor: '#FF0000',
    strokeOpacity: 1.0,
    strokeWeight: 2
  });

  flightPath2.setMap(map);

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.