Uploaded my source code for the FlightAware app shown in my last entry – source | ZIP. I’ve only done a little documentation; aka, on the header of each class. Keep in mind I wrote this in 20 blazing fast hours with no sleep, so ignore quality & practices. The only thing you should really care about are 2 things.
The first is that the YahooMap AS3 component is just that; an AS3 component. It is NOT a Flex component. This means, all you Flasherz can use the mofo in Flash.
Haven’t tried myself, but I KNOW it works in a pure AS3 project. Josh has it covered. In my example, I merely wrap it in a UIComponent so I can use it in MXML.
Second is the AirportsMap.mxml (com.jxl.flightaware.views.mainviews.airportsviews). This is the guy who uses the UIYahooMap component and draws markers into it based on dynamic data. He can either loop through an ArrayCollection that contains AirportVO’s or loop through an ArrayCollection that has a Flight’s tracking data. It’ll plot both with custom markers I created in Flash.
Although there is an IMarker interface, you’re better off either extending SimpleMarker. The IMarker interface is missing some stuff that you need. If you extend Marker, you won’t get anything visual on the map.
The are a few cool things about Markers. The first is that they take latitude and longitude values instead of x and y. This is done so when you add a marker to the YahooMap component, it’ll position it at the correct place. Debugging hint: Don’t see your marker? Swap the lat and lon values… happened to me all the time the Flex 1.5 component, and is happening again in this one. My fault.
The added feature is that when you zoom in and out of the map, the markers are all repositioned for you to indicate the appropriate distance. Finally, just like ESRI’s, you can specify at what zoom distance the markers should appear since some are only relevant at really zoomed in our really zoomed out distances.
Lastly, the markers are actually in a child clip within the map component. Therefore, when you drag the map around, so to do your markers drag. You CAN also make your markers into interactive buttons and/or widgets. Just ensure if you dispatch any events that they bubble.
Keep in mind I have an older (read: buggy) SWC in my source. If you want to do serious development, go download an updated SWC from Yahoo.
There are other features of markers, but those are my favorites. Also, there are a lot more features as a whole with the component; I’ve just covered one small portion. Go learn more if you’re so inclined.
Once again, great job Yahoo team!