原文摘录: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中传递
运行效果

ArcGIS API For Flex(在应用程序中添加web地图)
原文地址:http://blog.csdn.net/xiaokui_wingfly/article/details/38922069