例−45:180度線をまたいでポリラインを描画する

180度線を越えてラインを描画するときの方法です。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
 xmlns:maps="com.google.maps.*" viewSourceURL="srcview/index.html">
	<maps:Map key="[GoogleMapsAPIKey]"
		 width="100%" height="100%" sensor="false" mapevent_mapready="{onReady();}" id="map" />
	
	<mx:Script>
		<![CDATA[
			import com.google.maps.overlays.Marker;
			import com.google.maps.controls.ZoomControl;
			import com.google.maps.LatLng;
			import com.google.maps.overlays.Polyline;
			import com.google.maps.overlays.PolylineOptions;
			
			
			private function onReady():void{
				this.map.setCenter(new LatLng(0, 180), 2);
				this.map.addControl(new ZoomControl());
				
				//points
				var points : Array = new Array();
				points.push(new LatLng(35.681382, 139.766084));	//Tokyo Japan
				//points.push(new LatLng(40.756054, -73.986951));	//こうするとただしく描画されません
				points.push(new LatLng(40.756054, -73.986951 + 360, true));	//N.Y. USA
				
				//markers
				this.map.addOverlay(new Marker(points[0]));
				this.map.addOverlay(new Marker(points[1]));
				
				//draw lines
				var opts : PolylineOptions = new PolylineOptions({color : 0x0000FF, thickness : 5});
				var line : Polyline = new Polyline(points, opts);
				this.map.addOverlay(line);
				
			}
		]]>
	</mx:Script>
</mx:Application>


ダウンロード

map_example_45.zip



サイト内検索
Google Maps APIプログラミングガイド

Google Maps API Expert 4人が共著で執筆。中級者向けに実用に役立つサンプルを中心に紹介! スマートフォン時代に合わせたGoogle Maps APIの使い方も掲載。
詳しくはこちら
Google Maps APIプログラミング入門
Google Maps APIプログラミング入門
全480ページ。Google Maps API ver.2, ver.3, for Flash, Static Maps API v2, Google Maps API Primery, ライセンス…など、Google Maps APIに関連する幅広い内容の本を書きました。
このサイトで公開しているサンプルはもちろん、本のために作ったサンプルも満載です。
詳しくはこちら