Thanks Darek,

it works perfectly...

Here is the final code for everyone who want´s to read polylines from
XML:

getPolyline();

public function getPolyline():void
{
        var xmlString:URLRequest = new URLRequest("polyline.php");
        var xmlLoader:URLLoader = new URLLoader(xmlString);
        xmlLoader.addEventListener("complete", readXmlPolyline);
}

public function readXmlPolyline(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 color:Number = 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);
            var options:PolylineOptions = new
PolylineOptions({strokeStyle:{color: color, thickness: 7, alpha:
1.0}});
            poly.setOptions(options);
            map.addOverlay(poly);
        }
}

Greetings AK

On 3 Feb., 14:38, Darek <[email protected]> wrote:
> 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

-- 
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.

Reply via email to