


Flex Map View
For a big project I've been working on I've implemented the Yahoo Map to an application. The API and more information can be found at http://developer.yahoo.com/flash/maps/.
I've implemented this in an existing application and added all needed functions to it that were needed.
I've attached an Air version of the application for download if you want.
As you might know you can use your flex source in an air project and without changing any code it will run, the only difference in code is the
|
|
One thing I've added there is response to the mouse wheel for zooming in and out.
This was done by listening to a mousewheel event and dependent on that event zoom in or out. <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" label="Map view" creationComplete="handleCreationComplete();" mouseWheel="changeZoom(event)"> <mx:Script source="ascr/MapOverviewAs.as"/> <mx:UIComponent id="mapContainer" width="100%" height="100%"/> </mx:VBox> On the MouseEvent the zoomlevel changes. I know the mousewheel event has different values, what I did here is just check what side the mousewheel is turned and go with that, not paying attention to how fast the map should zoom on this scroll. To check what direction someone is rolling the mousewheel is just by checking if the delta property of the MouseEvent is positive or negative, and we can go with that for determining if we want to zoom in or out. /**
* Respond to a mousewheel move to change the zoom level on the map */ private function changeZoom(event:MouseEvent):void { if (event.delta < 0 && _yahooMap.zoomLevel < 17) { _yahooMap.zoomLevel++; } else if (event.delta > 0 && _yahooMap.zoomLevel > 1) { _yahooMap.zoomLevel--; } } |





There are no comments for this entry.
[Add Comment]