Hello, I have searched everywhere for the answer, and have been trying to solve this myself for a couple days now.
WHAT I AM DOING: I am trying to create a Route Map for a Virtual Airline (VA). I have 2 XML files that I am dynamically calling; the first retrieves airports for the VA, the second parses just the destinations of that airport. When a user hovers over an airport marker, I have it drawing geodesic polylines from the current airport to the "destination" airports. MY PROBLEM: I have managed to get everything working great. My problem is that when there are more than one polyline drawn, it clears only the first(last) poly that was drawn. If there is just 1 destination, it clears fine. So, I know that it has to do with the way I am parsing the XML, and creating the polyline array. But being a bit new to AS3 and Google Maps API for Flash, I can't quite see what I am doing wrong (actually I am not that good enough yet, either!). Here is a link to the map I have so far: http://chicagoflightsfsx.com/IHeart707/googleTutorial.html This is the last bit I have to do with this map, but just can't seem to nail where I am going wrong. Here is the code I am using (some I have written, and some I have gotten from examples on the net): import com.google.maps.LatLng; import com.google.maps.LatLngBounds; import com.google.maps.controls.ZoomControl; import com.google.maps.controls.PositionControl; import com.google.maps.controls.MapTypeControl; import com.google.maps.InfoWindowOptions; import com.google.maps.Map; import com.google.maps.MapEvent; import com.google.maps.MapMouseEvent; import com.google.maps.MapType; import com.google.maps.overlays.*; import com.google.maps.StyledMapType; import com.google.maps.StyledMapTypeOptions; import com.google.maps.styles.*; // FlashVars embedded in the HTML Object and Parameter tags var paramObj:Object = this.root.loaderInfo.parameters var myKey:String = paramObj.myKey; var myVaid:String = "584";//paramObj.myVaid; // Initiate the google map var map:Map = new Map(); map.key = ""+myKey; map.sensor = "false"; map.setSize(new Point(stage.stageWidth, stage.stageHeight)); map.addEventListener(MapEvent.MAP_READY, onMapReady); this.addChild(map); function onMapReady(event:Event):void { map.setCenter(new LatLng(35.675147, -94.570312), 4, MapType.PHYSICAL_MAP_TYPE); map.addControl(new ZoomControl()); getXml(); } function getXml():void { var airportsXml:URLRequest = new URLRequest("http:// www.vafinancials.com/plugins/app/x_airports.php?id="+myVaid); var xmlLoader:URLLoader = new URLLoader(airportsXml); xmlLoader.addEventListener("complete", readXml); } function readXml(event:Event):void { XML.ignoreWhitespace = true; var airportsXml:XML = new XML(event.target.data); for (var i:Number = 0; i < airportsXml.airport.length(); i++){ var newLat:Number = airportsXml.airport[i].lat; var newLon:Number = airportsXml.airport[i].lon; var latlng:LatLng = new LatLng(airportsXml.airport[i].lat, airportsXml.airport[i].lon); var tip = airportsXml.airport[i].aname; var myTitle:String = airportsXml.airport[i].aname; var myContent:String = airportsXml.airport[i].icao; map.addOverlay(createMarker(latlng, i, tip, myTitle, myContent, newLat, newLon)); } // Add Markers On The Map function createMarker(latlng:LatLng, number:Number, tip, myTitle, myContent, newLat, newLon):Marker { var i:Marker = new Marker(latlng, new MarkerOptions({ strokeStyle: { color: 0xBD7E1B }, fillStyle: { color: 0xBD7E1B, alpha: 0.8 }, label: "", labelFormat: { font: "Trebuchet MS", size: 10, color: 0xFFFFFF, bold: true }, radius: 2.5, hasShadow: true, tooltip: ""+tip }) ); i.addEventListener(MapMouseEvent.CLICK, function(event:MapMouseEvent):void { map.openInfoWindow(event.latLng, new InfoWindowOptions({ titleHTML: ""+myTitle, contentHTML: ""+myContent })); }); i.addEventListener(MapMouseEvent.ROLL_OVER, function(e:MapMouseEvent):void { var icao:String = new String(myContent); var routesXml:URLRequest = new URLRequest("http:// www.vafinancials.com/plugins/app/x_airports_dest.php?id="+myVaid+"&icao="+icao); var xmlLoader:URLLoader = new URLLoader(routesXml); xmlLoader.addEventListener("complete", readXml); function readXml(event:Event):void { XML.ignoreWhitespace = true; var routesXml:XML = new XML(event.target.data); for (var i2:Number = 0; i2 < routesXml.airport.length(); i2++){ var lat:Number = routesXml.airport[i2].lat; var lon:Number = routesXml.airport[i2].lon; var p:Polyline = new Polyline([ new LatLng(newLat, newLon), new LatLng(lat, lon) ], new PolylineOptions({ strokeStyle: new StrokeStyle({ color: 0x1B5ABD, thickness: 1.75, alpha: 0.5}), geodesic: true })) map.addOverlay(p); (trace(getVertexCount())); } i.addEventListener(MapMouseEvent.ROLL_OUT, function(e:MapMouseEvent):void { map.removeOverlay(p); }); } }); return i; } } -- 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.
