What layer type you are moving?
Hi,
Following on from Antti's question - please can you post your XAML/code which shows how the layer is defined/added and how it is being moved?
Cheers
Mike
<Grid> <Grid> <esri:Map x:Name="map"> <esri:ArcGISTiledMapServiceLayer ID="TileLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/> <esri:ArcGISDynamicMapServiceLayer ID="DynamicLayer" Url="http://maverick.arcgis.com/ArcGIS/rest/services/World_WGS84/MapServer" VisibleLayers="1,2" /> </esri:Map> </Grid> <Button Click="Button_Click" Height="20" Width="40" HorizontalAlignment="Left">Move</Button> </Grid>
private void Button_Click(object sender, RoutedEventArgs e) { var layer = this.map.Layers[0]; var index = map.Layers.IndexOf(layer); map.MoveLayer(index, index + 1); if (layer is ArcGISTiledMapServiceLayer) { (layer as ArcGISTiledMapServiceLayer).Refresh(); } else if (layer is ArcGISDynamicMapServiceLayer) { (layer as ArcGISDynamicMapServiceLayer).Refresh(); } }
<Grid> <Grid> <esri:Map x:Name="map"> <esri:ArcGISTiledMapServiceLayer ID="PhysicalTiledLayer" Url="http://gisservices.inbo.be/ArcGIS/rest/services/Orthofoto/MapServer"/> <esri:ArcGISDynamicMapServiceLayer ID="MyLayer" Url="http://gisservices.inbo.be/ArcGIS/rest/services/Viewer_overview/MapServer" VisibleLayers="1,2" /> </esri:Map> </Grid> <Button Click="Button_Click" Height="20" Width="40" HorizontalAlignment="Left">Move</Button> </Grid>
private void Button_Click(object sender, RoutedEventArgs e) { var layer = this.map.Layers[0]; var index = map.Layers.IndexOf(layer); map.MoveLayer(index, index + 1); //if (layer is ArcGISTiledMapServiceLayer) //{ // (layer as ArcGISTiledMapServiceLayer).Refresh(); //} //else if (layer is ArcGISDynamicMapServiceLayer) //{ // (layer as ArcGISDynamicMapServiceLayer).Refresh(); //} }
private void MovetopLayerDown_Click(object sender, RoutedEventArgs e) { _map.MoveLayer(0, 1); }
<Grid> <esri:Map x:Name="_map" UseAcceleratedDisplay="False"> <esri:ArcGISTiledMapServiceLayer ID="Orthofoto" Url="http://gisservices.inbo.be/ArcGIS/rest/services/Orthofoto/MapServer" Visible="True" /> <esri:ArcGISDynamicMapServiceLayer ID="Overview" Url="http://gisservices.inbo.be/ArcGIS/rest/services/Viewer_overview/MapServer" Visible="True" /> </esri:Map> <StackPanel> <Button Content="Move top layer down" Name="MovetopLayerDown" Click="MovetopLayerDown_Click" HorizontalAlignment="Left" VerticalAlignment="Top" Width="auto" Height="auto"/> </StackPanel> </Grid>
Hi,
Likewise - I just tested with your layers and cannot reproduce the problem you're experiencing with MoveLayer.private void MovetopLayerDown_Click(object sender, RoutedEventArgs e) { _map.MoveLayer(0, 1); }<Grid> <esri:Map x:Name="_map" UseAcceleratedDisplay="False"> <esri:ArcGISTiledMapServiceLayer ID="Orthofoto" Url="http://gisservices.inbo.be/ArcGIS/rest/services/Orthofoto/MapServer" Visible="True" /> <esri:ArcGISDynamicMapServiceLayer ID="Overview" Url="http://gisservices.inbo.be/ArcGIS/rest/services/Viewer_overview/MapServer" Visible="True" /> </esri:Map> <StackPanel> <Button Content="Move top layer down" Name="MovetopLayerDown" Click="MovetopLayerDown_Click" HorizontalAlignment="Left" VerticalAlignment="Top" Width="auto" Height="auto"/> </StackPanel> </Grid>
Cheers
Mike