My favorites | Sign in
Project Logo
                
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
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2008 Google Inc.
Licensed under the Apache License, Version 2.0:
http://www.apache.org/licenses/LICENSE-2.0
-->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:maps="com.google.maps.*" layout="absolute" width="100%" height="100%">
<mx:Panel title="Google Maps API for Flash Demo" width="100%" height="100%">
<maps:Map
id="map"
key="ABQIAAAA7QUChpcnvnmXxsjC7s1fCxQGj0PqsCtxKvarsoS-iqLdqZSKfxTd7Xf-2rEc_PC9o8IsJde80Wnj4g"
mapevent_mapready="onMapReady(event)"
width="100%" height="100%"/>
</mx:Panel>
<mx:Script>
<![CDATA[
import flash.events.Event;
import flash.geom.Point;
import flash.text.TextField;
import com.google.maps.MapEvent;
import com.google.maps.MapMouseEvent;
import com.google.maps.Map;
import com.google.maps.overlays.Marker;
import com.google.maps.MapType;
import com.google.maps.LatLng;
import com.google.maps.LatLngBounds;
import com.google.maps.InfoWindowOptions;

private var message:Array = ["This","is","the","secret","message"];

private function onMapReady(event:Event):void {
// Add 5 markers to the map at random locations
// Note that we don't add the secret message to the marker's instance data
var bounds:LatLngBounds = map.getLatLngBounds();
var southWest:LatLng = bounds.getSouthWest();
var northEast:LatLng = bounds.getNorthEast();
var lngSpan:Number = northEast.lng() - southWest.lng();
var latSpan:Number = northEast.lat() - southWest.lat();
for (var i:Number = 0; i < 5; i++) {
var latlng:LatLng = new LatLng(southWest.lat() + latSpan * Math.random(),
southWest.lng() + lngSpan * Math.random());
map.addOverlay(createMarker(latlng, i + 1));
}
}
// Creates a marker at the given point
// Clicking the marker will hide it
private function createMarker(latlng:LatLng, number:Number):Marker {
var marker:Marker = new Marker(latlng);
marker.addEventListener(MapMouseEvent.CLICK, function(e:MapMouseEvent):void {
var myTitle:String = "<b>#" + number + "</b>";
var myContent:String = message[number -1];
map.openInfoWindow(latlng, new InfoWindowOptions({titleHTML: myTitle, contentHTML: myContent}));
});
return marker;
}
]]>
</mx:Script>
</mx:Application>
Show details Hide details

Change log

r190 by pamela.fox on Oct 02, 2008   Diff
Committing changed examples for 1.7
Go to: 
Project members, sign in to write a code review

Older revisions

r2 by pamela.fox on May 13, 2008   Diff
Adding first draft of examples for the
Maps API for Flash
All revisions of this file

File info

Size: 2494 bytes, 58 lines

File properties

svn:executable
*
Hosted by Google Code