Select to view content in your preferred language

Select Graphics from a Graphicslayer

1924
2
02-08-2011 01:21 AM
sreeharikottoormadam
Occasional Contributor
I am adding a graphics layer from a featurelayer upon loading the application. I need to implement a cutom identify for the graphics layer. I am able to select graphics with in extent, but need to select a graphics while clicking on map. can anybody help me in this.......


private function ShowIdentify():void{
    
jnjMap.addEventListener(MapMouseEvent.MAP_CLICK,IdentifyFunction);
       
}



protected function IdentifyFunction(event:MapMouseEvent):void
{
   

var selGraphic:Graphic;  
var ext:Number = jnjMap.extent.width / jnjMap.width * 5;
var x:Number = event.mapPoint.x;
var y:Number = event.mapPoint.y;
var queryExtent:Extent = new Extent(x - ext, y - ext, x + ext, y + ext, event.mapPoint.spatialReference);
var identifyResults:ArrayCollection = new ArrayCollection;
var Identifygraphic:Graphic;
var storeInfo:StoreInfoWindow ;



// var ac:ArrayCollection = myGraphicsLayer.graphicProvider as ArrayCollection;

//Stuck up here ....     😞 

//Get the selected extent
if (queryExtent.contains(MapPoint(selGraphic.geometry)))
{
      
selGraphic.symbol = highlightedSymbol;       
identifyResults.addItem(selGraphic.attributes.CITY_NAME);      
}
//else if point was previously highlighted, reset its symbology
else if (selGraphic.symbol == highlightedSymbol)
{
      
selGraphic.symbol = defaultSymbol;
}
selectionGraphicsLayer.add(selGraphic);




Thanks!
Tags (2)
0 Kudos
2 Replies
IvanBespalov
Frequent Contributor
2 ways "to select a graphics while clicking on map":

1 - "I am able to select graphics with in extent" - create extent from MapPoint coordinates you clicked on map

newextent.minx = mappoint.xvalue -10
newextent.miny = mappoint.yvalue -10
newextent.maxx = mappoint.xvalue +10
newextent.maxy = mappoint.xvalue +10

2 - Do not add MapMouseEvent, but use MouseEvent

var gra:Graphic = your graphic; //
gra.addEventListener(MouseEvent.CLICK, graphicClicked);

private function graphicClicked(event:MouseEvent):void
{
      var gra:Graphic = event.target as Graphic;
      // do something
}
0 Kudos
sreeharikottoormadam
Occasional Contributor
hi Ivan,

                    Thanks alot.....   🙂
0 Kudos