Populating an array from an AJAX call and returning it to calling function

BurnedBagels

New Member
I am using the \[code\]gmap3\[/code\] extension for the \[code\]Google Maps API\[/code\] and \[code\]jQuery\[/code\].I have a \[code\].gpx\[/code\] file that I read via AJAX and get each coordinate and add it to an array. I then return this array to populate my polyline in my map.In function Test I would do a count of points just before I return it and count is 0.Here is my function that processes the .gpx file to return the coordinates:\[code\]function Test() { var points = []; $.ajax({ type: "GET", url: "gpx/12345.gpx", dataType: "xml", success: function (xml) { $(xml).find("trkpt").each(function () { var lat = $(this).attr("lat"); var lon = $(this).attr("lon"); var p = new google.maps.LatLng(lat, lon); points.push(p); }); } }); return points;}$(document).ready(function () { var points = Test(); var route1Latlng = new google.maps.LatLng(-33.7610590, 18.9616790); $('#map_canvas').gmap3({ map: { options: { center: route1Latlng, zoom: 11 } }, polyline: { options: { path: points, strokeColor: '#FF00AA', strokeOpacity: .7, strokeWeight: 4 } } });});\[/code\]In IE9 the polyline is not drawn, but in FIreFox it draws.
 
Top