looks like you are loading 4 single point "lines" how do you expect a 1 point line to render (you are probably one loop too far in).
On Nov 5, 10:55 am, felix <[email protected]> wrote: > I'm trying to get google maps api to draw a polyline from a json > file. I am using jquery to bring my json file into my html page. My > website ishttp://felixbrun.mine.nu/. Below is the javascript portion > along with the json file that I am using. I just can't figure out how > to make the polyline draw. > > function Pts(){ > > // initial load points > $.getJSON("Transit.json", function(json) { > for (i=0; i<json.length; i++) { > var points = []; > > // Loop through each coordinate pair > for(var j = 0; j < > json[i].coords.length; j++) { > var xy = json[i].coords[j]; > > // Add coordinates to > the array > points.push(new > GLatLng(parseFloat(xy[0]), parseFloat(xy[1]))); > > }; > // Create a new > GPolyline > var polyline = new > GPolyline(points, '#ff0000', 5, 0.7); > > map.addOverlay(polyline); > alert(points); > } > > }) > > }; > > -------------------------------------------------------------------------- > JSON > -------------------------------------------------------------------------- > [ > > {"coords": [[42.31395372878568, -82.91690826416016]]}, > {"coords": [[42.314080666610025, -82.91952610015869]]}, > {"coords": [[42.31417586981029, -82.92227268218994]]}, > {"coords": [[42.296697322651475, -83.06809902191162]]} > > ] -- You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-api?hl=en.
