home > March 2010
AS3 : Google Maps API
March 07, 2010
FlashとGoogleMapの連携って意外に簡単。
まず、SDKをダウンロードしてからAPIキーを取得する。
http://code.google.com/apis/maps/documentation/flash/
http://code.google.com/apis/maps/signup.html
swcファイル(map_1_8a.swc)をComponentsに格納します。
あとはクラスをインポートしていくつかnewするだけで地図が表示できます。
import com.google.maps.LatLng;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapType;
var map:Map = new Map();
map.key = "your_api_key";
map.setSize(new Point(stage.stageWidth, stage.stageHeight);
map.addEventListener(MapEvent.MAP_READY, onMapReady);
this.addChild(map);function onMapReady(event:Event):void {
map.setCenter(new LatLng(40.736072,-73.992062), 14, MapType.NORMAL_MAP_TYPE);
}
参考サイト
http://blog.alt-scape.com/archives/231
http://level0.kayac.com/2009/12/googlemapapi_route1.php
http://code.google.com/intl/ja/apis/maps/documentation/flash/tutorial-flash.html
ラインを引いたりするのも簡単にできそうですね。
Posted at 05:33 PM | Comments (0)
