使用bufferservice

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
               xmlns:s="library://ns.adobe.com/flex/spark"
               xmlns:esri="http://www.esri.com/2008/ags"
               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.
    -->

    <s:controlBarLayout>
        <s:HorizontalLayout horizontalAlign="center"
                            paddingBottom="7"
                            paddingTop="7"/>
    </s:controlBarLayout>
    <s:controlBarContent>
        <s:Button click="bufferCenterOfMap()" label="Buffer Center Of Map"/>
    </s:controlBarContent>

    <fx:Declarations>
        <esri:SimpleFillSymbol id="sfs" color="0xFF0000">
            <esri:SimpleLineSymbol color="0x000000"/>
        </esri:SimpleFillSymbol>
        <esri:GeometryService id="myGeometryService" url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"/>
    </fx:Declarations>

    <fx:Script>
        <![CDATA[
            import com.esri.ags.Graphic;
            import com.esri.ags.SpatialReference;
            import com.esri.ags.events.GeometryServiceEvent;
            import com.esri.ags.geometry.MapPoint;
            import com.esri.ags.geometry.Polygon;
            import com.esri.ags.tasks.supportClasses.BufferParameters;

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

                var bufferParameters:BufferParameters = new BufferParameters();
                // Note: As of version 2.0, the GeometryService input is geometries (instead of graphics).
                bufferParameters.geometries = [ myMapCenterPoint ];
                bufferParameters.distances = [ 50, 100 ];
                // Note: As of version 2.0, the buffer constants have been moved to GeometryService.
                bufferParameters.unit = GeometryService.UNIT_KILOMETER;
                bufferParameters.bufferSpatialReference = new SpatialReference(4326);
                bufferParameters.outSpatialReference = myMap.spatialReference;

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

                function bufferCompleteHandler(event:GeometryServiceEvent):void
                {
                    myGeometryService.removeEventListener(GeometryServiceEvent.BUFFER_COMPLETE, bufferCompleteHandler);
                    // Note: As of version 2.0, GeometryService returns geometries (instead of graphics)
                    for each (var geometry:Polygon in event.result)
                    {
                        var graphic:Graphic = new Graphic();
                        graphic.geometry = geometry;
                        graphic.symbol = sfs;
                        graphicsLayer.add(graphic);
                    }
                }
            }
        ]]>
    </fx:Script>

    <esri:Map id="myMap"
              crosshairVisible="true"
              level="3">
        <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
        <esri:GraphicsLayer id="graphicsLayer"/>
    </esri:Map>

</s:Application>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值