public void SetCustomLegend(LayerItemViewModel serviceLayerItemViewModel, String layerID, ObservableCollection<LegendItemViewModel> legendItems) { LayerItemViewModel layerItemViewModel = GetLegendLayer(serviceLayerItemViewModel, layerID); if (layerItemViewModel != null) layerItemViewModel.LegendItems = legendItems; }
protected LayerItemViewModel GetLegendLayer(LayerItemViewModel parentLayer, String layerID) { if(parentLayer.LayerItems != null) { for (Int32 i = 0; i < parentLayer.LayerItems.Count; i++) { //If match, return it if (parentLayer.LayerItems.Label == layerID) return parentLayer.LayerItems; //Check sub layers LayerItemViewModel layerItemViewModel = GetLegendLayer(parentLayer.LayerItems, layerID); if (layerItemViewModel != null) return layerItemViewModel; //Continue checking other layers } } return null; }
Legend.Refreshed is called a bunch of times
Legend.LayerItems.LayerItems.LegendItems = newLegendItems;but the second LayerItems collection is null... this should be the first row of actual layers in the service right?
Legend.LayerItems is the Service (aka, MapLayer)Legend.LayerItems.LayerItems is the first set of Layersright?
Also, a bit of a side question, I am using ArcGIS Server 10 SP1, but all the Legend.LayerItems are null... does this mean the legend is going out and using ESRI's legend REST service? All my services were published in 10 before SP1, do I need to publish them again? I tried publishing one from Desktop 10 SP1 and it still is null in the API...
public MainPage() { InitializeComponent(); this.MyMap.Layers.LayersInitialized += Layers_LayersInitialized; } bool allLayersInitialized; void Layers_LayersInitialized(object sender, EventArgs args) { if (!allLayersInitialized) { foreach (var l in this.MyLegend.LayerItems) { if (l.LegendItems == null) { l.LegendItems = new ObservableCollection<LegendItemViewModel>(); l.LegendItems.Add(new LegendItemViewModel() { ImageSource = new BitmapImage(new Uri("/image/car-blue-32x32.png", UriKind.Relative)), Description = "test" }); } } allLayersInitialized = true; } }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.