<API 2.0>Switching Basemaps

本文展示了一个允许用户在不同底图之间切换的示例,并确保根据所选底图更新细节层级(LOD)。如果所有底图都具有相同的LOD,则不需要使用layerShowHandler函数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://help.arcgis.com/en/webapi/flex/samples/index.html

<Mapping>---->Switching Basemaps

 

<? 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:esri
="http://www.esri.com/2008/ags"
               pageTitle
="Toggle between Map Services" >
    
<!--
    This sample shows one way of allowing users to change between different basemaps.
    It also ensures that the levels of detail (LOD) are updated based on which basemap is selected.
    If all base maps have the same LODs, you wouldn't need the layerShowHandler function.
    
-->
    
< fx:Script >
        
<![CDATA[
            import com.esri.ags.geometry.MapPoint;
            import com.esri.ags.layers.TiledMapServiceLayer;
            
            import mx.events.FlexEvent;
            
            private function layerShowHandler(event:FlexEvent):void
            {
                // update the LODs/zoomslider to use/show the levels for the selected base map
                var tiledLayer:TiledMapServiceLayer = event.target as TiledMapServiceLayer;
                myMap.lods = tiledLayer.tileInfo.lods;
            }
        
]]>
    
</ fx:Script >
    
    
< esri:Map  id ="myMap"
              level
="4"
              load
="myMap.centerAt(new MapPoint(-11713000, 4822000))" >
        
< esri:ArcGISTiledMapServiceLayer  show ="layerShowHandler(event)"
                                         url
="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
                                         visible
="{bb.selectedIndex == 0}" />
        
< esri:ArcGISTiledMapServiceLayer  show ="layerShowHandler(event)"
                                         url
="http://server.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer"
                                         visible
="{bb.selectedIndex == 1}" />
        
< esri:ArcGISTiledMapServiceLayer  show ="layerShowHandler(event)"
                                         url
="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"
                                         visible
="{bb.selectedIndex == 2}" />
    
</ esri:Map >
    
< s:ButtonBar  id ="bb"
                 right
="5"  top ="5"
                 requireSelection
="true" >
        
< s:dataProvider >
            
< s:ArrayList >
                
< fx:String > Streets </ fx:String >
                
< fx:String > U.S. Topo </ fx:String >
                
< fx:String > Imagery </ fx:String >
            
</ s:ArrayList >
        
</ s:dataProvider >
    
</ s:ButtonBar >
</ s:Application >

显示:

转载于:https://www.cnblogs.com/pandy/archive/2011/06/10/2077512.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值