AboutFlex.net

flex,air,flash …

Google has finally released the Api for Flash of the famous Google maps,too!

to start developing you can visit http://code.google.com/apis/maps/index.html
and follow this instructions:
- get your personal Google Map API KEY that you can use on your domain
- download the SWC library

This is a simple flex project

the Application.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%">
  <mx:Panel title="Google Maps API for Flash - Simple Map" width="100%" height="100%">
    <mx:UIComponent id="mapContainer"
        initialize="startMap(event);"
        resize="resizeMap(event)"
        width="100%" height="100%"/>
  </mx:Panel>
  <mx:Script>
    <![CDATA[
import flash.events.Event;
import com.google.maps.MapEvent;
import com.google.maps.Map;
import com.google.maps.MapType;
import com.google.maps.LatLng;

  private var map:Map;

  public function startMap(event:Event):void {
    map = new Map();
    map.addEventListener(MapEvent.MAP_READY, onMapReady);
    mapContainer.addChild(map);
  }

  public function resizeMap(event:Event):void {
    map.setSize(new Point(mapContainer.width, mapContainer.height));
  }

  private function onMapReady(event:Event):void {
    map.setCenter(new LatLng(41.936907, 12.539244), 14, MapType.NORMAL_MAP_TYPE);
  }

    ]]>
  </mx:Script>
</mx:Application>

P.S. remember to modify the Html to pass the API KEY like a flashvars
in this way:

the HTML file

<div id="map_canvas" name="map_canvas">
<object
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
width="800px"
height="600px">
<param name="movie" value="./swf/MapSimple.swf">
<param name="quality" value="high">
<param name="flashVars" value="key=ABQIAAAA7QUChpcnvnmXxsjC7s1fCxQGj0PqsCtxKvarsoS-iqLdqZSKfxTd7Xf-2rEc_PC9o8IsJde80Wnj4g">
<embed
width="800px"
height="600px"
src="./swf/MapSimple.swf"
quality="high"
flashVars="key=ABQIAAAA7QUChpcnvnmXxsjC7s1fCxQGj0PqsCtxKvarsoS-iqLdqZSKfxTd7Xf-2rEc_PC9o8IsJde80Wnj4g"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash">
</embed>
</object>
</div>

Add A Comment