for each(var graphic : Graphic in featureSet.features) { graphic.symbol = resultsSymbol; graphic.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver); graphic.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut); if (graphic.attributes.Homepage !== " " || graphic.attributes.Email !==" ") { graphic.addEventListener(MouseEvent.CLICK, clickongraphic) } myGraphicslayer.add(graphic); } var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(featureSet.features); if (graphicsExtent) { //IT STOPS WORKING AFTER A FEW QUERIES!!!! myMap.extent = graphicsExtent.expand(1.3); //zoom out a little if (!myMap.extent.contains(graphicsExtent)) { myMap.level--; } var graphicProvider:ArrayCollection = myGraphicsLayer.graphicProvider as ArrayCollection; var graphicsExtent:Extent = GraphicUtil.getGraphicsExtent(graphicProvider.toArray()); map.extent = graphicsExtent.expand(1.1); // zoom out a little }
Solved! Go to Solution.
if (featureSet.features.length == 1)
{
for each(var graphic2 : Graphic in featureSet.features)
{var mapPoint:MapPoint = MapPoint(graphic2.geometry);
myMap.centerAt(mapPoint);
myMap.scale = 4500;
}
}