xmlns:esri="http://schemas.esri.com/arcgis/client/2009" > <Grid x:Name="LayoutRoot" Background="White"> <Grid.Resources> <esri:SimpleLineSymbol x:Key="LineSymbol" Color="Red" Width="10" /> <esri:PictureMarkerSymbol x:Key="PictureSymbol" Source="images/i_pushpin.png" OffsetX="11" OffsetY="39"/> </Grid.Resources> <esri:Map x:Name="MyMap" WrapAround="True" Extent="-15000000,2000000,-7000000,8000000"> <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/> <esri:GraphicsLayer ID="MyLayer" /> </esri:Map> <StackPanel Orientation="Horizontal" VerticalAlignment="Top" HorizontalAlignment="Center"> <Button Content="Point" Click="Button_Click"/> <Button Content="Line" Click="Button_Click"/> </StackPanel> </Grid>
public MainPage() { InitializeComponent(); draw = new Draw(MyMap); var l = MyMap.Layers["MyLayer"] as GraphicsLayer; var pms = LayoutRoot.Resources["PictureSymbol"] as Symbol; var ls = LayoutRoot.Resources["LineSymbol"] as Symbol; draw.DrawComplete += (s, e) => { l.Graphics.Add(new Graphic() { Geometry = e.Geometry, Symbol = e.Geometry is MapPoint ? pms : ls }); }; } Draw draw; private void Button_Click(object sender, System.Windows.RoutedEventArgs e) { var b = sender as Button; if (b.Content.ToString() == "Point") draw.DrawMode = DrawMode.Point; else draw.DrawMode = DrawMode.Polyline; draw.IsEnabled = true; }
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.