Select to view content in your preferred language

Multiple Graphics Layers?

574
2
11-16-2010 11:29 AM
WesBailes
Occasional Contributor
Can multiple graphics layers be implemented?  Basically I have a search where the geometry result is a polygon that I want to highlight, but also show an infoSymbol pointing to the polygon's label point.  Seems like that only 1 or the other will work.  Any suggestions on how to work around this are welcomed.  Code is:

var graphic1:Graphic = featureSet.features[0];
var graphic2:Graphic=featureSet.features[0];
var polygon: Polygon;
var centerPt: MapPoint;
polygon = graphic2.geometry as Polygon;
centerPt = polygon.extent.center;
graphicsLayer2.add(graphic2); //the graphics layer with a simple fill symbol set (polygon geometry)
graphic1.geometry = centerPt;
graphicsLayer1.add(graphic1); //the graphics layer with a infoSymbol set (point geometry)
Tags (2)
0 Kudos
2 Replies
DasaPaddock
Esri Regular Contributor
This looks good. Double-check the order of the layers.
0 Kudos
WesBailes
Occasional Contributor
Got it to work...instead of both graphics (polygon and point) originally referencing featureSet.features[0];, I created a new graphic for the polygon (which didn't need attributes).  I also added these to one graphics layer.  Working code is below:


var graphic1:Graphic = featureSet.features[0];
var polygon: Polygon;
var centerPt: MapPoint;
polygon = graphic1.geometry as Polygon;
centerPt = polygon.extent.center;
graphic1.geometry=centerPt;
graphic1.symbol=myInfoSymbol;
var graphic2:Graphic=new Graphic(polygon,myFillSymbol);
graphicsLayer.add(graphic2);
graphicsLayer.add(graphic1);
0 Kudos