Polyline no Google Maps com Array Json
Bom pessoal eu queria inserir polyline em meu google maps de a cordo com as coordenadas que são passadas pelo Json, fazendo um array com o jquery, porém não consigo fazer isso :( , segue o link do json:
http://voemercosul.com/v2/index.php/acars/getJson
Código do mapa:
function initialize(){
var latlng = new google.maps.LatLng(0, 23);
var myOptions = {
zoom: 4,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var url = "http://voemercosul.com/v2/index.php/acars/getJson";
var mypath = new Array();
$.getJSON(url, function (data) {
// Parse the Linestring field into an array of LatLngs
$.each(data.bindings, function(index, record) {
line = JSON.parse(record.Linestring);
// Parse the array of LatLngs into Gmap points
for(var i=0; i < line.length; i++){
//Tokenise the coordinates
var coords = (new String(line[i])).split(",");
mypath.push(new google.maps.LatLng(coords[4], coords[5]));
}
var polyline = new google.maps.Polyline({
path: mypath,
strokeColor: '#ff0000',
strokeOpacity: 1.0,
strokeWeight: 3
});
polyline.setMap(map);
});
});
}
google.maps.event.addDomListener(window, 'load', initialize);
Me ajudem pf. Grato :D
Discussão (7)
Carregando comentários...