+ Reply to Thread
Results 1 to 12 of 12

Thread: InfoWindowRenderer re-drawing custom symbol?

  1. #1
    Matt Strum
    Join Date
    Feb 2012
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default InfoWindowRenderer re-drawing custom symbol?

    (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:

    Click image for larger version

Name:	first.jpg
Views:	75
Size:	42.5 KB
ID:	13790

    Click image for larger version

Name:	second.jpg
Views:	74
Size:	48.2 KB
ID:	13791

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

    Here is what my graphicsLayer definition looks like:

    Code:
    <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:

    Code:
    <?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
    Last edited by mstrum; 04-24-2012 at 07:02 PM.

  2. #2
    Dasa Paddock

    Join Date
    Dec 2009
    Posts
    1,160
    Points
    386
    Answers Provided
    65


    1
    This post is marked as the answer

    Default Re: InfoWindowRenderer re-drawing custom symbol?

    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/h...0000057000000/

    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/h...tGraphicsLayer
    Dasa Paddock
    Esri Flex and JavaScript Teams

  3. #3
    Matt Strum
    Join Date
    Feb 2012
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default Re: InfoWindowRenderer re-drawing custom symbol?

    Thanks, that fixed it! If there is a more appropriate way for me to handle that please let me know~

  4. #4
    Dasa Paddock

    Join Date
    Dec 2009
    Posts
    1,160
    Points
    386
    Answers Provided
    65


    0

    Default Re: InfoWindowRenderer re-drawing custom symbol?

    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?
    Dasa Paddock
    Esri Flex and JavaScript Teams

  5. #5
    Matt Strum
    Join Date
    Feb 2012
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default Re: InfoWindowRenderer re-drawing custom symbol?

    Quote Originally Posted by dpaddock View Post
    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

  6. #6
    Dasa Paddock

    Join Date
    Dec 2009
    Posts
    1,160
    Points
    386
    Answers Provided
    65


    0

    Default Re: InfoWindowRenderer re-drawing custom symbol?

    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.
    Dasa Paddock
    Esri Flex and JavaScript Teams

  7. #7
    Matt Strum
    Join Date
    Feb 2012
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default Re: InfoWindowRenderer re-drawing custom symbol?

    Sure, here is my Symbol code:

    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[i].colorIdx], 1);
    						sprite.graphics.beginFill(ColorUtil.colorsDark[managers.collection[i].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;
    			}
    		}
    	}
    }

  8. #8
    Dasa Paddock

    Join Date
    Dec 2009
    Posts
    1,160
    Points
    386
    Answers Provided
    65


    1

    Default Re: InfoWindowRenderer re-drawing custom symbol?

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

    Can you try adding this to your symbol code:

    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();
    }
    Last edited by dpaddock; 04-26-2012 at 11:58 AM. Reason: typo
    Dasa Paddock
    Esri Flex and JavaScript Teams

  9. #9
    Matt Strum
    Join Date
    Feb 2012
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default Re: InfoWindowRenderer re-drawing custom symbol?

    No, I haven't been seeing any problems related to that. I'll try adding that code and will report what happens~

  10. 04-28-2012 09:11 AM


  11. #10
    Matt Strum
    Join Date
    Feb 2012
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default Re: InfoWindowRenderer re-drawing custom symbol?

    Quote Originally Posted by dpaddock View Post
    Are you having any issues with your symbol when you pan or zoom?

    Can you try adding this to your symbol code:

    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();
    }
    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?

  12. #11
    Dasa Paddock

    Join Date
    Dec 2009
    Posts
    1,160
    Points
    386
    Answers Provided
    65


    0

    Default Re: InfoWindowRenderer re-drawing custom symbol?

    I'm glad to hear that resolved the original issue.

    It's currently up to the symbol code to support wraparound mode. This may be changed at the 3.0 final release.
    Dasa Paddock
    Esri Flex and JavaScript Teams

  13. #12
    Matt Strum
    Join Date
    Feb 2012
    Posts
    13
    Points
    0
    Answers Provided
    0


    0

    Default Re: InfoWindowRenderer re-drawing custom symbol?

    Quote Originally Posted by dpaddock View Post
    I'm glad to hear that resolved the original issue.

    It's currently up to the symbol code to support wraparound mode. This may be changed at the 3.0 final release.
    Any documentation on how to support wraparound mode?

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts