Google Maps API for Flash (Deprecated)

Google Maps API for Flash Developer Guide

The Google Maps API for Flash provides a way to add interactive Google Maps to your website, using Adobe's Flash® plugin to display dynamic map content.

Introduction

This developer guide assumes you are familiar with Flash development and ActionScript programming. It also does not assume usage of any particular development environment, though we provide tutorials for different development environments.

Note: this guide uses UNIX-like command line examples, and Macintosh screen shots, though usage should not appreciably change for other developers.

Setting Up Your Development Environment

Flash development can take many forms. Some developers/designers author purely within the Flash CS3 application to create and arrange content, and add ActionScript within that framework. Other developers use a full-featured IDE such as Adobe FlexBuilder® to create robust applications with heavy use of ActionScript. Some developers use the freely available Flex SDK® from Adobe and build their applications from the command line. The choice of development environment is up to you.

This documentation will provide tutorials for all three approaches to get you going. However, the code samples within this documentation set will be provided as MXML files, for use within either FlexBuilder, or the free Flex SDK. It is relatively straight-forward to use the ActionScript code embedded within those files directly within Flash CS3.

The Google Maps API for Flash now directly supports Adobe AIR® applications within the Flex development environment. Check out the tutorial for authoring AIR applications (experimental) within the FlexBuilder Tutorial.

Obtaining the Interface Library

Developing Flash content that integrates Google Maps requires inclusion of a Google Maps API for Flash interface library within your application code. This library consists of a *.swc file within the lib directory of the Maps API for Flash SDK available at the following URL:

http://maps.googleapis.com/maps/flash/release/sdk.zip

The SDK includes two SWC files: a Flex version for use within FlexBuilder (or with the free Flex SDK), and a non-Flex version for use within Flash CS3. The Flex *.swc is denoted with a _flex suffix in the filename.

These SWC files contain interfaces for all public classes in the Google Maps API for Flash development environment. Compiling your application with this library ensures that it can utilize and communicate with all public functionality of the runtime Google Maps API for Flash library, which is retrieved from Google's servers whenever a client loads your application.

Note that the bulk of the code for actually running your Maps Flash application remains within the separate runtime Google Maps API for Flash library. This allows us to make enhancements, bug fixes, and modifications to the core library functionality without requiring you to recompile your application. Note that if you ever wish to utilize new functionality that requires new interfaces, you will need to download an updated SWC file and recompile your application.

The interface library filename contains a suffix identifying its version number. For example, map_flex_1_7.swc identifies version 1.7 of the Flex interface library, while map_1_7.swc identifies version 1.7 of the Flash interface library. Once you've downloaded the interface library, create a development directory and place that file in the root of that directory.

#
#Create a development directory
#
hostname$ mkdir myflashapp
hostname$ cd myflashapp
#
# Copy the Google Maps API for Flash SDK to the root of your working development directory
#
hostname$ cp ~/sdk.zip .
#
# Unzip the SDK. The SWC interface library is located within the "lib" directory
# Offline ASDoc HTML documentation is available within the "docs" directory
#
hostname$ unzip sdk.zip

Make note of this directory location. You will need it when you need to link to the proper SWC file during development.

Obtaining a Maps API Key

Note: Maps for Business customers do not require an API Key as of version 1.8b of the Flash SDK. You should compile your application using version 1.8b or later to take advantage of keyless functionality. Existing applications will need to be re-compiled with this version to enable keyless support.

The Maps API for Flash is officially deprecated, but will continue to be supported for existing applications in accordance with the deprecation policy defined in the Maps API Terms of Service. Consequently we recommend against using the Maps API for Flash in any new applications, and instead recommend use of the Google Maps JavaScript API v3.

Although we are no longer issuing keys for the Maps API for Flash, we understand that some existing developers may need to update the key being used for an existing application, for example due to a change of hostname. Please follow the instructions on the Maps API for Flash Key Request website if you need a new key.

The Google Maps API for Flash, like the Google JavaScript Maps API, requires usage of a key. You will need to specify this key within one of three possible locations:

  • (For Flex applications) A special configuration file called an MXML declaration
  • (For Flash applications) Your ActionScript code (compiling it into the resulting SWF file)
  • The containing DOM element in your web page.

Note that the API key is compiled into the SWF file and must match the domain where the SWF file is hosted, which may not necessarily be the location for the hosted HTML file. This document set will show Flex examples defining the API key within the MXML declarations.

Specifying the Sensor Parameter

Use of the Google Maps API requires that you indicate whether your application is using a sensor (such as a GPS locator) to determine the user's location. This is especially important for mobile devices. Applications must set the Map's sensor parameter explicitly to either "true" or "false" — Note that these are string values, not booleans — to indicate whether or not the application is using a sensor device.

Applications that determine the user's location via a sensor must pass "true" within the Map's sensor property. (Note: this value must be specified as a string, and not as a Boolean.)

Note that even if your device does not use a sensing device, you must still pass this parameter, setting its value to "false".

You set the sensor property as an initialization parameter when loading the SWF file, in the same manner as specifying a Maps API key. See Setting Your API Key for more information.

Versioning

The Google Maps API for Flash interface library contains the ActionScript interfaces that allow you to communicate with the actual components provided through Google's runtime library. Occasionally, we will make updates to these components "under the hood." As long as the interfaces do not change, you don't need to do anything. The interface SWC file will automatically pick up the latest changes.

If we introduce new functionality and features (and therefore need to update the interfaces), we will also need to update the interface SWC file, which we will provide for download. Such versions will be named according to the version scheme. (For example, the interface library associated with version "1.3" will be named "map_flex_1_3.swc." You will need to download a new version of this interface library before you can make use of these latest features. Make sure you monitor the Google Maps API group or blog to ensure you receive announcements for new versions of the Google Maps API for Flash.

You may set your application to use a hard-coded version of the Maps API for Flash library by setting the Map's version property to a specific version. Note that this is not recommended as you will not benefit from any enhancements or bug fixes to the current implementation.

Tutorials

The following tutorials walk you through creating a sample application using the Google Maps API for Flash in your preferred development environment:

You do not need to read all three tutorials to get started, though it may be useful to you to compare the different development processes.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.