New API enables Google Maps to be embedded in Flash apps
In a move that could signal a break from Google's dependence on HTML-structured pages with JavaScript code, the company today unveiled its first working API for embedding functionality inside an Adobe Flash-based application.
Google's new Maps API for Flash now enables developers of Flash-endowed Web sites to embed Google Maps directly, but also more importantly to acquire and manipulate the data on which those maps are based. The result can be something more than the way, say, a YouTube video is "embedded" into a Web site by dropping in its <OBJECT> element.
According to new documentation released by Google this morning, using Adobe's Flex environment and the ActionScript language, a developer can import Google's map libraries into a page first by declaring their events. Since Web services operate on an asynchronous model, events serve as signals that Google's servers send to a client, to which a program can respond with functions. In order to cut right to the chase, events pretty much comprise the backbone of Google Maps API code; the very act of creating the map itself, including setting its initial location and search criteria, is phrased as a response to the event code MAP_READY. The Flex developer sets up a listener in ActionScript, which points by name to a function to be executed in response to that event.
From there, data points relevant to the map at hand can be retrieved as variables, and then used in other Flex functions. One compelling example of the Maps API in action was developed for today's unveiling by Flash components producer AFComponents, and posted on Google's corporate blog this morning.
The example shows a typical-looking Google Map that starts at San Francisco. A tour of the world has been programmed in, and AFComponents' example has plugged the route for that tour into the map, so Google displays it as a line. Meanwhile, a frame along the right side shows a Flash video of the highlights of all those points along the tour.
As the Flash video plays, complete with ragtime music, the Map repositions itself at each waypoint along the tour in sync with the destination shown in the video. And the running video slider along the bottom is decorated with waypoint markers that correspond to those same points on the map, so you can see at what time a certain waypoint is featured. It's a three-way interface of data elements, all in perfect sync, and all using an asynchronous programming platform.
Rather than release the Maps API as a beta, as Google developer Mike Jones blogged this morning, the company decided to try simply releasing what they had so far, knowing that Web sites would link to it anyway, and that any changes or fixes the company makes will be implemented along the way.
"We knew that version 1 of any software project is not perfect, so we opted to split the interface and implementation," Jones wrote. "As a result, you can build against the current version of the API, and as we add enhancements and tweaks, your Web site benefits automatically from each update. When you wish to take advantage of new API functions, only then do you need to download the latest API and rebuild."
Last month, Google introduced special APIs for its search, RSS feed, and language services for Flash sites, though a Web service API for Google Search through Flash had been unofficially available since about 2005.
The addition of server-based maps to Flash apps is actually nothing new; though Jones characterized it as a baby being let loose upon the world for the first time, a similar API for Yahoo Maps has been available since November 2005.