<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="handleCreationComplete();"
viewSourceURL="srcview/index.html">
<mx:UIComponent id="mapContainer" width="100%" height="100%"/>
<mx:Script>
<![CDATA[
import com.yahoo.maps.api.markers.SimpleMarker;
import com.yahoo.maps.api.core.location.LatLon;
import com.yahoo.maps.api.core.location.BoundingBox;
import com.yahoo.maps.api.YahooMapEvent;
import com.yahoo.maps.api.YahooMap;
private var _yahooMap:YahooMap;
private function handleCreationComplete():void
{
var appid:String = Application.application.parameters.appid;
_yahooMap = new YahooMap();
_yahooMap.addEventListener(YahooMapEvent.MAP_INITIALIZE, handleMapInitialize);
_yahooMap.init(appid, mapContainer.width, mapContainer.height);
_yahooMap.addPanControl();
_yahooMap.addZoomWidget();
mapContainer.addChild(_yahooMap);
}
private function handleMapInitialize(event:YahooMapEvent):void
{
_yahooMap.zoomLevel = 13;
_yahooMap.centerLatLon = new LatLon(37.5, -122.14);
var bounds:BoundingBox = _yahooMap.getMapBounds();
var southwest:LatLon = bounds.southwest;
var northeast:LatLon = bounds.northeast;
var lonSpan:Number = northeast.lon - southwest.lon;
var latSpan:Number = northeast.lat - southwest.lat;
for (var i:int = 0; i < 1000; i++)
{
var latlon:LatLon = new LatLon(southwest.lat + latSpan * Math.random(), southwest.lon + lonSpan * Math.random());
var marker:SimpleMarker = new SimpleMarker();
marker.latlon = latlon;
marker.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
marker.addEventListener(Event.REMOVED_FROM_STAGE, onRemoved);
_yahooMap.markerManager.addMarker(marker);
}
}
private function onAddedToStage( event:Event):void
{
trace(event.type, event.target);
}
private function onRemoved( event:Event):void
{
trace(event.type, event.target);
}
]]>
</mx:Script>
</mx:Application>