Moving objects

114
3
12-01-2011 02:04 AM
ToniMc
by
New Contributor
I have problem with moving hundreds of objects on map using GeoEvents example. When using this example with default elements which has CharacterMarkerSymbol(looks like pistol) this example works fine even with 500 elements.
But when i change this element to group element which consist of symbol loaded from symbol control (maybe first symbol from Esri.ServerStyle) and other Text marker element, grouped together, displaying 500 grouped elements start to slow down. I changed only default element in DisplayAgentLocation() where add element group.AddElement(element1) and group.AddElement(element2), and edited geometry moved elements in timer1_Tick().
It seems this 2 gruoped element are to complex for displaying in number more then 100 in GeoEvents.
Any advice how to speed things up ?
0 Kudos
3 Replies
ToniMc
by
New Contributor
When draw one by one, this grouped elements have delay displaying until all 500 elements are drawn.
Can i make it in memory and display all object at once, not to draw one by one element?
Or any other way to optimize this grouped element?

Here is only added new code to GeoEvents.cs:
 // 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);                  
   }    
}

Anyone?
0 Kudos
ToniMc
by
New Contributor
Any experience with moving hundreds objects around the screen? Which to choose,
dynamic display, geoevents, can i use something like feature layer for that? Can i
optimize custom symbols, optimize drawing on screen?
Please any advice!
0 Kudos
ToniMc
by
New Contributor
0 Kudos