// Add Symbology Control - axSymbologyControl1 Public class GeoEvents{ private IStyleGalleryItem m_StyleGalleryItem; private void Form_Load(){ // make 500 elements on map for(int i=0; i<=500; i++){ DisplayAgentLocation(agentArray[i%20]); } } private void timer1_Tick(){ IGroupElement groupElement = null; while(element != null){ // check if element from map is group element if(element is IGroupElement){ groupElement = element as IGroupElement; } if(elementProperties.Name = false.TOString()){ // Point geometry for first element from grouped element IPoint point = (IPoint)groupElement.get_Element(0).Geometry; if(Point.IsEmpty == false){ // Calculate random point // Move both element from group element to new location groupElement.get_Element(0).Geometry = point; groupElement.get_Element(1).Geometry = point; } } } } private void DisplayAgentLocation(){ // default element replaced with this grouped element IGraphicContainer pGraphicContainer = (IGraphicContainer)axMapControl1.ActiveView.FocusMap; IElement ELEMENT = null; //Element 1 IElement pElement1 = null; pElement1 = new MarkerElementClass(); pElement1.Geometry = point; IMarkerElement markerElement1 = (IMarkerElement)pElement1; m_StyleGalleryItem = axSymbologyControl1.GetStyleClass(esriSymbologyStyleClass.esriStyleClassMarkerSymbol).GetItem(43); IMarkerSymbol markerSymbol1 = (IMarkerSymbol)m_StyleGalleryItem.Item; markerSymbol.Size = 19; markerelement1.Symbol = markerSymbol1; // Element 2 IElement pElement2 = null; IPoint pCalloutPoint = new PointClass(); pCalloutPoint.PutCoords(point.X, point.Y); TextElementClass textElement = new TextElementClass(); textElement.Geometry = pCalloutPoint; textElement.Text = "text"; TextSymbolClass textSymbol = new TextSymbolClass(); IFontDisp font; font = new StdFontClass() as IFontDisp; font.Name = "Arial"; font.Bold = true; textSymbol.Font = font; textSymbol.Size = 7; IRgbColor pColor = new RgbColorClass(); pColor.Red = 0; pColor.Blue = 0; pColor.Green = 0; textSymbol.Color = pColor; textSymbol.XOffset = 13; textSymbol.YOffset = -13; BalloonCalloutClass callout = new BalloonCalloutClass(); callout.Style = esriBalloonCalloutStyle.esriBCSRectangle; callout.PutMargins(2, 1, 1, 0); IRgbColor background = new RgbColorClass(); background.Red = 200; background.Blue = 255; background.Green = 255; ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Color = background; callout.Symbol = simpleFillSymbol; textSymbol.Background = callout; textElement.Symbol = textSymbol; pElement2 = textElement as IElement; // Group elements into group element IGroupElement group = new GroupElementClass(); group.AddElement(pElement2); group.AddElement(pElement1); ELEMENT = (IElement)group; IElementProperties elementProperties = (IElementProperties)ELEMENT; elementProperties.Name = agent.Located.ToString(); elementProperties.CustomProperty = int.Parse(agent.CodeNumber); pGraphicContainer.AddElement.AddElement(ELEMENT, 0); } }
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.