[PHP]<?xml version="1.0" encoding="utf-8"?> <!-- //////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2010 ESRI // // All rights reserved under the copyright laws of the United States. // You may freely redistribute and use this software, with or // without modification, provided you include the original copyright // and use restrictions. See use restrictions in the file: // <install location>/License.txt // //////////////////////////////////////////////////////////////////////////////// --> <viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:esri="http://www.esri.com/2008/ags" xmlns:viewer="com.esri.viewer.*" widgetConfigLoaded="init()"> <fx:Script> <![CDATA[ import com.esri.ags.FeatureSet; import com.esri.ags.Graphic; import com.esri.ags.events.MapMouseEvent; import com.esri.ags.geometry.MapPoint; import com.esri.ags.tasks.supportClasses.ExecuteResult; import com.esri.ags.tasks.supportClasses.ParameterValue; import com.esri.ags.events.DrawEvent; import com.esri.ags.events.GeoprocessorEvent; import com.esri.ags.tasks.supportClasses.LinearUnit; import com.esri.ags.tools.DrawTool; import com.esri.ags.layers.GraphicsLayer; import mx.controls.Alert; import mx.rpc.AsyncResponder;
private var driveTimes:String = "1 2 3"; private var myGraphicsLayer:GraphicsLayer = new GraphicsLayer(); [Bindable] private var url:String; //this function called when the widget's configuration is loaded private function init():void { if (configXML) // checking for valid content in the configuration file { url = configXML.url; map.addLayer(myGraphicsLayer); } } private function computeServiceArea(mapPoint:MapPoint):void { myGraphicsLayer.clear(); var graphic:Graphic = new Graphic(mapPoint, sms_circleAlphaSizeOutline); myGraphicsLayer.add(graphic); var featureSet:FeatureSet = new FeatureSet([ graphic ]); var params:Object = { "Input_Location": featureSet, "Drive_Times": driveTimes }; gp.execute(params, new AsyncResponder(onResult, onFault)); function onResult(gpResult:ExecuteResult,token:Object = null):void { var pv:ParameterValue = gpResult.results[0]; var fs:FeatureSet = pv.value as FeatureSet; myGraphicsLayer.graphicProvider = fs.features; myGraphicsLayer.renderer=uniqueValueRenderer; } function onFault(info:Object, token:Object = null):void { Alert.show(info.toString()); } } private function clear():void { myGraphicsLayer.clear(); } private function mapClickHandler(event:MapMouseEvent):void { computeServiceArea(event.mapPoint); } protected function driveTime_openHandler(event:Event):void { map.addEventListener(MapMouseEvent.MAP_CLICK,mapClickHandler) } protected function driveTime_closedHandler(event:Event):void { map.removeLayer(myGraphicsLayer); map.removeEventListener(MapMouseEvent.MAP_CLICK,mapClickHandler) } ]]> </fx:Script>