Developer Network Home - Help

Yahoo! Maps Web Services - ActionScript®-Flash® API Getting Started Guide

Version 3.5 - Beta Yahoo! Maps AS-Flash API - CustomSWFOverlay Tutorial

Learn the fundamentals of the CustomSWFOverlay feature in the Yahoo! Maps AS-Flash API for use with ActionScript and the Flash IDE.

Introduction and Prerequisites

The CustomSWFOverlay feature in the Yahoo! Maps API gives you the ability to display all sorts of graphics and data over the map. Similar to CustomSWFMarker, the overlay spans the whole map and can display anything from land parcel data to a custom polyline overlay. In this tutorial we will be creating a user-drawn polyline overlay using the built in Flash drawing tools.

To create and test applications using the Yahoo! Maps AS-Flash API, you'll need Macromedia® Flash MX 2004® or higher and a browser with Flash Player 7 or higher. You will also need to download the Yahoo! Maps MXP (Macromedia® eXtensions Package) file that will install the appropriate classes onto your machine. An application ID is required to use the AS-Flash API. You can get an application ID here.

For best results, you should launch your web pages from a web server. However, it's possible to run applications directly from your hard drive by double-clicking on them. If you run them from your hard drive, you may see a warning from the Flash Player that your application is trying to access data from a third-party server (Yahoo!). You can remove this warning by adjusting your Flash Player settings.

Displaying a Yahoo! Map using ActionScript and Flash

Once you have agreed to the terms and downloaded the Yahoo! Maps MXP file, double click on it to launch the Macromedia Extension Manager and automatically install the extension. Please make sure that you have the latest version of the Extension Manager installed. You will need to restart the Flash IDE if you have it open in order for the classes to be available. After the extension is loaded, open the Components panel and expand the Yahoo tree where you should now see com.yahoo.maps.api.flash.YahooMap. To use the component, drag com.yahoo.maps.api.flash.YahooMap from the Components panel onto the stage. Resize the component with the Transform tool or Property inspector and test your movie to see the map. To interact with the map you will need to give the component an instance name. For the examples below, myMap is the instance name.

When adding the Map component to the stage, you should specify what the map will display by default as well as enter your Yahoo! application ID. With the component selected, click on the Parameters tab in the Properties inspector. Here you can specify the starting location, default zoom level, and Yahoo! application ID for your map. The starting location can either be an address, taking advantage of our built-in geocoding, or a latitude and longitude. The zoom level can be any integer from 1 to 17. If no zoom level is specified, the map will default to a zoom level of 14 over the specified location. If no location is specified, the map will default to the center of the United States at the specified zoom level.

Creating the Overlay SWF


With a working map, our next step will be to create the overlay. This will be a seperate SWF file that the map will load as a CustomSWFOverlay. It will also be solely based on ActionScript.

Back to the Map: Adding the Overlay


 

Copyright © 2008 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings