InfoWindowRenderer re-drawing custom symbol?

2695
12
Jump to solution
04-24-2012 06:45 PM
MattStrum
New Contributor
(EDIT: FYI using 3.0 preview)

I am using a custom Symbol in a GraphicsLayer with a infoWindowRenderer defined which does nothing but display some static stuff (from the InfoWindow sample) but I'm seeing some strange results.  When I click on a symbol, it looks like either the first symbol in the GraphicsLayer or perhaps all of the symbols are getting re-drawn under where the infoWindow appears.  Here is a picture before and after clicking on a symbol:

[ATTACH=CONFIG]13790[/ATTACH]

[ATTACH=CONFIG]13791[/ATTACH]

When I click the 'x' on the infoWindow, the extra added symbol(s) goes away.

Here is what my graphicsLayer definition looks like:

<esri:GraphicsLayer id="markersLayer" infoWindowRenderer="com.flack.geni.display.mapping.mapproviders.esriprovider.testInfoWindow" />


I'm not doing much with the infoWindowRenderer, here's the code for that:

<?xml version="1.0" encoding="utf-8"?> <esri:LabelDataRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"      xmlns:s="library://ns.adobe.com/flex/spark"      xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:esri="http://www.esri.com/2008/ags">  <esri:label>test</esri:label>  <s:BorderContainer backgroundColor="white"         borderColor="black"         color="green"         cornerRadius="5"         minHeight="0"         minWidth="0">   <s:layout>    <s:VerticalLayout paddingBottom="5"          paddingLeft="5"          paddingRight="5"          paddingTop="5"/>   </s:layout>   <s:Label text="Sex ratio"/>   <s:Label text="Divorce rate:" toolTip="Divorce rate is the number of divorces per 1000 people."/>  </s:BorderContainer> </esri:LabelDataRenderer>


Any insight would be greatly appreciated 🙂
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Original User: dpaddock

At 3.0, the feature shown in the InfoWindow when using infoWindowRenderer is also drawn and highlighted in the Map's defaultGraphicsLayer.

See this sample:
http://resourcesbeta.arcgis.com/en/help/flex-api/samples/index.html#/InfoWindows_for_FeatureLayer/01...

This isn't recommended, but as a quick fix, try setting map.defaultGraphicsLayer.visible = false after the map has loaded.

Does the issue you're seeing go away after making this change?

See:
http://resourcesbeta.arcgis.com/en/help/flex-api/apiref/com/esri/ags/Map.html#defaultGraphicsLayer

View solution in original post

0 Kudos
12 Replies
by Anonymous User
Not applicable
Original User: dpaddock

At 3.0, the feature shown in the InfoWindow when using infoWindowRenderer is also drawn and highlighted in the Map's defaultGraphicsLayer.

See this sample:
http://resourcesbeta.arcgis.com/en/help/flex-api/samples/index.html#/InfoWindows_for_FeatureLayer/01...

This isn't recommended, but as a quick fix, try setting map.defaultGraphicsLayer.visible = false after the map has loaded.

Does the issue you're seeing go away after making this change?

See:
http://resourcesbeta.arcgis.com/en/help/flex-api/apiref/com/esri/ags/Map.html#defaultGraphicsLayer
0 Kudos
MattStrum
New Contributor
Thanks, that fixed it!  If there is a more appropriate way for me to handle that please let me know~
0 Kudos
by Anonymous User
Not applicable
Original User: dpaddock

There currently isn't an easier way to disable the highlight feature, but it would be good to know why it wasn't working for you.

Are you also using a custom Graphic or GraphicsLayer?
0 Kudos
MattStrum
New Contributor
There currently isn't an easier way to disable the highlight feature, but it would be good to know why it wasn't working for you.

Are you also using a custom Graphic or GraphicsLayer?


Yes, I created a Graphic which has a custom Symbol set on it and add it to a GraphicsLayer
0 Kudos
by Anonymous User
Not applicable
Original User: dpaddock

Can you share your symbol code? Maybe your symbol doesn't support drawing more than one feature using the same instance of your symbol? The API's symbols are stateless in the sense that a single instance can be used to draw many different graphics.
0 Kudos
MattStrum
New Contributor
Sure, here is my Symbol code:

package com.flack.geni.display.mapping.mapproviders.esriprovider
{
 import com.esri.ags.Graphic;
 import com.esri.ags.Map;
 import com.esri.ags.geometry.Geometry;
 import com.esri.ags.geometry.MapPoint;
 import com.esri.ags.symbols.MarkerSymbol;
 import com.esri.ags.symbols.Symbol;
 import com.flack.geni.resources.physical.PhysicalNodeCollection;
 import com.flack.geni.resources.sites.GeniManagerCollection;
 import com.flack.geni.resources.virtual.VirtualNodeCollection;
 import com.flack.shared.utils.ColorUtil;
 
 import flash.display.Sprite;
 import flash.events.MouseEvent;
 import flash.filters.DropShadowFilter;
 import flash.text.TextField;
 import flash.text.TextFieldAutoSize;
 
 import mx.core.DragSource;
 import mx.core.IUIComponent;
 import mx.core.UIComponent;
 import mx.managers.DragManager;
 
 public class EsriMapNodeMarkerSymbol extends Symbol
 {
  private var marker:EsriMapNodeMarker;
  public function EsriMapNodeMarkerSymbol(newMarker:EsriMapNodeMarker)
  {
   super();
   marker = newMarker;
  }
  
  override public function draw(sprite:Sprite,
           geometry:Geometry,
           attributes:Object,
           map:Map):void
  {
   if (geometry is MapPoint)
   {
    var managers:GeniManagerCollection = marker.Nodes.Managers;
    
    var mapPoint:MapPoint = MapPoint(geometry) as MapPoint;
    sprite.x = toScreenX(map, mapPoint.x)-14-Math.min(3*((marker.Nodes as PhysicalNodeCollection).Locations.length-1), 6)/2;
    sprite.y = toScreenY(map, mapPoint.y)-14-Math.min(3*((marker.Nodes as PhysicalNodeCollection).Locations.length-1), 6)/2;
    
    
    var loc:int;
    if(managers.length > 1)
    {
     var numShownManagers:int = Math.min(managers.length, 5);
     loc = 3*(numShownManagers-1);
     for(var i:int = numShownManagers-1; i > -1; i--)
     {
      sprite.graphics.lineStyle(2, ColorUtil.colorsMedium[managers.collection.colorIdx], 1);
      sprite.graphics.beginFill(ColorUtil.colorsDark[managers.collection.colorIdx], 1);
      sprite.graphics.drawRoundRect(loc, loc, 28, 28, 10, 10);
      loc -= 3;
     }
    }
    else
    {
     if(marker.Nodes is PhysicalNodeCollection)
      loc = Math.min(3*((marker.Nodes as PhysicalNodeCollection).Locations.length-1), 6);
     else if(marker.Nodes is VirtualNodeCollection)
      loc = Math.min(3*((marker.Nodes as VirtualNodeCollection).PhysicalNodes.Locations.length-1), 6);
     while(loc > -1)
     {
      sprite.graphics.lineStyle(2, ColorUtil.colorsMedium[managers.collection[0].colorIdx], 1);
      sprite.graphics.beginFill(ColorUtil.colorsDark[managers.collection[0].colorIdx], 1);
      sprite.graphics.drawRoundRect(loc, loc, 28, 28, 10, 10);
      loc -= 3;
     }
    }
    
    var labelMc:TextField = new TextField();
    labelMc.textColor = ColorUtil.colorsLight[managers.collection[0].colorIdx];
    labelMc.selectable = false;
    labelMc.border = false;
    labelMc.embedFonts = false;
    labelMc.mouseEnabled = false;
    labelMc.width = 28;
    labelMc.height = 28;
    labelMc.htmlText = marker.Nodes.length.toString();
    labelMc.autoSize = TextFieldAutoSize.CENTER;
    labelMc.y = 4;
    sprite.addChild(labelMc);
    
    // Apply the drop shadow filter to the box.
    var shadow:DropShadowFilter = new DropShadowFilter();
    shadow.distance = 5;
    shadow.angle = 25;
    sprite.filters = [shadow];
    
    sprite.buttonMode = true;
    sprite.useHandCursor = true;
   }
  }
 }
}
0 Kudos
by Anonymous User
Not applicable
Original User: dpaddock

Are you having any issues with your symbol when you pan or zoom?

Can you try adding this to your symbol code:

override public function clear(sprite:Sprite):void
{
    removeAllChildren(sprite);
    sprite.graphics.clear();
    sprite.x = 0;
    sprite.y = 0;
    sprite.filters = [];
    sprite.buttonMode = false;
}


override public function destroy(sprite:Sprite):void
{
    clear();
}
0 Kudos
MattStrum
New Contributor
No, I haven't been seeing any problems related to that.  I'll try adding that code and will report what happens~
0 Kudos
MattStrum
New Contributor
After adding that code, I didn't need to have "defaultGraphicsLayer.visible = false"

There weren't any other effects I can see though.  Quick question, it seems that the markers only occur once on the map and don't get copied into areas where the map repeats itself.  Is there a setting that needs to be set to support that or some code that needs to be added into the symbol, graphic or graphicsLayer?
0 Kudos