3D Flash 地図

| Category=Flex | Comment

Google Maps API for Flash で、3Dが機能するようになったみたいなので(左上のコントローラ)

※グーグルのSDK一式を最新のもの(map_flex_1_16.swc)にしないとコンパイルできない。

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:VBox width="100%" height="100%">
<maps:Map3D xmlns:maps="com.google.maps.*"
mapevent_mappreinitialize="onMapPreinitialize(event)"
mapevent_mapready="onMapReady(event)"
id="map"
key="ABQIAAAAAObg9xo1xsy............"
width="100%" height="100%"/>
</mx:VBox>
<mx:TextInput top="12" left="100" width="80" id="address" text="" enter="doGeocode(event);" />
<mx:Button id="GeocodeButton" top="12" left="190" width="45" label="Go!" click="doGeocode(event);" />
<mx:Script>
<![CDATA[
import com.google.maps.LatLng;
import com.google.maps.Map3D;
import com.google.maps.MapEvent;
import com.google.maps.MapMouseEvent;
import com.google.maps.MapOptions;
import com.google.maps.MapType;
import com.google.maps.View;
import com.google.maps.controls.MapTypeControl;
import com.google.maps.controls.NavigationControl;
import com.google.maps.geom.Attitude;
import com.google.maps.overlays.Marker;
import com.google.maps.InfoWindowOptions;
import com.google.maps.services.ClientGeocoder;
import com.google.maps.services.GeocodingEvent;
import mx.controls.Alert;
private function onMapPreinitialize(event:MapEvent):void {
var myMapOptions:MapOptions = new MapOptions;
myMapOptions.zoom = 12;
myMapOptions.center = new LatLng(35.69, 139.7);
myMapOptions.mapType = MapType.NORMAL_MAP_TYPE;
myMapOptions.viewMode = View.VIEWMODE_ORTHOGONAL;
myMapOptions.attitude = new Attitude(20,30,0);
this.map.setInitOptions(myMapOptions);
}
private function onMapReady(event:MapEvent):void {
this.map.addControl(new NavigationControl());
this.map.addControl(new MapTypeControl());
}
private function doGeocode(event:Event):void {
var geocoder:ClientGeocoder = new ClientGeocoder();
geocoder.addEventListener(
GeocodingEvent.GEOCODING_SUCCESS,
function(event:GeocodingEvent):void {
var placemarks:Array = event.response.placemarks;
if (placemarks.length > 0) {
map.setCenter(placemarks[0].point, 14);
var marker:Marker = new Marker(placemarks[0].point);
marker.addEventListener(MapMouseEvent.CLICK, function (event:MapMouseEvent):void {
marker.openInfoWindow(new InfoWindowOptions({content: placemarks[0].address}));
});
map.addOverlay(marker);
}
});
geocoder.addEventListener(
GeocodingEvent.GEOCODING_FAILURE,
function(event:GeocodingEvent):void {
Alert.show("Geocoding failed");
trace(event);
trace(event.status);
}
);
geocoder.geocode(address.text);
}
]]>
</mx:Script>
</mx:Application>

« [No.107] Gracia de Chile: Merlot Reserva 2008    [No.108] Cremaschi Furlotti: Cabernet Sauvignon 2006 »