PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/examples/MarkerClustererDemo/src/MarkerClustererDemo.mxml

http://gmaps-utility-library-flash.googlecode.com/
Macromedia eXtensible Markup Language | 68 lines | 58 code | 10 blank | 0 comment | 0 complexity | 14a349bf3ec2c158aca5d9cdffe9511b MD5 | raw file
 1<?xml version="1.0" encoding="utf-8"?>
 2<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
 3				layout="vertical"
 4				xmlns:maps="com.google.maps.*" 
 5				width="100%" 
 6				height="100%"  backgroundGradientAlphas="[1.0, 1.0]" 
 7				backgroundGradientColors="[#002856, #7E9FFF]">
 8<!--	
 9
10LOG:
11
12@20100211	Change the interface of MarkerClusterer from using Map, to IPane.
13
14-->
15<mx:Script>
16<![CDATA[
17	import com.google.maps.interfaces.IPane;
18	import com.google.maps.extras.markerclusterer.*;
19	import com.google.maps.styles.FillStyle;
20	import com.google.maps.InfoWindowOptions;
21	import com.google.maps.overlays.Marker;
22	import com.google.maps.overlays.MarkerOptions;
23	import com.google.maps.LatLng;
24	import com.google.maps.MapOptions;
25	import com.google.maps.MapMoveEvent;
26	import com.google.maps.MapMouseEvent;
27	import com.google.maps.controls.ZoomControl;
28	
29	private var markerClusterer : MarkerClusterer;
30	private function map_onMapReady() : void {
31		var newCenter 	    : LatLng;
32		
33		var pane:IPane = map.getPaneManager().createPane();
34		
35		// Will now cluster them
36		markerClusterer = new MarkerClusterer(pane, this.createRandomMarkers());
37		
38		var centerPos : LatLng = new LatLng(0, 0);
39		map.setCenter(centerPos, 2);
40		map.addControl(new ZoomControl);			
41      } 
42	private function createRandomMarkers(count:int=500):Array{
43      	var marker_s        : Array = new Array();
44
45		// Will draw 500 randomly positioned markers
46		for (var i:int = 0; i < count; ++i) {
47			var latlng : LatLng = new LatLng((Math.random() * 170) - 85, (Math.random() * 360) - 180);
48			var marker_ : UnitMarker 	= new UnitMarker(latlng);
49			marker_s.push(marker_);
50		}
51		return marker_s;
52     }
53]]>
54</mx:Script>
55	<mx:Label text="Marker Clustering Demo - For Flex" color="#FFFFFF" fontWeight="bold" fontSize="14" width="100%"/>
56	<mx:Box direction="horizontal" >
57		<mx:Button label="add random markers" click="this.markerClusterer.addMarkers(createRandomMarkers(200)); markerClusterer.resetViewport(this.cb.selected);" />
58		<mx:CheckBox id="cb" label="update map dymantically?" click="markerClusterer.resetViewport(this.cb.selected);" color="0xffffff"/>
59		<mx:Button id="btn" label="remove all markers" click="this.markerClusterer.clearMarkers()" />
60	</mx:Box>
61	<maps:Map id="map" 
62			  key="ABQIAAAAwZG5Tk3XmQjBsSYWpMhjDRSdTDYviMONHujlMmN890x_YsxVvRSwiyXiYCZghmG9-BgJSPC0upuacg"
63	  		  mapevent_mapready="map_onMapReady()" 
64	  		  width="100%" height="100%"
65	  		  />
66	
67</mx:Application>
68