PageRenderTime 35ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/examples/ArcGISLink/src/LayerQuery3.mxml

http://gmaps-utility-library-flash.googlecode.com/
Macromedia eXtensible Markup Language | 103 lines | 90 code | 13 blank | 0 comment | 0 complexity | 7c5d1ca0823ea2f1968b43b383055ad4 MD5 | raw file
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3. layout="absolute"
  4. width="100%"
  5. height="100%">
  6. <mx:Panel title="Layer Query"
  7. width="100%"
  8. height="100%">
  9. <mx:HBox>
  10. <mx:Label text="Pick a date:"/>
  11. <mx:DateField width="135" id="date311" displayedMonth="8" displayedYear="2009" showToday="false" enabled="true" includeInLayout="true" selectedDate="{new Date (2009, 8, 9)}" toolTip="Select a date" editable="true"/>
  12. <mx:Button label="Load Incidents" click="onLoadClick(event)"/>
  13. </mx:HBox>
  14. <maps:Map xmlns:maps="com.google.maps.*"
  15. id="map"
  16. mapevent_mapready="onMapReady(event)"
  17. width="100%"
  18. height="100%"
  19. key="ABQIAAAA7QUChpcnvnmXxsjC7s1fCxQGj0PqsCtxKvarsoS-iqLdqZSKfxTd7Xf-2rEc_PC9o8IsJde80Wnj4g" sensor="false"/>
  20. </mx:Panel>
  21. <mx:Script>
  22. <![CDATA[
  23. import com.google.maps.*;
  24. import com.google.maps.controls.*;
  25. import com.google.maps.extras.arcgislink.*;
  26. import com.google.maps.interfaces.*;
  27. import com.google.maps.overlays.*;
  28. import mx.controls.Alert;
  29. private var layer:Layer;
  30. private function onMapReady(event:Event):void {
  31. map.setCenter(new LatLng(37.76, -122.45), 13);
  32. map.addControl(new com.google.maps.controls.MapTypeControl());
  33. map.addControl(new NavigationControl());
  34. map.enableScrollWheelZoom();
  35. map.enableContinuousZoom();
  36. layer=new Layer('http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/SanFrancisco/311Incidents/MapServer/0');
  37. //layer.addEventListener(ServiceEvent.LOAD, initFunctionality);
  38. }
  39. private function loadFeatures():void {
  40. var where:String = "req_date = '"+DateField.dateToString(this.date311.selectedDate, this.date311.formatString)+"'";
  41. var params:QueryParameters=new QueryParameters({returnGeometry: true, where: where, outFields: ['*']});
  42. map.clearOverlays();
  43. layer.query(params, processResultSet, handleError, null);
  44. }
  45. private function processResultSet(rs:ResultSet):void {
  46. var fs:Array=rs.features;
  47. for (var i:int=0, c:int=fs.length; i < c; i++) {
  48. var ovs:Array=createGMarkers(fs[i], rs.spatialReference);
  49. for (var j:int=0; j < ovs.length; j++) {
  50. map.addOverlay(ovs[j]);
  51. }
  52. }
  53. }
  54. private function createGMarkers(feat:Feature, sr:SpatialReference):Array {
  55. var a:*=feat.attributes;
  56. var ovs:Array=feat.geometry;
  57. var html:String="<div id='iwdiv'>";
  58. for (var x:String in a) {
  59. if (a.hasOwnProperty(x)) {
  60. var val:*=a[x];
  61. val=(val === null || typeof val === 'undefined') ? '' : '' + val;
  62. html +="<b>"+ x +"</b>: "+val+"<br/>";
  63. }
  64. }
  65. html+="</div>";
  66. var io:InfoWindowOptions = new InfoWindowOptions({contentHTML: html, pointOffset:new Point(2, -20)});
  67. // note it is possible each feature has more than one poly.
  68. for (var j:int=0, jc:int=ovs.length; j < jc; j++) {
  69. var ov:Marker=ovs[j] as Marker;
  70. ov.addEventListener(MapMouseEvent.ROLL_OVER, function(event:MapMouseEvent):void {
  71. map.openInfoWindow(ov.getLatLng(), io);
  72. });
  73. ov.addEventListener(MapMouseEvent.ROLL_OUT, function(event:MapMouseEvent):void {
  74. // map.closeInfoWindow();
  75. });
  76. ov.addEventListener(MapMouseEvent.CLICK, function(event:MapMouseEvent):void {
  77. map.openInfoWindow(event.latLng, io);
  78. });
  79. }
  80. return ovs;
  81. }
  82. private function onLoadClick(event:Event):void{
  83. loadFeatures();
  84. }
  85. private function handleError(err:ServiceError):void {
  86. mx.controls.Alert.show(err.toString());
  87. }
  88. ]]>
  89. </mx:Script>
  90. </mx:Application>