/examples/ArcGISLink/src/LayerQuery3D.mxml
http://gmaps-utility-library-flash.googlecode.com/ · Macromedia eXtensible Markup Language · 102 lines · 89 code · 13 blank · 0 comment · 0 complexity · e3437aaf9fc769600527290d4965fcee MD5 · raw file
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- xmlns:maps="com.google.maps.*"
- layout="absolute"
- width="100%"
- height="100%"
- viewSourceURL="srcview/index.html">
- <mx:Panel title="Census Data from ArcGIS Server Service: After load you should see NC county polygons, mouse over a county for name, click for data"
- width="100%"
- height="100%">
- <maps:Map3D id="map"
- sensor="false"
- mapevent_mapready="onMapReady(event)"
- mapevent_mappreinitialize="onMapPreinitialize(event);"
- width="100%"
- height="100%"
- key="ABQIAAAA7QUChpcnvnmXxsjC7s1fCxQGj0PqsCtxKvarsoS-iqLdqZSKfxTd7Xf-2rEc_PC9o8IsJde80Wnj4g"/>
- </mx:Panel>
-
- <mx:Script>
- <![CDATA[
- import mx.events.ListEvent;
- import mx.controls.Alert;
-
- import com.google.maps.*;
- import com.google.maps.geom.*;
- import com.google.maps.controls.*;
- import com.google.maps.overlays.*;
- import com.google.maps.interfaces.*;
-
- import com.google.maps.extras.arcgislink.*;
-
-
- private var svcUrl:String="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer";
- private var countyLayer:Layer;
- private var hStyle:OverlayOptions=new OverlayOptions({polygon: new PolygonOptions({fillStyle: {color: 0xffff00, alpha: 0.35}, strokeStyle: {color: 0xFF0000, thickness: 4}})});
- private var style:OverlayOptions=new OverlayOptions({polygon: new PolygonOptions({fillStyle: {color: 0x888888, alpha: 0.35}, strokeStyle: {color: 0x0000ff, thickness: 1}})});
-
- private function onMapPreinitialize(event:MapEvent):void {
- map.setInitOptions(new MapOptions({viewMode: View.VIEWMODE_PERSPECTIVE, attitude: new Attitude(20, 30, 0)}));
- }
-
- private function onMapReady(event:Event):void {
- map.setCenter(new LatLng(35.7, -79.5), 7);
- map.addControl(new com.google.maps.controls.MapTypeControl());
- map.addControl(new NavigationControl());
- map.enableScrollWheelZoom();
- map.enableContinuousZoom();
- countyLayer=new Layer(svcUrl + '/3');
- countyLayer.addEventListener(ServiceEvent.LOAD, initFunctionality);
-
- }
-
- private function initFunctionality(evt:Event):void {
- var params:QueryParameters=new QueryParameters({returnGeometry: true, where: "STATE_NAME = 'North Carolina'", outFields: ["NAME", "POP2000", "POP2007", "POP00_SQMI", "POP07_SQMI"]});
- countyLayer.query(params, processResultSet, handleError, style);
- }
-
- private function processResultSet(rs:ResultSet):void {
- var fs:Array=rs.features;
- fs.sort(function(A:*, B:*):int {
- return A.attributes['NAME'].localeCompare(B.attributes['NAME']);
- }, 1);
-
- for (var i:int=0, c:int=fs.length; i < c; i++) {
- var ovs:Array=createGPolys(fs[i], rs.spatialReference);
- for (var j:int=0; j < ovs.length; j++) {
- map.addOverlay(ovs[j]);
- }
- }
- }
-
- private function createGPolys(feat:Feature, sr:SpatialReference):Array {
- var a:*=feat.attributes;
- var ovs:Array=feat.geometry;
- var html:String="<div id='iwdiv'><b>" + a['NAME'] + "</b><br/>" + "<b>2000 Population: </b>" + a['POP2000'] + "<br/>" + "<b>2000 Population per Sq. Mi.: </b>" + a['POP00_SQMI'] + "<br/>" + "<b>2007 Population: </b>" + a['POP2007'] + "<br/>" + "<b>2007 Population per Sq. Mi.: </b>" + a['POP07_SQMI'] + '</div>';
- // note it is possible each feature has more than one poly.
- for (var j:int=0, jc:int=ovs.length; j < jc; j++) {
- var ov:Polygon=ovs[j] as Polygon;
- ov.addEventListener(MapMouseEvent.ROLL_OVER, function(event:MapMouseEvent):void {
- for (var i:int=0, ic:int=ovs.length; i < ic; i++) {
- (ovs[i] as Polygon).setOptions(hStyle.polygon);
- }
- });
- ov.addEventListener(MapMouseEvent.ROLL_OUT, function(event:MapMouseEvent):void {
- for (var i:int=0, ic:int=ovs.length; i < ic; i++) {
- (ovs[i] as Polygon).setOptions(style.polygon);
- }
- });
- ov.addEventListener(MapMouseEvent.CLICK, function(event:MapMouseEvent):void {
- map.openInfoWindow(event.latLng, new InfoWindowOptions({contentHTML: html}));
- });
- }
- return ovs;
- }
-
- private function handleError(err:ServiceError):void {
- mx.controls.Alert.show(err.toString());
- }
- ]]>
- </mx:Script>
- </mx:Application>