Hello Everyone, I have a Route Map that I am working on. This is much like ones you would find on major airline websites, but this is for flight simulation Virtual Airlines (VA). The point is for many different VA's to incorporate a simple, dynamic route map for their airline. I am parsing 2 XML files: One for the Airport Markers, and the other for the Destination polylines to all Airports that the VA flies to from there, when the marker is hovered over (ROLL_OVER); then, consequently is cleared when the mouse is off the marker (ROLL_OUT). When I add new routes, via a 3rd party website, the XML files are instantly updated, and so is the Route Map.
Here is the link for my Map: http://chicagoflightsfsx.com/IHeart707/vaRouteMap.html Everything works great: it dynamically displays the airports, draws geodesic polylines to the destination airports, has the info window, etc, etc... My problem is that if an airport has more than one destination, only the last polyline drawn clears. For airports that have a single destination, it works like a charm. But for the life of me, I can not figure out why I can't get ALL the polylines to clear. If someone could look at my code, and tell me/hint where I am going wrong, I would SO appreciate it! I have been trying for days now. Google Maps API for Flash Actionscript 3 Code: 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 = "17898";//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: ""+myContent+" - "+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); } i.addEventListener(MapMouseEvent.ROLL_OUT, function(e:MapMouseEvent):void { map.removeOverlay(p); }); } }); return i; } } Thank you in advanced for any help/pointers! Jon -- You received this message because you are subscribed to the Google Groups "Google Maps API For Flash" group. To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-api-for-flash/-/Q3Ork9moEbIJ. 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.
