My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Panel title="Google Maps 3D FlyTo Demo" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:HBox width="100%" height="25">
<mx:Label
text="Enter address: "/>
<mx:TextInput
id="address"
text="Coney Island, Brooklyn, NY"
dropShadowColor="0x000000"
enter="doFlyTo(event);"
/>
<mx:Button
id="submitButton" label="Search"
click="doFlyTo(event);"
/>
</mx:HBox>
<maps:Map3D xmlns:maps="com.google.maps.*"
mapevent_mappreinitialize="onMapPreinitialize(event)"
mapevent_mapready="onMapReady(event)"
id="map"
sensor="false" key="your_api_key"
width="100%" height="100%" />
</mx:VBox>
</mx:Panel>
<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.services.GeocodingEvent;
import com.google.maps.services.ClientGeocoder;
import com.google.maps.overlays.Marker;
import com.google.maps.InfoWindowOptions;
import com.google.maps.MapOptions;
import com.google.maps.MapType;
import com.google.maps.View;
import com.google.maps.controls.NavigationControl;
import com.google.maps.geom.Attitude;
import mx.controls.Alert;

private function onMapPreinitialize(event:MapEvent):void {
var myMapOptions:MapOptions = new MapOptions;
myMapOptions.zoom = 12;
myMapOptions.center = new LatLng(40.756054, -73.986951);
myMapOptions.mapType = MapType.PHYSICAL_MAP_TYPE;
myMapOptions.viewMode = View.VIEWMODE_PERSPECTIVE;
myMapOptions.attitude = new Attitude(20,30,0);
this.map.setInitOptions(myMapOptions);
}

private function onMapReady(event:MapEvent):void {
this.map.addControl(new NavigationControl());
}

private function doFlyTo(event:Event):void {
// Instantiate a Geocoder
var geocoder:ClientGeocoder = new ClientGeocoder();

// Add an event listener for a GEOCODING SUCCESS
geocoder.addEventListener(
GeocodingEvent.GEOCODING_SUCCESS,
function(event:GeocodingEvent):void {
var placemarks:Array = event.response.placemarks;
if (placemarks.length > 0) {
map.flyTo(placemarks[0].point,12,new Attitude(20,30,0),3);
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>

Change log

r341 by t...@google.com on Sep 21, 2010   Diff
Update the code samples to not include a
valid API key
Go to: 
Project members, sign in to write a code review

Older revisions

r340 by t...@google.com on Sep 21, 2010   Diff
Add sensor parameter to code samples
r318 by manshreck on Jul 27, 2009   Diff
Added MXML for FlyTo example

All revisions of this file

File info

Size: 2907 bytes, 91 lines

File properties

svn:executable
*
Powered by Google Project Hosting