Purpose:
1. ArcGIS. server.9.3 and ArcGIS API for flex implement dynamic layer and tile layer overlapping display, and Display Dynamic layer on the tile base map.
Preparations:
1. Release a map service named USA in ArcGIS. server.9.3 and start the service as dynamic layer data.
2. The rest world map data service provided by ESRI is not available here. The address is http://server.arcgisonline.com/arcgis/rest/services/esri_streetmap_world_2d/mapserver.
After completion:
Start:
1. start flex builder3, click File> New> flex project, enter the project name Project name: flexmapapp, and click Next to select the Output Folder (you do not need to modify the default value) next, the following page is displayed:
2. in the interface above, click library path and then click Add SWC to find the agslib-1.0-beta-2008-07-31.swc file extracted to the directory and click OK. Here, the ArcGIS API for flex Library Development Kit is introduced to the project, you can use the flex component provided by ESRI in the project.
3. here we need to display two types of map data: A tile chart and a dynamic graph. In this way, we need support for arcgistiledmapservicelayer and arcgisdynamicmapservicelayer. For more information, see the first article, here, the tile chart is used as the basemap display. First, you must add arcgistiledmapservicelayer. The specific code is as follows:
Code
1 <? XML version = "1.0" encoding = "UTF-8"?>
2 <mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute" backgroundcolor = "white" xmlns: ESRI = "http://www.esri.com/2008/ags">
3 <mx: canvas width = "500" Height = "300" horizontalcenter = "-63" verticalcenter = "-13" borderstyle = "solid" borderthickness = "2" bordercolor = "#439ad7">
4 <ESRI: Map logovisible = "false" panarrowsvisible = "true">
5 <ESRI: arcgistiledmapservicelayer url = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/>
6 </ESRI: Map>
7 </MX: canvas>
8
9 </MX: Application>
4. the code above is very simple. First, a canvas control is added to the page as a map frame, then, a map control is added to the canvas control and the arcgistiledmapservicelayer is set up to view the world map.
5. Next, you need to publish a dynamic data named USA in ArcGIS. server.9.3 on the basemap, add arcgisdynamicmapservicelayer, and set it. The specific code is as follows: 1 <? XML version = "1.0" encoding = "UTF-8"?>
2 <mx: Application xmlns: MX = "http://www.adobe.com/2006/mxml" layout = "absolute" backgroundcolor = "white" xmlns: ESRI = "http://www.esri.com/2008/ags">
3 <mx: canvas width = "500" Height = "300" horizontalcenter = "-63" verticalcenter = "-13" borderstyle = "solid" borderthickness = "2" bordercolor = "#439ad7">
4 <ESRI: Map logovisible = "false" panarrowsvisible = "true">
5 <ESRI: arcgistiledmapservicelayer url = "http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/>
6 <ESRI: arcgisdynamicmapservicelayer url = "http: // jh-53a435fbc0e8/ArcGIS/rest/services/USA/mapserver">
7 </ESRI: arcgisdynamicmapservicelayer>
8 </ESRI: Map>
9 </MX: canvas>
10
11 </MX: Application>
12
6. added the <ESRI: arcgisdynamicmapservicelayer url = "http: // jh-53a435fbc0e8/ArcGIS/rest/services/USA/mapserver">
</ESRI: arcgisdynamicmapservicelayer> the URL is the rest address of the released USA. After installing ags9.3, you can view all the rest Services published by yourself through the ArcGIS Services Directory menu. In this way, the overlapping display of the two map types is completed. You can run and view the effect.
7. through the browsing effect, we can find that the map display range is very large, not the USA as the display range. In this way, you can set the map display view range in the extent attribute of the map control, here, the data range of USA is set as the default display range of the map. You can find the maximum view range of USA data on the mapserver that browses USA in ArcGIS Services Directory: xmin:-127.968857954995, ymin: 25.5778580720472, xmax:-65.0742781827045, Ymax: 51.2983251993735, add an ESRI: extent tag in MX: application according to these parameters:
1 <ESRI: extent id = "allusa" xmin = "-183.780014745329" ymin = "16.2975638854873" xmax = "-61.4068547410964" Ymax = "74.0304580085983"/>
8. add an extent = "{allusa}" attribute to ESRI: map, and set the default view range of the map control to ectent with the ID of allusa. This completes the exercise.
9. you can also set mapservicelayer to select the layers you want to display. For example, four layers in the map data of USA are cities, highways, states, and counties, now you only want to display the states and counties layers. You can add the following code:
Code
1 <ESRI: arcgisdynamicmapservicelayer url = "http: // jh-53a435fbc0e8/ArcGIS/rest/services/USA/mapserver">
2 <ESRI: visiblelayers>
3 <mx: arraycollection>
4 <mx: number> 2 </MX: number>
5 <mx: number> 3 </MX: number>
6 </MX: arraycollection>
7 </ESRI: visiblelayers>
8 </ESRI: arcgisdynamicmapservicelayer>