Oh, I did not see that you are requesting the event.target.data two
times... this is not a mistake, but you don't need to do this. The
mistake actually is in the fact that you are requesting a wrong
hierarchy of xml nodes for your points and thus there are no
polylines.
So instead of casting the event target data a second time, use the
above already created 'polylineXML' XML-object. Your code would be:
public function readXmlTest(event:Event):void
{
var polylinesXML:XML = new XML(event.target.data);
var polylines:XMLList = polylinesXML.polyline;
var polylinesCount:int = polylines.length();
var i:Number;
for (i=0; i < polylinesCount; i++)
{
var polylineXml:XML = polylines[i];
var line:String = polylinex...@line;
var color:String = polylinex...@color;
var latlng:Array = new Array();
var points:XMLList = polylineXml.point;
var pointsCount:int = points.length();
var a:Number;
for (a=0; a < pointsCount; a++)
{
var point:XML = points[a];
latlng.push(new LatLng(poi...@lat,
poi...@lng));
}
var poly:Polyline = new Polyline(latlng);
map.addOverlay(poly);
}
}
You may even shorten this to:
public function readXmlTest(event:Event):void
{
var polylinesXML:XML = new XML(event.target.data);
var polylines:XMLList = polylinesXML.polyline;
for each (polyline:XML in polylines)
{
var line:String = polylinex...@line; << use
this somewhere
var color:String = polylinex...@color; << use this
somewhere
var latlng:Array = new Array();
var points:XMLList = polyline.point;
for each (point:XML in points)
{
latlng.push(new LatLng(poi...@lat,
poi...@lng));
}
map.addOverlay(new Polyline(latlng));
}
}
Greetings, Darek
On 2 Feb., 17:02, AK <[email protected]> wrote:
> Thanks Darek for the fast answer... :-)
>
> I have changed the code.
> Now there´s no error and no duplicate variable definition warning for
> the "i"
> and for the "var latlng:Array = new Array();".
>
> But there are no polylines on my map although he´s reading the xml
> file.
> I have checked this via ff live header...
>
> public function readXmlTest(event:Event):void
> {
> var polylinesXML:XML = new XML(event.target.data);
> var polylines:XMLList = polylinesXML.polyline;
> var polylinesCount:int = polylines.length();
> var i:Number;
> for (i=0; i < polylinesCount; i++)
> {
> var polylineXml:XML = polylines[i];
> var line:String = polylinex...@line;
> var color:String = polylinex...@color;
>
> var latlng:Array = new Array();
>
> var polylineXML:XML = new XML(event.target.data);
> var polyline:XMLList = polylineXML.point;
> var polylineCount:int = polyline.length();
> var a:Number;
> for (a=0; a < polylineCount; a++)
> {
> var pointXml:XML = polyline[a];
> latlng.push(new LatLng(pointx...@lat, pointx...@lng));
> }
> var poly:Polyline = new Polyline(latlng);
> map.addOverlay(poly);
> }
>
> }
>
> I think i need a second function with the options of the polyline to
> show it on the map...
> Hmmmmm...
>
> Greetings, AK
>
> On 1 Feb., 16:52, Darek <[email protected]> wrote:
>
> > It's the "var latlng[i] = ..." ;)
> > You mean latlng.push(new LatLng(pointx...@lat, pointx...@lng));
>
> > Beside this, there will be a "Duplicate variable definition" error
> > because of the i in both for-loops.
> > With these changes the code should be fine.
>
> > Regards, Darek
--
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.