Hi, The Polyline contructor takes an Array of LatLng objects, but you are passing in an array of Markers!
See: http://code.google.com/apis/maps/documentation/flash/reference.html#Polyline Try somthing like this: for each (var truckXML:XML in truckXList) { var locations:XMLList = truckXML.locations.location; var pointsArr:Array = new Array(); // Modified this line, changed name to pointsArr for each(var location:XML in locations) { var lat = Number(location.latitude); var lng = Number(location.longitude) var latLng:LatLng = new LatLng(lat,lng); var locationId:String = location.id; var colorInt:uint; if (location.zipcode == 'XXXXX') { colorInt = 0x40aff6; locationId = locationId ; } else { colorInt = 0x40aff6; } var options:MarkerOptions = new MarkerOptions({ fillStyle: { color: colorInt,alpha: 0.8},toolTip : locationId }); options.label = locationId; options.tooltip = locationId; var marker:Marker = new Marker(latLng,options); map.addOverlay(marker); pointsArr.push(latLng); // Modified this line to use points array } // Modified next line to use points array in contructor var polyline:Polyline = new Polyline (pointsArr, new PolylineOptions({ strokeStyle: {color: 0x553344,alpha: 0.8}})); map.addOverlay( polyline) } Hope this helps! James On Jan 2, 1:29 am, Peeyush <[email protected]> wrote: > Hello, > > I am trying to plot a polyline on a map from an array of latlng > objects, where i extract lat lng values from an xmllist. > > The code snippet is below - > > for each (var truckXML:XML in truckXList) > { > var locations:XMLList = > truckXML.locations.location; > var markerArr:Array = new Array(); > for each(var location:XML in > locations) > { > var lat = > Number(location.latitude); > var lng = > Number(location.longitude) > var latLng:LatLng = new > LatLng(lat,lng); > var locationId:String = > location.id; > var colorInt:uint; > if( location.zipcode == > 'XXXXX') > { > colorInt = 0x40aff6; > locationId = > locationId ; > } > else > { > colorInt = 0x40aff6; > } > var options:MarkerOptions = > new MarkerOptions({ fillStyle: { > color: colorInt,alpha: 0.8},toolTip : > locationId }); > options.label = locationId; > options.tooltip = locationId; > var marker:Marker = new > Marker(latLng,options); > map.addOverlay(marker); > markerArr.push(marker); > } > -- var polyline:Polyline = new Polyline > (markerArr, > new PolylineOptions({ strokeStyle: {color: > 0x553344,alpha: > 0.8}})); > map.addOverlay( polyline); > } > } > > I am able to add the markers easily but for the polyline, It gives an > error each time as > > ReferenceError: Error #1069: Property lat not found on > com.google.maps.overlays.Marker and there is no default value. > at com.google.maps::LatLng$/fromObject() > at com.google.maps.wrappers::Wrapper/wrapLatLng() > at com.google.maps.wrappers::Wrapper/wrapLatLngArray() > at com.google.maps.wrappers::IMapsFactoryWrapper/createPolyline() > at com.google.maps.overlays::Polyline() > at testGoogleMaps/plotRoutes()[C:\Project\Aldor\MapTest\src > \testGoogleMaps.mxml:98] > at testGoogleMaps/onXMLLoadHandler()[C:\Project\Aldor\MapTest\src > \testGoogleMaps.mxml:34] > at flash.events::EventDispatcher/dispatchEventFunction() > at flash.events::EventDispatcher/dispatchEvent() > at flash.net::URLLoader/onComplete() > > My environment flex sdk 2.0.1 hotfix 3. > > Am I doing something wrong? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API For Flash" 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-for-flash?hl=en -~----------~----~----~----~------~----~------~--~---
