Google Maps APIをためしてみる。


umhr_googlemapGoogle Maps APIをためしてみる。

回転中も地図上の操作ができることに注意。

▼Google Maps API for Flash デベロッパー ガイド – Google Maps API for Flash – Google Code
http://code.google.com/intl/ja/apis/maps/documentation/flash/intro.html

▼Wonderfl
http://wonderfl.net/code/8852d58b8d235408da4727f78b2cd34460a9e9e2
回転しない版
http://wonderfl.net/code/45ae1bb7e0ccd622fcc7e46fec9af968cbd6670b

▼ActionScript AS3(FP10)
[sourcecode language=”as3″]
/*
Google Maps APIキーはGoogle アカウントに紐づけられているみたい。
特に↓mztm.jp以外で使う場合にはapiキーを取り直すこと。
http://code.google.com/intl/ja/apis/maps/signup.html

wonderfl版
http://wonderfl.net/code/8852d58b8d235408da4727f78b2cd34460a9e9e2

参考
http://code.google.com/intl/ja/apis/maps/documentation/flash/
http://code.google.com/intl/ja/apis/maps/documentation/flash/tutorial-flash.html
http://wonderfl.net/code/40ea4a8b37715d10e1e66fc0fa41cf08fd12320a
*/
package
{
import com.google.maps.LatLng;
import com.google.maps.Map;
import com.google.maps.MapEvent;
import com.google.maps.MapType;
import com.google.maps.controls.*;
import com.google.maps.overlays.Marker;
import com.google.maps.overlays.MarkerOptions;
import com.google.maps.MapType;
import com.google.maps.LatLng;
import com.google.maps.styles.FillStyle;
import com.google.maps.styles.StrokeStyle;
import com.google.maps.InfoWindowOptions;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
import flash.text.TextFormat;
[SWF(width="465", height="465", frameRate="30", backgroundColor="0")]
/**
* …
* @author umhr
*/
public class Main extends Sprite
{
private var map:Map;
public function Main():void
{

map = new Map();
map.key = "ABQIAAAA3rUkaCgx4lrP8oG34Tr2ERRRMikYFh7V9Xz0T0QdrnG0MKgS5BSyIZWj5Bc1nccSqDiPGW_gtUP5TA";
map.setSize(new Point(stage.stageWidth, stage.stageHeight));
map.addEventListener(MapEvent.MAP_READY, onMapReady);
this.addChild(map);
}
private function onMapReady(event:Event):void {
map.setCenter(new LatLng(35.70299 , 139.70485), 14, MapType.NORMAL_MAP_TYPE);
var markerA:Marker = new Marker(
new LatLng(35.70299 , 139.70485),
new MarkerOptions({
strokeStyle: new StrokeStyle({color: 0x987654}),
fillStyle: new FillStyle({color: 0xFFFFFF, alpha: 0.9}),
radius: 26,
hasShadow: true,
label:"mztm.jp",
labelFormat:new TextFormat(null,null,0x4465d7)
}));
map.addOverlay(markerA);
map.addControl(new ZoomControl());
map.addControl(new PositionControl());
map.addControl(new MapTypeControl());
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
map.x = 200;
map.z = 100;
}
private function onEnterFrame(e:Event):void{
map.rotationY += 0.2;
}
}
}

[/sourcecode]