<UserControl x:Class="ESRI_Test.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:esri="http://schemas.esri.com/arcgis/client/2009"> <Grid x:Name="LayoutRoot" Background="White"> <Grid.Resources> <esri:SimpleLineSymbol x:Key="DrawLineSymbol" Color="Green" Width="4" /> <esri:SimpleFillSymbol x:Key="DrawFillSymbol" Fill="#3300FF00" BorderBrush="Green" BorderThickness="2" /> <esri:SimpleMarkerSymbol x:Key="DefaultMarkerSymbol" Color="Red" Size="12" Style="Circle" /> <esri:SimpleLineSymbol x:Key="DefaultLineSymbol" Color="Red" Width="4" /> <esri:SimpleFillSymbol x:Key="DefaultFillSymbol" Fill="#33FF0000" BorderBrush="Red" BorderThickness="2" /> </Grid.Resources> <esri:Map x:Name="MyMap" Extent="-15000000,2000000,-7000000,8000000" SnapToLevels="True" MinimumResolution="0.0746126492252985" MaximumResolution="1222.99245256249"> <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/> <esri:GraphicsLayer ID="MyGraphicsLayer" /> </esri:Map> <Canvas Width="370" Height="110" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,15,15,0" > <Rectangle Stroke="Gray" RadiusX="10" RadiusY="10" Fill="#77919191" Canvas.Left="0" Canvas.Top="0" Width="370" Height="110" > <Rectangle.Effect> <DropShadowEffect/> </Rectangle.Effect> </Rectangle> <Rectangle Fill="#FFFFFFFF" Stroke="DarkGray" RadiusX="5" RadiusY="5" Canvas.Left="10" Canvas.Top="10" Width="350" Height="90" /> <TextBlock x:Name="ToolTile" Foreground="Black" Width="340" TextAlignment="Center" FontSize="9" FontWeight="Bold" Canvas.Left="20" Canvas.Top="10" Text="Use these tools to add graphics to the map." /> <StackPanel Orientation="Vertical" Canvas.Top="5" Canvas.Left="20"> <esri:Toolbar x:Name="MyToolbar" MaxItemHeight="80" MaxItemWidth="80" Grid.Row="0" VerticalAlignment="Top" HorizontalAlignment="Center" ToolbarItemClicked="MyToolbar_ToolbarItemClicked" ToolbarIndexChanged="MyToolbar_ToolbarIndexChanged" Width="330" Height="80"> <esri:Toolbar.Items> <esri:ToolbarItemCollection> <esri:ToolbarItem Text="Add a point"> <esri:ToolbarItem.Content> <Image Source="Assets/images/i_draw_point.png" Stretch="UniformToFill" Margin="5" /> </esri:ToolbarItem.Content> </esri:ToolbarItem> <esri:ToolbarItem Text="Add a Polyline"> <esri:ToolbarItem.Content> <Image Source="Assets/images/i_draw_line.png" Stretch="UniformToFill" Margin="5" /> </esri:ToolbarItem.Content> </esri:ToolbarItem> <esri:ToolbarItem Text="Add a Polygon"> <esri:ToolbarItem.Content> <Image Source="Assets/images/i_draw_poly.png" Stretch="UniformToFill" Margin="5" /> </esri:ToolbarItem.Content> </esri:ToolbarItem> </esri:ToolbarItemCollection> </esri:Toolbar.Items> </esri:Toolbar> <TextBlock x:Name="StatusTextBlock" Text="" FontWeight="Bold" HorizontalAlignment="Center"/> </StackPanel> </Canvas> </Grid> </UserControl>
using System.Windows.Controls; using ESRI.ArcGIS.Client; using ESRI.ArcGIS.Client.Symbols; namespace ESRI_Test { public partial class MainPage : UserControl { private Draw MyDrawObject; private Symbol _activeSymbol = null; public MainPage() { InitializeComponent(); MyDrawObject = new Draw(MyMap) { LineSymbol = LayoutRoot.Resources["DrawLineSymbol"] as LineSymbol, FillSymbol = LayoutRoot.Resources["DrawFillSymbol"] as FillSymbol }; MyDrawObject.DrawComplete += MyDrawObject_DrawComplete; } private void MyToolbar_ToolbarItemClicked(object sender, ESRI.ArcGIS.Client.Toolkit.SelectedToolbarItemArgs e) { switch (e.Index) { case 0: // Point MyDrawObject.DrawMode = DrawMode.Point; _activeSymbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as Symbol; break; case 1: // Polyline MyDrawObject.DrawMode = DrawMode.Polyline; _activeSymbol = LayoutRoot.Resources["DefaultLineSymbol"] as Symbol; break; case 2: // Polygon MyDrawObject.DrawMode = DrawMode.Polygon; _activeSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol; break; case 3: // Rectangle MyDrawObject.DrawMode = DrawMode.Rectangle; _activeSymbol = LayoutRoot.Resources["DefaultFillSymbol"] as Symbol; break; case 4: // Freehand MyDrawObject.DrawMode = DrawMode.Freehand; _activeSymbol = LayoutRoot.Resources["DefaultLineSymbol"] as Symbol; break; default: // Clear Graphics MyDrawObject.DrawMode = DrawMode.None; GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); break; } MyDrawObject.IsEnabled = (MyDrawObject.DrawMode != DrawMode.None); } private void MyToolbar_ToolbarIndexChanged(object sender, ESRI.ArcGIS.Client.Toolkit.SelectedToolbarItemArgs e) { StatusTextBlock.Text = e.Item.Text; } private void MyDrawObject_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args) { GraphicsLayer graphicsLayer = MyMap.Layers["MyGraphicsLayer"] as GraphicsLayer; ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = args.Geometry, Symbol = _activeSymbol, }; graphicsLayer.Graphics.Add(graphic); } } }
And yes, I am able to replicate the problem in the sample by adding SnapToLevels and Min/Max resolution.
if (e.OldExtent.Equals(e.NewExtent)) { return; }
You are right, it is the same issue.For the moment, the best workaround is to unset SnapToLevels bu it should be fixed for final.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.