首页 > 代码库 > ArcGIS For Flex学习之Mapping---Switching Basemaps
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 ways10 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.html18 http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/TiledMapServiceLayer.html19 http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/TiledMapServiceLayer.html#tileInfo20 http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/supportClasses/TileInfo.html21 http://resources.arcgis.com/en/help/flex-api/apiref/com/esri/ags/layers/supportClasses/LOD.html22 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.html27 http://resources.arcgis.com/en/help/rest/apiref/tile.html28 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):void42 {43 // update the LODs/zoomslider to use/show the levels for the selected base map44 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 change53 between different basemaps. There are different ways54 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
ArcGIS For Flex学习之Mapping---Switching Basemaps
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。