//Set the URL where the xml file is. var xmlURL = "http://chnm.gmu.edu/1989/maps/xml.php"; //Import Yahoo map tools import com.yahoo.maps.LatLon; import com.yahoo.maps.markers.CustomPOIMarker; import com.yahoo.maps.tools.PanTool; import com.yahoo.maps.widgets.*; //Create a listener associated with the instance of the Yahoo map component. // Set the map to pull down the yahoo map and get the setting/changes from // the onMap function. euroMap.addEventListener(com.yahoo.maps.api.flash.YahooMap.EVENT_INITIALIZE, onMap); //This will add a zoom tool and set it as closed by default var zoomer:NavigatorWidget = new NavigatorWidget("closed"); //The onMap function adds the tools, settings, and markers to the map. function onMap(eventData) { //create a new PanTool and name it pantool var pantool:PanTool = new PanTool(); //tell the instance of the map to use the new PanTool called pantool euroMap.addTool(pantool, true); //Add the Navigator widget euroMap.addWidget(zoomer); //Create a variable called xmlData of the type XML var locations_xml:XML = new XML(); //igore white space locations_xml.ignoreWhite = true; //when the xml file is loaded, do the fuction within locations_xml.onLoad = function(success){ //if the xml file loaded successfully run the function addMarkers if (success) addMarkers(this); }; //then actually load the xml file. locations_xml.load(xmlURL); /******************************************* * Used this for testing, you don't really need it. I was thinking of using * this in the future to display the lat and long to the user. //Get the center of the map and store them in the variable called points. var points = euroMap.getCenter(); //trace("before convert" + points); //swap the points, so long->long and lat->lat convert(points); //trace(points); ******************************************/ } //This is the function that adds the markers to the map. function addMarkers(xml:XML):Void { //the addresses variable holds the path to the right xml element. //firstChild is the and childNodes is an array of the tags var addresses = xml.firstChild.childNodes; for(var i=0; i then the second and so on for all of them. address = addresses[i]; /*************************************************************** * MarkerData is the object that holds the info for each marker. * index: is the text that shows up on the marker (usually just A or * what have you. you could use the variable i to show an * incremented number (each marker has it's own number). * title: sets the title of the marker and corresponds to the title * parameter in the location tags in the xml file. * description: is the larger text. It corresponds with the description * parameter in the location tag in the xml field. * markerColor: sets the color of the marker, duh :) It's the border * color, and the color when not expanded. * strokeColor: is the background. ***************************************************************/ var MarkerData:Object = {index: '\'89', title:address.attributes.info, description:address.attributes.description, markerColor:0xcc0000, strokeColor:0xceccc7}; /**************************************************************** * This actually adds the address to the map using the custom point of * interest style of marker (you can use your own style if you like. * the address.attributes.loc grabs the latitude and longitude from * the loc="" part of the location tag in the xml file. MarkerData * is the stuff we just set above. ****************************************************************/ euroMap.addMarkerByAddress(CustomPOIMarker, address.attributes.loc, MarkerData); } }