|
POST
|
Thank you for sharing. Alternatively, you can use FeatureDataForm with Silverlight Toolkit Data Pager. FeatureDataForm adjusts its field container based on the field type. For example, a coded-value domain will use ComboBox instead of TextBox, a DateTime will use DateTimePicker. Attribute values are also converted to their corresponding type. Validation and saving edits are handled by the FeatureDataForm.
... View more
01-21-2011
06:58 PM
|
0
|
0
|
3658
|
|
POST
|
Good point, you need to unsubscribe the old map from its events and subscribe the new map to the same event handler. I think you can only reuse the same name after you have removed the old map instance from your visual tree.
LayerCollection otherLayers = new LayerCollection();
Map map = this.LayoutRoot.Children[0] as Map;
map.Loaded -= MyMap_Loaded;
map.ExtentChanged -= MyMap_ExtentChanged;
foreach (var layer in map.Layers)
if (!string.Equals(layer.ID, "BaseLayer", StringComparison.InvariantCultureIgnoreCase))
otherLayers.Add(layer);
map.Layers.Clear();
ArcGISTiledMapServiceLayer arcgisLayer = new ArcGISTiledMapServiceLayer()
{
ID = "BaseLayer",
Url = ((RadioButton)sender).Tag as string
};
this.LayoutRoot.Children.Remove(map);
Map newMap = new Map() { Name = "MyMap" };
newMap.SetValue(Grid.RowProperty, 0);
this.LayoutRoot.Children.Insert(0, newMap);
newMap.Layers.Add(arcgisLayer);
newMap.Loaded += MyMap_Loaded;
newMap.ExtentChanged += MyMap_ExtentChanged;
foreach (var layer in otherLayers)
newMap.Layers.Add(layer);
However, in trying this code out. I found that this.MyMap still refers to the old instance. Same is true when I played with TextBox with TextChanged event.
private void MyMap_ExtentChanged(object sender, ExtentEventArgs e)
{
ArcGISTiledMapServiceLayer baseLayer = this.MyMap.Layers[0] as ArcGISTiledMapServiceLayer;
}
this.MyMap.Layers.Count is 0 as this refers to the old instance. (this.LayoutRoot.Children[0] as Map).Layers.Count is 2 as this refers to the new instance. And if you check for this.LayoutRoot.Children[0] as Map).Name, it is MyMap. I don't know if this is expected behavior or bug in VS as I found the same behavior with TextBox, where this.OldTb.Text still contained the old instance' text value after creating a new instance with the same name. I think then that the best way to get your map is to know it's position in the visual tree Map map = this.LayoutRoot.Children[0] as Map; //this is guaranteed to be the current map.
... View more
01-21-2011
08:15 AM
|
0
|
0
|
2423
|
|
POST
|
If you will be using FeatureLayer or GraphicsLayer, you can use Editor.Select http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#EditToolsAutoSave or EditorWidget http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ToolkitEditorWidget. Either solutions will make a selection across different layers of same or different geometries and you can access them through SelectedGraphics property http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.GraphicsLayer~SelectedGraphics.html(available in either FeatureLayer or GraphicsLayer).
... View more
01-20-2011
10:04 PM
|
0
|
0
|
1607
|
|
POST
|
The difference is - this.MyMap is an instance of a map control, this.LayoutRoot.Children[0] is the first UIElement in the grid. Since you will be switching two map controls in the same grid location, it would be easier to grab the element from the container rather than access the map instance by name. Take the following for example. Let's say you need TextBox replaced with another TextBox. <Grid x:Name="LayoutRoot"> <TextBox x:Name="MyTextBox"/> </Grid> You cannot replace MyTextBox with a new TextBox instance by accessing the old instance by name. You would only do so when you want to copy properties from another TextBox. MyTextBox.Text = anotherTextBox.Text; To replace the UIElement, you would do the following instead. LayoutRoot.Children[0] = anotherTextBox;
... View more
01-20-2011
09:48 PM
|
0
|
0
|
2423
|
|
POST
|
You may want to subscribe to QueryTask Failed event as well. It might be useful to run Fiddler with your app too.
... View more
01-20-2011
09:34 PM
|
0
|
0
|
358
|
|
POST
|
Thank you for your post. We'll consider this for future enhancement. For the meantime, you can subscribe to the layer's EndSaveEdits and maybe do the following:
private void FeatureLayer_EndSaveEdits(object sender, EndEditEventArgs e)
{
if(e.Results== null|| e.Results.UpdateResults == null) return;
FeatureLayer layer = sender as FeatureLayer;
foreach (var item in e.Results.UpdateResults)
{
Graphic graphic = layer.Graphics.Where(g =>(int) g.Attributes[layer.LayerInfo.ObjectIdField] ==(int) item.ObjectID).First();
//TODO: your code goes here
}
}
... View more
01-20-2011
11:24 AM
|
0
|
0
|
353
|
|
POST
|
This is related thread http://forums.arcgis.com/threads/14852-Toolbar-icons-are-not-visible (see Post #6). In the SDK sample, you will find the Assets folder in the website project. Where you save the images is completely up to you. Basically, you add images to your project and update the Image Source property to point to that image location.
... View more
01-20-2011
10:58 AM
|
0
|
0
|
2113
|
|
POST
|
If you would like to change an element's visiblity through StoryBoard, you can look at this: http://msdn.microsoft.com/en-us/library/system.windows.uielement.visibility(v=vs.95).aspx where TargetName is the name of your collapsed Border.
... View more
01-19-2011
01:51 PM
|
0
|
0
|
1363
|
|
POST
|
Url is not a DependencyProperty that's why you cannot Bind to it. In addition to J's sample, you can also look at : http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SwitchMap. The ArcGISTiledMapServiceLayer.Url is updated in code-behind.
... View more
01-19-2011
01:40 PM
|
0
|
0
|
748
|
|
POST
|
I tried your sample and I faced the same issues so I think this would be a better approach. I adapted the following code from this sample: http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#SwitchMap XAML-code:
xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
<Grid x:Name="LayoutRoot" Background="White">
<esri:Map x:Name="MyMap" Loaded="MyMap_Loaded">
<esri:ArcGISTiledMapServiceLayer ID="BaseLayer" Visible="True"
Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer" />
<esri:ArcGISDynamicMapServiceLayer ID="MyLayer"
Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer" />
</esri:Map>
<Grid HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10" >
<Rectangle Fill="#77919191" Stroke="Gray" RadiusX="10" RadiusY="10" Margin="0" >
<Rectangle.Effect>
<DropShadowEffect/>
</Rectangle.Effect>
</Rectangle>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Background="Transparent" Margin="10">
<RadioButton x:Name="StreetsRadioButton"
Tag="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_ShadedRelief_World_2D/MapServer"
IsChecked="true" Margin="5,0,0,0" Foreground="White"
GroupName="Layers" Content="4326" Click="RadioButton_Click"/>
<RadioButton x:Name="TopoRadioButton"
Tag="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"
Margin="5,0,0,0" Foreground="White"
GroupName="Layers" Content="102100" Click="RadioButton_Click"/>
</StackPanel>
</Grid>
</Grid>
To switch out the base layer, you can first copy all other layers to another layer collection (just as you did), excluding the base layer that you want replaced. Clear the old map layers so that you can add the copied layers to another map control. Create a new map control. Add the new base layer to this new map and add the other layers. Once the new map control is set, you can replace the old map control with this.
private void RadioButton_Click(object sender, RoutedEventArgs e)
{
LayerCollection otherLayers = new LayerCollection();
Map map = this.LayoutRoot.Children[0] as Map;
foreach(var layer in map.Layers)
if(!string.Equals(layer.ID, "BaseLayer", StringComparison.InvariantCultureIgnoreCase))
otherLayers.Add(layer);
map.Layers.Clear();
ArcGISTiledMapServiceLayer arcgisLayer = new ArcGISTiledMapServiceLayer()
{
ID="BaseLayer",
Url = ((RadioButton)sender).Tag as string
};
Map newMap = new Map();
newMap.Layers.Add(arcgisLayer);
foreach (var layer in otherLayers)
newMap.Layers.Add(layer);
this.LayoutRoot.Children[0] = newMap;
}
private void MyMap_Loaded(object sender, RoutedEventArgs e)
{
MyMap.Focus();
}
... View more
01-19-2011
10:09 AM
|
0
|
0
|
2423
|
|
POST
|
This is to give you an idea of how you can modify your code. You will need to look up Grid, StackPanel, Auto and "*" Star Sizing, and Visibility. In this sample, the stack panel contains two elements a grid that grows horizontally and a rectangle of fixed size. The grid that grows horizontally defines two columns with 2nd column width="*" (which means the column will adjust to its content size). While the textbox is collapsed it will not occupy any space but when it becomes visible, the column will adjust to its contents. In this sample, I used the button click to change the visibility of my textbox.
<StackPanel Orientation="Horizontal" >
<Grid x:Name="MyGrid" VerticalAlignment="Top" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Content="Button" Click="Button_Click" />
<TextBox x:Name="MyTextBox" Text="This expands on button click" Grid.Column="1" Visibility="Collapsed"/>
</Grid>
<Rectangle Fill="Blue" Width="50" Height="50" VerticalAlignment="Top"/>
</StackPanel>
private void Button_Click(object sender, RoutedEventArgs e)
{
if (this.MyTextBox.Visibility == System.Windows.Visibility.Collapsed)
this.MyTextBox.Visibility = System.Windows.Visibility.Visible;
else
this.MyTextBox.Visibility = System.Windows.Visibility.Collapsed;
}
... View more
01-19-2011
07:49 AM
|
0
|
0
|
1363
|
|
POST
|
This might be a related thread http://forums.arcgis.com/threads/16731-Change-value-of-FeatureDataGrid-Cell if you are also working with related tables.
... View more
01-19-2011
07:29 AM
|
0
|
0
|
1076
|
|
POST
|
I don't see anything wrong with the code snippet you provided. The delay could be because of the update as this operation requires to re-query the layer. Have you looked into using Feature Data Form? A lot of the attribute editing considerations are handled by this control. Maybe you can compare the time difference in the two solutions. The toolkit is also open source and may be downloaded from codeplex, if you only want to get some idea from the code to improve yours.
... View more
01-19-2011
05:43 AM
|
0
|
0
|
1680
|
|
POST
|
These two numbers dictate how much you can zoom in/out. I cannot tell you a set of reasonable values for these properties as it would depend on the layers contained in your map. If your map contains tiled layer, you may not need to update the map's Minimum and MaximumResolution http://help.arcgis.com/en/webapi/silverlight/apiref/ESRI.ArcGIS.Client~ESRI.ArcGIS.Client.Map~MaximumResolution.html.
... View more
01-18-2011
09:01 PM
|
0
|
0
|
875
|
|
POST
|
I don't think you need to change the Width or apply ScaleTransform to your Grid. But you might need to have ColumnDefintions where the last column's Width is "*" to be able to expand horizontally. Look at how the IdentifyGrid in this sample is defined in the XAMLhttp://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Identify. This Grid contains two child elements: TextBlock and another Grid (IdentifyResultsPanel). When the child grid (IdentifyResultsPanel) is changed from collapsed to visible, the parent grid (IdentifyGrid) expands vertically. This is possible because the child grid is contained in the 2nd row where Height="*". You can read more about Grid here http://msdn.microsoft.com/en-us/library/system.windows.controls.grid(v=vs.95).aspx
... View more
01-18-2011
08:39 PM
|
0
|
0
|
1363
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 4 weeks ago | |
| 1 | 09-11-2025 01:30 PM | |
| 1 | 06-06-2025 10:14 AM | |
| 1 | 03-17-2025 09:47 AM | |
| 1 | 07-24-2024 07:32 AM |
| Online Status |
Offline
|
| Date Last Visited |
3 weeks ago
|