<Window x:Class="GraphicLabel.MainWindow" 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" Title="MainWindow" Height="350" Width="525"> <Grid x:Name="LayoutRoot"> <Grid.Resources> <esri:MarkerSymbol x:Key="labelSymbol" OffsetX="6" OffsetY="6"> <esri:MarkerSymbol.ControlTemplate> <ControlTemplate> <Grid> <!--Marker--> <Ellipse Width="12" Height="12" Fill="Red" HorizontalAlignment="Left" VerticalAlignment="Top" /> <!--Label--> <Grid Margin="8,8,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" IsHitTestVisible="False"> <!--Text halo using a white blurred text--> <TextBlock Foreground="White" Text="{Binding Attributes[NAME]}" > <TextBlock.Effect> <BlurEffect Radius="5" /> </TextBlock.Effect> </TextBlock> <!--Text--> <TextBlock Foreground="Black" Text="{Binding Attributes[NAME]}" /> </Grid> </Grid> </ControlTemplate> </esri:MarkerSymbol.ControlTemplate> </esri:MarkerSymbol> </Grid.Resources> <esri:Map x:Name="_mapControl" Background="Gray" WrapAround="True"> <esri:ArcGISTiledMapServiceLayer ID="arcGISTiledMapServiceLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" /> <esri:GraphicsLayer ID="graphicsLayer"/> </esri:Map> </Grid> </Window>
using System.Windows; using ESRI.ArcGIS.Client; using ESRI.ArcGIS.Client.Symbols; using ESRI.ArcGIS.Client.Geometry; using System; namespace GraphicLabel { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); Random random = new Random(); GraphicsLayer graphicsLayer = _mapControl.Layers["graphicsLayer"] as GraphicsLayer; for(int i = 0; i <=10 ; i++) { Graphic graphic = new Graphic() { Geometry = new MapPoint(random.Next(0,10000000),random.Next(0,10000000)), Symbol = LayoutRoot.Resources["labelSymbol"] as MarkerSymbol, }; graphic.Attributes.Add("NAME",string.Format("Point {0}", i.ToString())); graphicsLayer.Graphics.Add(graphic); } } } }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.