<?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:Label text="{_currentEvent}" fontSize="14" fontWeight="bold" id="eventLabel" right="10" color="#F8F8F8" textAlign="left" left="10" top="5" height="23"/>
<mx:Panel id="panel" title="Yahoo! Maps - Map Events Example" top="30" left="5" bottom="5" right="5">
<mx:UIComponent id="mapContainer" width="100%" height="100%"/>
</mx:Panel>
<mx:Script>
<![CDATA[
import com.yahoo.maps.api.YahooMap;
import com.yahoo.maps.api.YahooMapEvent;
import com.yahoo.maps.api.core.location.Address;
import com.yahoo.maps.api.core.location.LatLon;
import com.yahoo.maps.webservices.geocoder.GeocoderResult;
import com.yahoo.maps.webservices.geocoder.events.GeocoderEvent;
import mx.events.ResizeEvent;
private var _yahooMap:YahooMap;
[Bindable] private var _currentEvent:String;
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);
mapContainer.addChild(_yahooMap);
mapContainer.addEventListener(ResizeEvent.RESIZE, handleContainerResize);
_yahooMap.addPanControl();
_yahooMap.addZoomWidget();
_yahooMap.addTypeWidget();
}
private function handleMapInitialize(event:YahooMapEvent):void
{
_currentEvent = event.type;
_yahooMap.zoomLevel = 5;
_yahooMap.centerLatLon = new LatLon(47.60350,-122.3294);
_yahooMap.addEventListener(YahooMapEvent.MAP_CLICK, handleMapClick);
_yahooMap.addEventListener(YahooMapEvent.MAP_DOUBLE_CLICK, handleMapDoubleClick);
_yahooMap.addEventListener(YahooMapEvent.MAP_MOVE, handleMapMove);
_yahooMap.addEventListener(YahooMapEvent.MAP_TYPE_CHANGED, handleMapTypeChange);
_yahooMap.addEventListener(YahooMapEvent.MAP_ZOOM, handleMapZoom);
_yahooMap.addEventListener(YahooMapEvent.MAP_DRAG_START, handleMapDragStart);
_yahooMap.addEventListener(YahooMapEvent.MAP_DRAG_STOP, handleMapDragStop);
}
private function handleMapDoubleClick(event:YahooMapEvent):void
{
_currentEvent = event.type + " latlon: " + event.data.latlon;
}
private function handleMapClick(event:YahooMapEvent):void
{
_currentEvent = event.type + " latlon: " + event.data.latlon;
}
private function handleMapMove(event:YahooMapEvent):void
{
_currentEvent = event.type + " centerLatLon: " + _yahooMap.centerLatLon.toString();
}
private function handleMapTypeChange(event:YahooMapEvent):void
{
_currentEvent = event.type + " mapType: " + _yahooMap.mapType;
}
private function handleMapZoom(event:YahooMapEvent):void
{
_currentEvent = event.type + " mapZoom: " + _yahooMap.zoomLevel;
}
private function handleMapDragStart(event:YahooMapEvent):void
{
_currentEvent = event.type + " centerLatLon: " + _yahooMap.centerLatLon.toString();
}
private function handleMapDragStop(event:YahooMapEvent):void
{
_currentEvent = event.type + " centerLatLon: " + _yahooMap.centerLatLon.toString();
}
private function handleContainerResize(event:ResizeEvent):void
{
_yahooMap.setSize(mapContainer.width,mapContainer.height);
}
]]>
</mx:Script>
</mx:Application>