xmlns:esri="http://schemas.esri.com/arcgis/client/2009"> <Grid x:Name="LayoutRoot" Background="White"> <esri:Map x:Name="MyMap" WrapAround="True" Extent="-15000000,2000000,-7000000,8000000"> <esri:ArcGISTiledMapServiceLayer Url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" /> </esri:Map> <StackPanel VerticalAlignment="Top" HorizontalAlignment="Center"> <Button Content="Add WMS" Click="Button_Click"/> <ListBox x:Name="LayerList" SelectionMode="Multiple" SelectionChanged="LayerList_SelectionChanged"> <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Name}"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </StackPanel> </Grid>
private void Button_Click(object sender, RoutedEventArgs e) { var wmsLayer = new WmsLayer() { ID="MyWmsLayer", Url = "http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi", ProxyUrl = "http://serverapps.esri.com/SilverlightDemos/ProxyPage/proxy.ashx", SkipGetCapabilities = false, Version = "1.1.1", Opacity = 0.7, //Layers =new string[]{ "nexrad-n0r"} }; wmsLayer.Initialized += (a, b) => { LayerList.ItemsSource = (a as WmsLayer).LayerList; }; MyMap.Layers.Add(wmsLayer); } private void LayerList_SelectionChanged(object sender, SelectionChangedEventArgs e) { var layerList = new List<string>(); var wmsLayer = MyMap.Layers["MyWmsLayer"] as WmsLayer; if (wmsLayer.Layers != null) { foreach (var l in wmsLayer.Layers) layerList.Add(l); } if (e.AddedItems != null) { foreach(var item in e.AddedItems) { var info = item as WmsLayer.LayerInfo; layerList.Add(info.Name); } } if (e.RemovedItems != null) { foreach (var item in e.RemovedItems) { var info = item as WmsLayer.LayerInfo; layerList.Remove(info.Name); } } wmsLayer.Layers = layerList.ToArray(); }
<esri:Map.Extent> <esri:Envelope XMin="-14930991.170" YMin="3611744.037" XMax="-11348896.882" YMax="5340571.181"> <esri:Envelope.SpatialReference> <esri:SpatialReference WKID="3857"/> </esri:Envelope.SpatialReference> </esri:Envelope> </esri:Map.Extent>
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.