|
POST
|
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? Right. Perhaps the items are not yet initialized when you ran your code. The best is to use the 'Legend.Refreshed' event for adding/removing/modifying any item you want. Legend.LayerItems is the Service (aka, MapLayer) Legend.LayerItems.LayerItems is the first set of Layers right? Right 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... No, the usage of 10SP1 or of the arcgis.com is transparent. The same legend item tree is created. More likely you tested before the legend tree was populated. Use the legend.refreshed event for that.
... View more
11-19-2010
03:52 AM
|
0
|
0
|
1827
|
|
POST
|
One option is you to develop a value converter (e.g. 'AliasConverter') which is returning the alias from one of the LayerItemViewModel or Layer property. So you could use a maplayertemplate which looks like:
<esri:Legend.MapLayerTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox Content="{Binding Layer.ID, Converter=AliasConverter}"
IsChecked="{Binding IsEnabled, Mode=TwoWay}"
IsEnabled="{Binding IsInScaleRange}" >
</CheckBox>
<Slider Maximum="1" Value="{Binding Layer.Opacity, Mode=TwoWay}" Width="50" />
</StackPanel>
</DataTemplate>
</esri:Legend.MapLayerTemplate>
Or more generally: "{Binding Layer.ID, Converter=LayerConverter, ConverterParameter=Alias}" if you want to use the same converter to retrieve Url, Description, Copyright, ....
... View more
11-18-2010
06:24 AM
|
0
|
0
|
1042
|
|
POST
|
Another option (independent of the legend control), is you to hook up the 'LayerChanged' event of the layers, and if the 'VisibleLayers' or 'Visible' property changes, you apply the same change to your cloned layer.
... View more
11-18-2010
06:14 AM
|
0
|
0
|
3135
|
|
POST
|
I reproduced the issue but it's very unusual and very difficult to reproduce, so very difficult to debug. What is the map service you are using to be able to reproduce the issue a good majority of the time? (if it's a public service)
... View more
11-18-2010
05:17 AM
|
0
|
0
|
1157
|
|
POST
|
For sure, you could do that by code. On the 'Refreshed' event of the legend, you can change the label of the LayerItem from the layername to the alias name. Now that's probably not the best way with MVVM in mind 🙂 Where are coming your aliases from? I don't think there is any layer alias returned by the REST API.
... View more
11-18-2010
05:01 AM
|
0
|
0
|
1042
|
|
POST
|
A Legend control can bind only one map. If you have multiple maps even with the exact same service, the layers are different (one layer can't be included in 2 maps). This means that the visibility, the scale, ... are (or can be) different by map. So the legend control can't display 2 layers with only one legend item. That being said, if you sure that your 2 maps are exactly the same, you can bind the legend control to any of these maps the result will be the same. I am guessing that what you want is to use the legend control to keep in sync your 2 maps. This might probably be done by customizing the legend control (when a layer is checked on or off --> check on or off the same layer in the other map) but I think it would be better to create a separate component to manage that. This component would take care of any layer change, not only those done by the legend control. Not sure I answered to your question, did I?
... View more
11-18-2010
04:56 AM
|
0
|
0
|
3135
|
|
POST
|
So what is the work around??? Is there one? The 2.1 version has no more this limitation. So the workaround is either not to use IE, or to use ArcGIS SL 2.1.
... View more
11-18-2010
04:39 AM
|
0
|
0
|
865
|
|
POST
|
Oh yeah. There was a bug which is fixed with the version I am using (and will be fixed in final). When layer visibilities are changed by API, the GUI was not updated. I forgot it. Sorry about that.
... View more
11-17-2010
12:47 PM
|
0
|
0
|
2047
|
|
POST
|
I would need more info on what you want to do. Let's take an example with the sample you pointed out. The attached screen shot shows the result when the service's visibility is set to false (layer.Visible = false) and when only 2 of 3 sublayers are set to visible (layer.VisibleLayers= {2, 3} ). The checkbox of the service is unchecked (seems what you want) but the checkboxes of the sublayers are depending on the VisibleLayers property (despite the fact that none of these sublayers be visible because the layer itself is checked off). If now you checked on the layer visibility, the sublayers 2 and 3 will be displayed (but the status of the sublayers checkboxes will not change). I am guessing that you need to show if a sublayer is currently viisble or not. For that, you can use the 'IsVisible' property (which is taking of care of the visibility of all ascendants and is also taking care of the scale). But this property is Read-Only, so populate the checkbox with this property is probably not the best use case.
... View more
11-17-2010
12:07 PM
|
0
|
0
|
2047
|
|
POST
|
For those who are interested, I just updated the print map sample. A live version is still available here. After refactoring the code, there are now separate components for: - cloning a map (using an attached property) - displaying the print grid (PrintOverviewLayer) Combining these components gives more output possibilities just by changing the mapprinter style. Example of output : WithLegend/WithOverview (in low definition pdf to reduce file size).
... View more
11-17-2010
10:45 AM
|
0
|
17
|
8116
|
|
POST
|
When all layers of a map are initialized, the event 'LayersInitialized' fires on LayerCollection object. So you can hook up with a code like :
myMap.Layers.LayersInitialized += ....
That being said it's strange that your code is not working by the time the Layer.Initialized event fires. In my opinion, it should work. What is doing your code exactly?
... View more
11-17-2010
07:48 AM
|
0
|
0
|
645
|
|
POST
|
In the sample, the binding is this one:
<CheckBox Content="{Binding Label}"
IsChecked="{Binding IsEnabled, Mode=TwoWay}"
IsEnabled="{Binding IsInScaleRange}" >
'IsInScaleRange' is binded to 'IsEnabled' in order to dim the checkbox. It doesn't affect the check status. You could as well define:
<CheckBox Content="{Binding Label}"
IsChecked="{Binding IsEnabled, Mode=TwoWay}" >
The only difference is that the checkbox will not be grayed when the layer is out of scale.
... View more
11-17-2010
07:28 AM
|
0
|
0
|
2047
|
|
POST
|
My question now is it possible to set the MapTips for FeatureLayers using code behind? Yes, MapTip can be set by code. Example :
TextBlock txtBlock = new TextBlock();
txtBlock.SetBinding(TextBlock.TextProperty, new Binding("[POP1990]"));
graphicLayer.MapTip = new Border() { Child = txtBlock, Background = new SolidColorBrush(Colors.White) };
That being said, I don't see why your maptip is depending on the URL but... Or is there an easier way to achieve this using XAML and code behind? Not sure it's better, but one option is you to create a resource dll including a resource dictionary with the parameters depending on the context, then you merge this dictionary in your project. So you have only the resource dll to change when deploying the application. Example : 1) Create a new 'ResourceProject' with config.xaml file declared as 'Resource':
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
>
<sys:String x:Key="baseLayerUrl">http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer</sys:String>
<sys:String x:Key="featureLayerUrl">http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/2</sys:String>
</ResourceDictionary>
2) In your application, reference the resource project and merge the dictionary in your App.xaml file:
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ESRI.ArcGIS.Tests.Legend.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Styles/Styles.xaml" />
<ResourceDictionary Source="Styles/NavigationStyle.xaml" />
<ResourceDictionary Source="/ResourceProject;Component/config.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
3) In your application, use the parameters as static resource: Example:
Url="{StaticResource baseLayerUrl}"
... View more
11-17-2010
03:35 AM
|
0
|
0
|
693
|
|
POST
|
Please, try after adding this reference to your Silverlight project "System.Windows.Controls.Data.Input".
... View more
11-17-2010
02:49 AM
|
0
|
0
|
713
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-12-2025 03:01 AM | |
| 1 | 10-14-2025 09:24 AM | |
| 1 | 06-13-2013 09:22 AM | |
| 1 | 04-29-2022 02:21 AM | |
| 1 | 04-29-2022 02:28 AM |
| Online Status |
Offline
|
| Date Last Visited |
10-30-2025
08:06 AM
|