In the ArcGIS Flex API, you can use the GeometryService service for buffer analysis. Next we will discuss the implementation of buffer analysis. <Esri: GeometryService/> is used to process the Geometry service. To perform buffer analysis, you must first create a Geometry service in the ArcCatalog, after the establishment, we can write code in Flex. I imagine adding a map file first in the map. We can add the local shapfile file to GraphicLayer using the LibertyGIS we mentioned earlier, or we can draw a polygon on GraphicLayer using our own code, click this polygon to perform buffering analysis and add the analysis result to GraphicLayer. The operation is complete. However, it is worth noting that the processing methods of the Points and Points in the buffer analysis are different from those of the line and polygon. Find the following sentence on the Internet: Point (Points) and multipoint (Multipoints ): if the unit is long, such as meters and feet, the geodesic buffering analysis will be performed as is saved med. polylines and Polygons: the unit must be an angle, for example, in decimal format. First, let's take a look at the buffer analysis. The Code is as follows: [java] private function mouseClickHandler (e: MouseEvent): void {var myMapCenterPoint: MapPoint = MapPoint (map. extent. center); var bufferParm: BufferParameters = new BufferParameters (); bufferParm. bufferSpatialReference = map. spatialReference; bufferParm. outSpatialReference = map. spatialReference; bufferParm. unit = GeometryService. UNIT_KILOMETER; bufferParm. distances = [50]; // The unit of length is bufferParm. geometries = [myMapCenterPoint]; myGeometryService. addEventListener (GeometryServiceEvent. BUFFER_COMPLETE, bufferCompleteHandler); myGeometryService. buffer (bufferParm);} function bufferCompleteHandler (event: GeometryServiceEvent): void {var sfs: SimpleFillSymbol = new SimpleFillSymbol ("solid", 0xff0000, 1, sls); myGeometryService. removeEventListener (GeometryServiceEvent. BUFFER_COMPLETE, bufferCompleteHandler); for each (var geometry: Polygon in event. result) {var graphic: Graphic = new Graphic (); graphic. geometry = geometry; graphic. symbol = sfs; graphicsLayer. add (graphic) ;}} private function mouseClickHandler (e: MouseEvent): void {var myMapCenterPoint: MapPoint = MapPoint (map. extent. center); var bufferParm: BufferParameters = new BufferParameters (); bufferParm. bufferSpatialReference = map. spatialReference; bufferParm. outSpatialReference = map. spatialReference; bufferParm. unit = GeometryService. UNIT_KILOMETER; bufferParm. distances = [50]; // The unit of length is bufferParm. geometries = [myMapCenterPoint]; myGeometryService. addEventListener (GeometryServiceEvent. BUFFER_COMPLETE, bufferCompleteHandler); myGeometryService. buffer (bufferParm);} function bufferCompleteHandler (event: GeometryServiceEvent): void {var sfs: SimpleFillSymbol = new SimpleFillSymbol ("solid", 0xff0000, 1, sls); myGeometryService. removeEventListener (GeometryServiceEvent. BUFFER_COMPLETE, bufferCompleteHandler); for each (var geometry: Polygon in event. result) {www.2cto. comvar graphic: Graphic = new Graphic (); graphic. geometry = geometry; graphic. symbol = sfs; graphicsLayer. add (graphic) ;}}result: The reference coordinate system needs to be set for the line or polygon for buffering analysis on the line and polygon, and The radian is used as the distance unit. The following uses the polygon as an example, the Code is as follows: [java] private function mouseClickHandler (e: MouseEvent): void {var gra: Graphic = e. currentTarget as Graphic; var polygon: Polygon = gra. geometry as Polygon; polygon. spatialReference = map. spatialReference; // set reference coordinate system var bufferParm: BufferParameters = new BufferParameters (); bufferParm. bufferSpatialReference = map. spatialReference; bufferParm. outSpatialReference = map. spatialReference; bufferParm. unit = GeometryService. UNIT_KILOMETER; bufferParm. distances = [1, 50/6378137. 0*180.0/Math. PI]; // unit conversion to radian unit bufferParm. geometries = [polygon]; myGeometryService. addEventListener (GeometryServiceEvent. BUFFER_COMPLETE, bufferCompleteHandler); myGeometryService. buffer (bufferParm);} private function mouseClickHandler (e: MouseEvent): void {var gra: Graphic = e. currentTarget as Graphic; var polygon: Polygon = gra. geometry as Polygon; polygon. spatialReference = map. spatialReference; // set reference coordinate system var bufferParm: BufferParameters = new BufferParameters (); bufferParm. bufferSpatialReference = map. spatialReference; bufferParm. outSpatialReference = map. spatialReference; bufferParm. unit = GeometryService. UNIT_KILOMETER; bufferParm. distances = [1, 50/6378137. 0*180.0/Math. PI]; // unit conversion to radian unit bufferParm. geometries = [polygon]; myGeometryService. addEventListener (GeometryServiceEvent. BUFFER_COMPLETE, bufferCompleteHandler); myGeometryService. buffer (bufferParm );}
The result is as follows: