Select to view content in your preferred language

Change symbol of a graphic event

1117
6
Jump to solution
02-03-2014 06:06 AM
AndreasRuloffs1
Occasional Contributor
Hello,
I have got a GraphicsLayer and I write a lot of Graphics in it (round 15,000). Then I change the symbol of the Graphics it tooks some time before the change becomes visible.

In the meantime I want to give the user the feedback, that something is happening. But I have a problem to recognize the time when the change has become visible.

There is a event called: updateEnd which should be fired when the contend changed, but it seems not to be.
Looking at the elements of the graphics layer graphicProvider all the symbols show the modifiesd value, even when the change is not visible yet.

Does someone got an idea?

Thanks,
Andreas Ruloffs
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Andreas,

   I know what you mean as the event is fired and the Browser is not yet done drawing the graphics. I don't know if there is anything you can do to tell when the browser/plugin is done with the full drawing.

View solution in original post

0 Kudos
6 Replies
raffia
by
Deactivated User
Hello;

Are the graphics bitmaps that are embedded in the app?

My app queries landmarks with a certain type, the query happens by user input. The graphics bitmaps are embedded in the app, and the graphic symbol is added to the map in the result function of the landmark relationship type query. It seems to work fine. Let me know if you need the code for this.

Regards;
0 Kudos
AndreasRuloffs1
Occasional Contributor
Hello,
No, the Graphics are com.esri.ags.Graphics, no bitmaps.
to clarify the problem:
I have got a function, that fills the GraphicsLayer with com.esri.ags.Graphics:


private var shapefileGL:GraphicsLayer;

[Bindable]
public var polygonFillSymbol:SimpleFillSymbol = new SimpleFillSymbol("solid",0,1,new SimpleLineSymbol());

private function fileLoaded(result:Array):void
{
 for each(var i:Geometry in result)
 {
  switch (_shapeFileLoader.shpType)
  {
   case ShpType.SHAPE_POLYGON: 
   {
    graphic = new Graphic(i, this.polygonFillSymbol);
    this.shapefileGL.add(graphic); 
   }
  }
 }
}


When I later change the symbol polygonFillSymbol , then this change becomes visible in the map.
protected function fillStyle_changeHandler(event:IndexChangeEvent):void
{
 polygonFillSymbol.style = fillStyle.selectedItem.style;
}

Unfortunately this takes same time when there are lots of Graphics in the GraphicsLayer.
So I want to recognise the point of time, when the change has become visible so I can turn on and of a busy indicator.
Thanks,
Andreas Ruloffs
0 Kudos
EvelynHernandez
Frequent Contributor
I hope this give u some help to your code.

This allows you when a layer is loaded or not loaded completely. I know that is not what exactly u need but atleast give u some indication that how to do it.

<s:Label text="Layer Logs:" y="780"/>
 
 <s:HGroup width="100%"
     height="50%"
     y="800">
  
  <s:TextArea width="100%"
     height="90%"
     id="log" />
  
 </s:HGroup>


private function addLog(message:String):void
   {
    log.text = StringUtil.substitute("{0}\n\n{1}", message, log.text);
   }
   
   protected function onLayerLoadError(event:LayerEvent):void
   {
    addLog(StringUtil.substitute("Error on loading layer {0}", event.layer.name));
    nonLoadedCount++;
    
    var mapLayersCount:int = ArrayCollection(myMap.layers).length;
    if (mapLayersCount == (nonLoadedCount + loadedCount))
    {
     addLog(StringUtil.substitute("Loaded: {0} of {1} layers\n {2} layers fault on loading.", 
      loadedCount, mapLayersCount, nonLoadedCount));
    }
   }
   
   protected function onLayerLoad(event:LayerEvent):void
   {
    addLog(StringUtil.substitute("{0} is loaded", event.layer.name));
    loadedCount++;
    
    var mapLayersCount:int = ArrayCollection(myMap.layers).length;
    if (mapLayersCount == (nonLoadedCount + loadedCount))
    {
     addLog(StringUtil.substitute("Loaded: {0} of {1} layers\n {2} layers fault on loading.", 
      loadedCount, mapLayersCount, nonLoadedCount));
    }
   }
   
   protected function onLayerUpdateStart(event:LayerEvent):void
   {
    addLog(StringUtil.substitute("{0} update started", event.layer.name));
    if (updateStartedCount == updateEndedCount)
    {
     updateStartedCount = updateEndedCount = 0; // reset
    }
    
    updateStartedCount++;
   }
   
   
   protected function onLayerUpdateEnd(event:LayerEvent):void
   {
    addLog(StringUtil.substitute("{0} update ended >> update success = {1}", 
     event.layer.name, event.updateSuccess));
    updateEndedCount++;
    
    if (updateStartedCount == updateEndedCount)
    {
     addLog("All layers are updated");
    }
   }
0 Kudos
AndreasRuloffs1
Occasional Contributor
Hello,
I have tried to use these events.
They are all thrown just once when the GraphicLayer is created and then nevermore. And even the first time they are thrown far to early when the features are not yet visible.

     this.shapefileGL = new GraphicsLayer();
     baseWidget.map.addLayer( this.shapefileGL);
     this.shapefileGL.addEventListener(LayerEvent.UPDATE_START, updateStart);
     this.shapefileGL.addEventListener(LayerEvent.UPDATE_END, updateEnd);
     this.shapefileGL.addEventListener(LayerEvent.LOAD, loaded);


  
  private function updateStart(event:LayerEvent):void
  {
   LogUtil.getLogger(ShowShapefileMediator).info("updateStart");
  }
  
  private function updateEnd(event:LayerEvent):void
  {
   LogUtil.getLogger(ShowShapefileMediator).info("updateEnd");
  }
  
  private function loaded(event:LayerEvent):void
  {
   LogUtil.getLogger(ShowShapefileMediator).info("loaded");
  }

bye,
Andreas Ruloffs
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Andreas,

   I know what you mean as the event is fired and the Browser is not yet done drawing the graphics. I don't know if there is anything you can do to tell when the browser/plugin is done with the full drawing.
0 Kudos
AndreasRuloffs1
Occasional Contributor
Thank you Robert,
you are right, this is not the answer I want to hear, but it seems to be the only right one.
Bye,
Andreas Ruloffs
0 Kudos