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

时间: 2024-08-01 18:52:45

ArcGIS For Flex学习之Mapping---Switching Basemaps的相关文章

arcgis for flex 学习笔记(一)

初步认识 地图由图层.要素.样式等组成.地图上有N个图层,图层上有N个要素,每个要素可以存放点.线.面等,每个要素可以设置样式,如果显示图片.或文字均可以先创建一个mxml组件,然后设置到要素上. 面和线都是由点组成的. 添加点 1.首先初始化图层,GraphicsLayer. 2.获取坐标点,MapPoint. 3.创建要素,Graphic. 4.设置样式 Symbol. 5.添加要素至Layer,即是第一步创建的图层. 添加线 在添加点的基础上多了一个步骤. 获取到多个点,可以实例化一个线对

ArcGIS For Flex学习之Layers---控制图层的显示与否(利用DataGrid)

这个例子演示的是通过右侧DataGrid中的复选框来控制相应图层的可见性,由于ArcGISDynamicMapServiceLayer的defaultVisibility属性在地图发布时均为可见(true),所以开始时复选框均为选中状态,注意一下几点:(1)DataGrid的数据源为图层的LayerInfos(其中包括defaultVisibility.layerId.name等,可以用作某些控件的dataField属性):(2)复选框的select以及click属性:(3)复选框在选中状态时,

ArcGIS For Flex学习之Mapping---Select and zoom

Tips:这个例子说明如何在图层中选择或反选几何对象,当点击地图时,触发mapClick事件,激活QueryTask,这里的Query中的query.geometry = event.mapPoint;利用鼠标点击的点来查找包括该选择点的Polygon,然后将查询到的几何要素添加到GraphicsLayer中并放大一个级别:同时,再次点击选择的要素时,触发unselectGraphic事件,并从GraphicsLayer中移除该要素.具体效果图及代码如下: 1 <?xml version="

【转】【Flex】FLEX 学习网站分享

[转:http://hi.baidu.com/tanghecaiyu/item/d662fbd7f5fbe02c38f6f764 ] FLEX 学习网站分享 http://blog.minidx.com/flex核心开发技术:http://blog.csdn.net/mervyn_lee/archive/2008/10/07/3027039.aspxfl部落:http://www.fltribe.com/捕鱼者说http://www.cnblogs.com/fishert/category/85

ArcGIS for Android学习(一)

GIS的开发中,什么时候都少不了地图操作.ArcGIS for Android中,地图组件就是MapView,MapView是基于Android中ViewGroup的一个类(参考),也是ArcGIS Runtime SDK for Android中的地图容器,与很多ArcGIS API中的Map.MapControl类的作用是一样的. 地图常见的操作有缩放.旋转.平移.获取范围.比例尺.分辨率等信息,以及常用的手势操作,其中,经常使用到的功能和常见问题有以下几个: 1)将地图缩放到指定的比例尺/

arcgis for flex api version3.7 教程:8.创建地图

地图概述: arcgis for flex api提供了大量的方法来实现地图操作和交互.首先,地图(map)支持添加各种类型的图层或服务.图层数据来源可以是arcgis server.Bing maps.graphics layers等.此外还有可以使用网络公开的其他服务像arcgis.com或自建的.网络地图服务有相似的一面,都通过一定的方法支持各种类型的图层 ,任务和数据(数据可以扩展,例如可以是.csv和.gpx文件作为一个组合).下面我们将对此做详细讨论. 创建地图并设置显示范围和空间参

arcgis for flex api version3.7 教程:10.打印服务功能简介

高质量的打印功能是arcgis server 10.1的新特性功能.arcgis api for flex在3.x版本之前使用的是flex sdk基本的打印功能.而完全的在线制图打印功能需要web应用来实现. arcgis api for flex 高级打印功能是通过printtask类来实现的.该类通过arcgis 10.1版本的export web map GP服务来实现,可以进行配置,提供输出设置,可以是PDF,PNG,SVG. 在作用GP服务之前,需要启动arcgis 10.1打印服务(

arcgis for flex全国地图天气预报的具体实现过程解析

系统架构是B/S,开发语言是flex,开发工具是myeclise或者flashbuild,通过调用百度提供的在线天气预报web api接口的方式来实现. 采用地图是ArcGIS全国地图,开发接口为arcgis api for flex,但是程序可以拓展api 接口,可以采用其他GIS api,地图数据也可以更换其他地图数据,拓展性比较好. 先谈谈主界面的布局,只是简单的设计了大概的布局,如下: 首先是两行,第一行是标题:第二行再分为两列,第一列是用来天气预报查询以及显示查询的结果,第二列用来显示

CSS3伸缩布局Flex学习笔记

如果需要使用伸缩布局首先得把display:flex;对于兼容还得加前缀display:-webkit-display:flex;等其他浏览器前缀,但我本机Chrome测试已经不需要加前缀了,其实这些还好,关键移动端竟然不支持这个属性,移动端支持的还是老版本的display:-webki-box;不过对于学习来说,也不管它支持不支持了,学了再说吧,更何况Chrome已经把flex的前缀去了,说明flex多少还是有些稳定的. 下面列出了关于CSS与flex一起使用的一些属性 display 显示方