ArcGIS API For Flex(在应用程序中添加web地图)

时间:2014-08-29 13:06:07   收藏:0   阅读:363

Add the web map to the application

原文摘录:https://developers.arcgis.com/flex/guide/tutorial-add-a-web-map-to-the-application.htm


这个WebMapUtil类是基于一个给定ID的web map项目信息用来创建地图 ,这个类需要在线的ArcGIS网络地图上工作,也可以使用 ArcGIS 的门户网站,通过设置arcgisSharingURL属性 ,本教程使用Online ArcGIS地图学习


在Flash Builder中,创建一个新的项目,并加入Flex的API库

Editor View编辑器视图中添加下面的代码。另外,请一定要引用ESRI的命名空间

<?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"
   initialize="application_initializeHandler(event)">

<fx:Script>
   <![CDATA[

    import com.esri.ags.events.WebMapEvent;
    import mx.controls.Alert;
    import mx.events.FlexEvent;

    protected function application_initializeHandler(event:FlexEvent):void
    {
     webMapUtil.createMapById("4778fee6371d4e83a22786029f30c7e1");
    }

    protected function webMapUtil_createMapByIdCompleteHandler(event:WebMapEvent):void
    {
     addElementAt(event.map, 0);
    }
   ]]>
</fx:Script>

<fx:Declarations>
   <esri:WebMapUtil id="webMapUtil"
    createMapByIdComplete="webMapUtil_createMapByIdCompleteHandler(event)"
    fault="Alert.show(event.fault.faultString);"/>
   </fx:Declarations>

<s:Label top="10"
   fontSize="24"
   horizontalCenter="0"
   text="ArcGIS.com Web Map"/>

</s:Application>

当程序中initializeHandler 函数被触发,并使用提供的web map ID  4778fee6371d4e83a22786029f30c7e1

一旦地图完成构建,the createMapByIdCompleteHandler 函数就会被触发,event事件调用 Spark container‘s容器addElement 函数在map中传递


运行效果

bubuko.com,布布扣




评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!