Flex4 ArcGis地图服务操作

前端开发 作者: 2024-08-25 15:50:01
1.简单使用
1.简单使用
<?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="Example #1">

    <esri:Map>

        <esri:ArcGISTiledMapServiceLayer

            url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />

    </esri:Map>

</s:Application>

2.定位地图位置
<?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:mx="library://ns.adobe.com/flex/halo"

    xmlns:esri="http://www.esri.com/2008/ags"

    pageTitle="A tiled map service"

    >

 

    <esri:Map>

        <esri:extent>

            <esri:Extent xmin="-1788000" ymin="-4177000" xmax="10044000" ymax="4511000">

                <esri:SpatialReference wkid="102100"/>

            </esri:Extent>

        </esri:extent>

        <esri:ArcGISTiledMapServiceLayer

            url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>

    </esri:Map>

</s:Application>

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

               xmlns:mx="library://ns.adobe.com/flex/mx"

               xmlns:esri="http://www.esri.com/2008/ags"

               xmlns:s="library://ns.adobe.com/flex/spark"

               pageTitle="Query Task (with a map)">

 

    <s:layout>

        <s:VerticalLayout gap="10"

                          horizontalAlign="center"

                          paddingBottom="20"

                          paddingLeft="25"

                          paddingRight="25"

                          paddingTop="20"/>

    </s:layout>

 

    <fx:Script>

        <![CDATA[

            import com.esri.ags.Graphic;

            import com.esri.ags.FeatureSet;

            import mx.controls.Alert;

            import mx.rpc.AsyncResponder;

 

            private function doQuery():void

            {

                queryTask.execute(query,new AsyncResponder(onResult,onFault));

                function onResult(featureSet:FeatureSet,token:Object = null):void

                {

                    // No code needed in this simple sample,since the

                    // graphiclayer is bound to the query result using

                    // graphicProvider="{queryTask.executeLastResult.features}"

                }

                function onFault(info:Object,token:Object = null):void

                {

                    Alert.show(info.toString(),"Query Problem");

                }

            }

        ]]>

    </fx:Script>

 

    <fx:Declarations>

        <!-- Layer with US States -->

        <esri:QueryTask id="queryTask"

                        showBusyCursor="true"

                        url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0"

                        useAMF="false"/>

 

        <esri:Query id="query"

                    outSpatialReference="{myMap.spatialReference}"

                    returnGeometry="true"

                    text="{qText.text}">

            <esri:outFields>

                <fx:String>CITY_NAME</fx:String>

                <fx:String>STATE_NAME</fx:String>

            </esri:outFields>

        </esri:Query>

        <esri:InfoSymbol id="infoSymbol1">

            <esri:infoRenderer>

                <fx:Component>

                    <mx:VBox>

                        <mx:Label text="{data.CITY_NAME}"/>

                        <mx:Label text="{data.STATE_NAME }"/>

                    </mx:VBox>

                </fx:Component>

            </esri:infoRenderer>

        </esri:InfoSymbol>

    </fx:Declarations>

 

    <s:Panel backgroundColor="0xB2BFC6"

             height="60"

             title="Query a layer (search for a state)">

        <s:layout>

            <s:HorizontalLayout/>

        </s:layout>

        <s:TextInput id="qText"

                     enter="doQuery()"

                     text="San Jose"

                     width="100%"/>

        <s:Button click="doQuery()" label="Do Query"/>

    </s:Panel>

 

    <esri:Map id="myMap">

        <esri:extent>

            <esri:Extent xmin="-14298000" ymin="2748000" xmax="-6815000" ymax="7117000">

                <esri:SpatialReference wkid="102100"/>

            </esri:Extent>

        </esri:extent>

        <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Physical_Map/MapServer"/>

        <esri:GraphicsLayer id="myGraphicsLayer" graphicProvider="{queryTask.executeLastResult.features}" symbol="{infoSymbol1}"/>

    </esri:Map>

 

</s:Application>
原创声明
本站部分文章基于互联网的整理,我们会把真正“有用/优质”的文章整理提供给各位开发者。本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
本文链接:http://www.jiecseo.com/news/show_68474.html
flex4 flex 4 arcgis 地图 服务 操作