ArcGIS For Flex学习之Mapping---Switching Basemaps

今天开始系统的学习ArcGIS For Flex,先从ESRI的例子学起

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
 3                xmlns:s="library://ns.adobe.com/flex/spark"
 4                xmlns:esri="http://www.esri.com/2008/ags"
 5                pageTitle="Toggle between Map Services">
 6     <!--
 7     Description:
 8     This sample demonstrates how to allow users to change
 9     between different basemaps.  There are different ways
10     to visually accomplish this behavior, this is just one example.
11 
12     It also ensures that the levels of detail (LOD) are updated based on which basemap is selected.
13     If all base maps have the same LODs, you wouldn‘t need the layerShowHandler function.
14 
15     Documentation:
16     For more information, see the API documentation.
17     http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/geometry/MapPoint.html
18     http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/TiledMapServiceLayer.html
19     http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/TiledMapServiceLayer.html#tileInfo
20     http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/supportClasses/TileInfo.html
21     http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/supportClasses/LOD.html
22 
23     http://resources.arcgis.com/en/help/flex-api/concepts/index.html#/Types_of_layers/017p00000027000000/
24 
25     ArcGIS REST API documentation:
26     http://resources.arcgis.com/en/help/rest/apiref/mapserver.html
27     http://resources.arcgis.com/en/help/rest/apiref/tile.html
28 
29     ArcGIS for Server documentation:
30     http://resources.arcgis.com/en/help/main/10.1/#/What_is_a_map_service/0154000002m7000000/
31     http://resources.arcgis.com/en/help/main/10.1/#/What_is_map_caching/01540000048q000000/
32     -->
33 
34     <fx:Script>
35         <![CDATA[
36             import com.esri.ags.geometry.MapPoint;
37             import com.esri.ags.layers.TiledMapServiceLayer;
38 
39             import mx.events.FlexEvent;
40 
41             private function layerShowHandler(event:FlexEvent):void
42             {
43                 // update the LODs/zoomslider to use/show the levels for the selected base map
44                 var tiledLayer:TiledMapServiceLayer = event.target as TiledMapServiceLayer;
45                 myMap.lods = tiledLayer.tileInfo.lods;
46             }
47         ]]>
48     </fx:Script>
49 
50     <s:controlBarContent>
51         <s:RichText width="100%">
52             This sample demonstrates how to allow users to change
53             between different basemaps.  There are different ways
54             to visually accomplish this behavior, this is just one example.
55             Click the different buttons on the bar below to switch basemaps.
56         </s:RichText>
57     </s:controlBarContent>
58 
59     <esri:Map id="myMap"
60               level="4"
61               load="myMap.centerAt(new MapPoint(-11713000, 4822000))">
62         <esri:ArcGISTiledMapServiceLayer show="layerShowHandler(event)"
63                                          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
64                                          visible="{bb.selectedIndex == 0}"/>
65         <esri:ArcGISTiledMapServiceLayer show="layerShowHandler(event)"
66                                          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"
67                                          visible="{bb.selectedIndex == 1}"/>
68         <esri:ArcGISTiledMapServiceLayer show="layerShowHandler(event)"
69                                          url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"
70                                          visible="{bb.selectedIndex == 2}"/>
71         <esri:ArcGISTiledMapServiceLayer show="layerShowHandler(event)"
72                                          url="http://server.arcgisonline.com/ArcGIS/rest/services/Ocean_Basemap/MapServer"
73                                          visible="{bb.selectedIndex == 3}"/>
74         <esri:ArcGISTiledMapServiceLayer show="layerShowHandler(event)"
75                                          url="http://server.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer"
76                                          visible="{bb.selectedIndex == 4}"/>
77     </esri:Map>
78     <s:ButtonBar id="bb"
79                  right="5" top="5"
80                  requireSelection="true">
81         <s:dataProvider>
82             <s:ArrayList>
83                 <fx:String>Streets</fx:String>
84                 <fx:String>Topographic</fx:String>
85                 <fx:String>Imagery</fx:String>
86                 <fx:String>Oceans</fx:String>
87                 <fx:String>National Geographic</fx:String>
88             </s:ArrayList>
89         </s:dataProvider>
90     </s:ButtonBar>
91 </s:Application>

转载地址:https://developers.arcgis.com/flex/sample-code/switching-basemaps.htm

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。