Select to view content in your preferred language

Getting Data from Buffer

555
1
08-12-2010 08:23 AM
ShaunCunningham
New Contributor
Hi, I am new to programming with Flex and GIS.  I am using Flex 3.0. I have followed the example  from the samples "Buffer Using Geometry Service" under "Geometry Service" in order to create a buffer around my point of interest. (http://resources.esri.com/help/9.3/arcgisserver/apis/flex/samples/index.html).

However, I am running into problems getting the data in the buffer.  Does anyone know how to do this? The main code from the example is pasted below. Thanks in advance.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:esri="http://www.esri.com/2008/ags"
    layout="absolute"
    pageTitle="Buffer using the Geometry Service">
<!--
    This sample creates buffers around the center of the map. This example just draws the buffers,
    but the buffers could also be used to perform a task such as returning a list of addresses of
    people who live within the buffered area.
-->
    <mx:Script>
        <![CDATA[
            import com.esri.ags.SpatialReference;
            import com.esri.ags.events.GeometryServiceEvent;
            import com.esri.ags.tasks.BufferParameters;
            import com.esri.ags.Graphic;

            private function bufferCenterOfMap():void
            {
                var myMapCenterPoint:Graphic = new Graphic();
                myMapCenterPoint.geometry = myMap.extent.center;

                var bufferParameters:BufferParameters = new BufferParameters();
                bufferParameters.features = [myMapCenterPoint];
                bufferParameters.distances = [2000, 4000];
                bufferParameters.unit = BufferParameters.UNIT_METER;
                bufferParameters.bufferSpatialReference = new SpatialReference(102113);

                myGeometryService.addEventListener(GeometryServiceEvent.BUFFER_COMPLETE, bufferCompleteHandler);
                myGeometryService.buffer(bufferParameters);

                function bufferCompleteHandler(event:GeometryServiceEvent):void
                {
                    myGeometryService.removeEventListener(GeometryServiceEvent.BUFFER_COMPLETE, bufferCompleteHandler);
                    for each (var graphic:Graphic in event.graphics)
                    {
                        graphic.symbol = sfs;
                        myGraphicsLayer.add(graphic);
                    }
                }
            }
        ]]>
    </mx:Script>
    <esri:SimpleFillSymbol id="sfs" color="0xFF0000">
        <esri:SimpleLineSymbol color="0x000000"/>
    </esri:SimpleFillSymbol>
    <esri:GeometryService id="myGeometryService"
        url="http://sampleserver2.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"/>
    <mx:Panel width="100%" height="100%">
        <mx:ControlBar>
            <mx:Button label="Buffer Center Of Map" click="bufferCenterOfMap()"/>
        </mx:ControlBar>
        <esri:Map id="myMap" crosshairVisible="true">
            <esri:ArcGISTiledMapServiceLayer
               

url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Portland/ESRI_LandBase_WebMercator/MapSer..."/>
            <esri:GraphicsLayer id="myGraphicsLayer"/>
        </esri:Map>
    </mx:Panel>
</mx:Application>
Tags (2)
0 Kudos
1 Reply
DasaPaddock
Esri Regular Contributor
Here's a more complete sample:
http://resources.esri.com/help/9.3/arcgisserver/apis/flex/samples/index.html?sample=FreehandBufferGP

You could also use the buffer result as the input to a QueryTask.

Since you're just starting, you may want to start with the current 2.0 version available at:
http://help.arcgis.com/en/webapi/flex/
0 Kudos