GoogleMap2.as
package
{
import flash.display.MovieClip;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.geom.Point;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;
import com.google.maps.controls.OverviewMapControl;
import com.google.maps.MapEvent;
import com.google.maps.MapMouseEvent;
import com.google.maps.Map;
import com.google.maps.MapType;
import com.google.maps.LatLng;
import com.google.maps.LatLngBounds;
import com.google.maps.ProjectionBase;
import com.google.maps.interfaces.IProjection;
import com.google.maps.interfaces.IMapType;
import com.google.maps.controls.MapTypeControl;
import com.google.maps.controls.ZoomControl;
import com.google.maps.controls.PositionControl;
import com.google.maps.overlays.Marker;
import com.google.maps.overlays.MarkerOptions;
import com.google.maps.styles.StrokeStyle;
import com.google.maps.styles.FillStyle;
import com.google.maps.overlays.Polyline;
import com.google.maps.overlays.PolylineOptions;
import com.google.maps.overlays.EncodedPolylineData;
import com.google.maps.InfoWindowOptions;
import flash.external.ExternalInterface;
public class GoogleMap2 extends MovieClip
{
private const API_KEY:String = "ABQIAAAA73dVoFyoQbog-4yz-ZBItxQBsB0c0omCcBiYWhQPV0tbulUaWBShq05AmizCFtLMAcSE97qEUQhiyg"; //APIキー
private var container:MovieClip;
private var map:Map;
private var marker : Marker;
private var delay:uint = 2000;
private var repeat:uint = 15;
private var myTimer:Timer = new Timer(delay, repeat);
private var num:int = 0;
private var latArray:Array = [
35.647968112304525,
35.64854352416794,
35.649153804948654,
35.649851262989245,
35.65063589600608,
35.65140308528166,
35.652379497339254,
35.65325128373329,
35.65408818971973,
35.65494571868501,
35.65546557839573,
35.656128111323135,
35.656671791054116,
35.657282009733834,
35.657819288874535,
35.65822028448464
];
private var lotArray:Array = [
139.74459171295166,
139.74465608596802,
139.74472045898438,
139.74478483200073,
139.7448492050171,
139.74495649337769,
139.74502086639404,
139.7450852394104,
139.74514961242676,
139.74534273147583,
139.7457504272461,
139.74592208862305,
139.74600791931152,
139.74579334259033,
139.74562168121338,
139.74592208862305
];
public function GoogleMap2()
{
initMap();
}
private function initMap():void
{
//コンテナ作成
container = new MovieClip();
container.x = container.y = 0;
addChild(container);
//Google MAP 作成
map = new Map();
map.key = API_KEY; //APIキー
map.language = "ja"; //言語
map.setSize(new Point(stage.stageWidth, stage.stageHeight)); //地図サイズ設定
map.addControl(new PositionControl()); //ポジションキーボタン
map.addControl(new ZoomControl()); //拡大縮小スライダー
map.addControl(new MapTypeControl()); //地図タイプセレクトボタン
map.addControl(new OverviewMapControl()); //右下オーバービューコントローラー
map.addEventListener(MapEvent.MAP_READY, onMapReady, false, 0, true); //イベント設定
map.addEventListener(MapMouseEvent.CLICK, onMapClick);
container.addChild(map);
}
//地図生成完了イベント
private function onMapReady(e:MapEvent):void
{
map.removeEventListener(MapEvent.MAP_READY, onMapReady);
//初期表示設定
map.enableScrollWheelZoom(); //マウスホイールで拡大縮小できる
map.enableContinuousZoom(); //スムースな拡大縮小ができる
//地図座標セット
var centerLL : LatLng = new LatLng(latArray[num],lotArray[num]);
map.setCenter(
centerLL, //座標
16, //拡大率
MapType.NORMAL_MAP_TYPE //地図タイプ
);
//マーカー座標セット
marker = new Marker( centerLL );
map.addOverlay( marker );
//タイマーセット
myTimer.start();
myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, completeHandler);
//ステージ設定
initStage();
}
private function timerHandler(e:TimerEvent):void
{
repeat--;
num++;
//地図座標セット
var centerLL : LatLng = new LatLng(latArray[num],lotArray[num]);
map.setCenter(
centerLL, //座標
16, //拡大率
MapType.NORMAL_MAP_TYPE //地図タイプ
);
//マーカー移動
marker.setLatLng( centerLL );
//ExternalInterfaceで外部JavaScript関数を呼び出す
ExternalInterface.call( "setPanorama", latArray[num], lotArray[num] );
}
private function completeHandler(e:TimerEvent):void
{
}
private function onMapClick(e:MapMouseEvent):void
{
//マーカー移動
marker.setLatLng( e.latLng );
//ExternalInterfaceで外部JavaScript関数を呼び出す
ExternalInterface.call( "setPanorama", e.latLng.lat(), e.latLng.lng() );
}
//ステージ設定
private function initStage():void
{
stage.showDefaultContextMenu = false;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, stageResizeListener);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveListener, true);
map.setSize(new Point(stage.stageWidth, stage.stageHeight));
}
//マウス移動イベント
private function mouseMoveListener(e:MouseEvent):void
{
//マウスの座標取得
var nowLL:LatLng = map.fromViewportToLatLng(new Point(mouseX, mouseY));
//trace(nowLL.lat()+" , "+nowLL.lng());
}
//ステージリサイズイベント
private function stageResizeListener(e:Event):void
{
map.setSize(new Point(stage.stageWidth, stage.stageHeight));
}
}
}
HTML
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="http://blog.alt-scape.com/js/AC_RunActiveContent.js" language="javascript"></script>
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA73dVoFyoQbog-4yz-ZBItxQBsB0c0omCcBiYWhQPV0tbulUaWBShq05AmizCFtLMAcSE97qEUQhiyg" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
//<![CDATA[
//ストリートビュー初期設定
var panorama;
function load() {
panorama = new GStreetviewPanorama(document.getElementById("pano"));
panorama.setLocationAndPOV(new GLatLng( 35.647968112304525, 139.74459171295166 ));
}
//ポイントの指定
function setPanorama( lat , lon ) {
panorama.setLocationAndPOV( new GLatLng(lat, lon) );
}
//]]>
</script>
</head>
<body onLoad="load()">
<!-- ストリートビュー -->
<div id="pano" style="width:550px;height:400px;float:left;background-color:#ffccff;" ></div>
<br clear="all" />
<!-- Googleマップ -->
<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("このページでは \"AC_RunActiveContent.js\" が必要です。");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', '550',
'height', '400',
'src', 'googlemap2',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'googlemap2',
'bgcolor', '#ffffff',
'name', 'googlemap2',
'menu', 'true',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', 'googlemap2',
'salign', ''
); //end AC code
}
</script>