Melissa, If you have the FlexViewer2.0 source code than you just have to add some code to the LayerListWidget.mxml. <?xml version="1.0" encoding="utf-8"?> <!-- //////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2010 ESRI // // All rights reserved under the copyright laws of the United States. // You may freely redistribute and use this software, with or // without modification, provided you include the original copyright // and use restrictions. See use restrictions in the file: // <install location>/License.txt // //////////////////////////////////////////////////////////////////////////////// --> <viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:viewer="com.esri.viewer.*" xmlns:toccomp="com.esri.viewer.components.toc.*" widgetConfigLoaded="init()" x="600" y="400"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import com.esri.viewer.components.toc.tocClasses.TocMapLayerItem; private function init():void { toc.map = map; toc.isMapServiceOnly = false; //gotta get this from the config file toc.excludeLayers = getExcludeLayers(); toc.excludeGraphicsLayers = true; callLater(expandTOC); } private function expandTOC():void { toc.openItems = toc.dataProvider.source; for each(var item:TocMapLayerItem in toc.openItems) { if (item.isTopLevel()){ toc.expandItem(item, true); } } } private function getExcludeLayers():ArrayCollection { var result:ArrayCollection = new ArrayCollection(); if (configData && configData.basemaps) { // exclude basemaps for (var i:int = 0; i < configData.basemaps.length; i++) { result.addItem(configData.basemaps.label); } } if (configXML) { // exclude these layers var layers:XMLList = configXML.excludelayer as XMLList; for (var j:Number = 0; j < layers.length(); j++) { result.addItem(layers.toString()); } } return result; } ]]> </fx:Script> <viewer:WidgetTemplate id="wTemplate" height="300" width="300"> <viewer:layout> <s:VerticalLayout gap="8" paddingTop="4"/> </viewer:layout> <s:Label text="Layer Visibility"/> <toccomp:TOC id="toc" height="100%" width="100%"/> </viewer:WidgetTemplate> </viewer:BaseWidget>
<?xml version="1.0" encoding="utf-8"?> <!-- //////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2010 ESRI // // All rights reserved under the copyright laws of the United States. // You may freely redistribute and use this software, with or // without modification, provided you include the original copyright // and use restrictions. See use restrictions in the file: // <install location>/License.txt // //////////////////////////////////////////////////////////////////////////////// --> <viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:viewer="com.esri.viewer.*" xmlns:toccomp="com.esri.viewer.components.toc.*" widgetConfigLoaded="init()" x="600" y="400"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import com.esri.viewer.components.toc.tocClasses.TocMapLayerItem; private function init():void { toc.map = map; toc.isMapServiceOnly = false; //gotta get this from the config file toc.excludeLayers = getExcludeLayers(); toc.excludeGraphicsLayers = true; callLater(expandTOC); } private function expandTOC():void { toc.openItems = toc.dataProvider.source; for each(var item:TocMapLayerItem in toc.openItems) { if (item.isTopLevel()){ toc.expandItem(item, true); } } } private function getExcludeLayers():ArrayCollection { var result:ArrayCollection = new ArrayCollection(); if (configData && configData.basemaps) { // exclude basemaps for (var i:int = 0; i < configData.basemaps.length; i++) { result.addItem(configData.basemaps.label); } } if (configXML) { // exclude these layers var layers:XMLList = configXML.excludelayer as XMLList; for (var j:Number = 0; j < layers.length(); j++) { result.addItem(layers.toString()); } } return result; } ]]> </fx:Script> <viewer:WidgetTemplate id="wTemplate" height="300" width="300"> <viewer:layout> <s:VerticalLayout gap="8" paddingTop="4"/> </viewer:layout> <s:Label text="Layer Visibility"/> <toccomp:TOC id="toc" height="100%" width="100%"/> </viewer:WidgetTemplate> </viewer:BaseWidget>
config="widgets/LayerListWidget.xml"
config="widgets/LayerList/LayerListWidget.xml"
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.