ArcGIS API for Flex
Add a map and layers
Version 3.6
The steps below will guide you through displaying a map with a basemap layer in your application. We assume that you have already created a blank project with the referenced API library as discussed in the Getting started section.(下面的步骤将指导您完成显示的地图,在你的应用程序中的底图图层。我们假设您已经创建了被引用的API库的空白项目作为入门节中讨论。 )
The primary way to display geographic information in your application is through a map. The Flex API provides a user interface (UI) Map component. This component lets you display content by either working with layers referencing varIoUs web services such as ArcGIS Server Map and image services,Open Street Map,Bing Maps,OGC WMS etc. or by referencing preconfigured web maps from ArcGIS Online (Esri's cloud),or your own on-premise ArcGIS portal(s).(在应用程序中显示地理信息的主要方式是通过一个地图。 Flex的API提供了一个用户界面(UI)地图组件。该组件允许您通过任何与层参考各种网络服务,如ArcGIS Server的地图和影像服务,开放街道地图,Bing地图,OGC WMS等工作,或者从ArcGIS Online中(Esri的云),或引用预配置的Web地图显示内容你自己的内部部署ArcGIS的门户网站(S))
Flex applications are developed using the MXML and ActionScript languages with the ActionScript class library. MXML can be compared to HTML,as it uses tags to lay out the page. Whereas Actionscript can be compared to Javascript,as this is where the code and logic usually reside.(Flex应用程序正在使用MXML和ActionScript语言与动作类库开发。 MXML可与HTML相比,它使用标签进行布局的页面。而动作脚本可以比较的Javascript,因为这是代码和逻辑通常居住。)
We are going to work strictly in MXML for this tutorial by adding a map UI component to the project initially created in theGetting started topic.(我们将在MXML中加入了地图的UI组件的入门课题最初创建的项目严格工作本教程。)
Add an Esri namespace reference
The first step in displaying a map in your application is to reference the ArcGIS API for Flex library in the MXML. You will do this by adding the Esri namespace. This is added as a property of the application or component you are building.(添加ESRI的命名空间引用
在显示在你的应用程序中的地图的第一步是引用的ArcGIS API,用于Flex库在MXML。您将通过增加ESRI的空间做到这一点。这是添加的应用程序或组件要构建的一个属性。)
- In the Editor view,modify the MXML markup to read(在编辑器视图,修改MXML标记阅读)
-
<?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/mx" minWidth="955" minHeight="600" xmlns:esri="http://www.esri.com/2008/ags"> </s:Application>
-
Now that you added the namespace reference to your markup. You can begin writing code.
Add a map and data to the UI
The next step is to add a map component to your application's UI. This component will act as an empty canvas to which you will later add map content.(下一步是将地图部件添加到您的应用程序的用户界面。此组件将作为一个空的画布,你会在以后添加地图的内容。)
- Add the following markup in the Editor view underneath the namespace reference added above.(添加以下标记中的命名空间参考上面添加下面的编辑器视图。)
-
<?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"> <esri:Map level="3" wrapAround180="true"> <esri:center> <esri:WebMercatorMapPoint lon="0" lat="0"/> </esri:center> </esri:Map> </s:Application>
Next,add theArcGISTiledMapServiceLayer
as the basemap layer to the map. Add theArcGISDynamicMapServiceLayer
displaying world population density onto the basemap layer.(接下来,添加ArcGISTiledMapServiceLayer作为底图图层到地图中。添加theArcGISDynamicMapServiceLayer显示,世界人口密度到底图图层。)
-
.... <esri:Map level="3" wrapAround180="true"> <esri:center> <esri:WebMercatorMapPoint lon="0" lat="0"/> </esri:center> <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/ World_Street_Map/MapServer"/> <esri:ArcGISDynamicMapServiceLayer url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/ Demographics/ESRI_Population_World/MapServer" alpha=".70"/> </esri:Map>
Run the application -
The MXML above adds the
esri:Map
component to the application with a set level and center. In addition to the Map container,you are also adding a tiled map service layer pointing to a REST URL hosting a cached map service and a dynamic map service layer. Upon launching the application,the map displays the tiled map service layer at the third level of detail centered on a latitude and longitude of zero with the dynamic map service layer layered on top.(在MXML上面增加了ESRI:地图组件的一组水平和中心的应用程序。除了地图的容器,你还加入了拼接地图服务图层指向一个REST URL托管缓存的地图服务,动态地图服务层。当启动应用程序时,地图显示平铺地图服务层在细节的中心为零的纬度和经度与层叠在上方的动态地图服务层的第三层。)Tip:
-