Select to view content in your preferred language

Getting feature layer graphic on map click

2754
1
Jump to solution
01-24-2013 04:10 AM
ab1
by
Deactivated User
Hello,

I have a map with a polyline feature layer named iti. The goal is to select polylines by clicking on them on the map.
I'm trying to do that through the code below:
private function mainMap_mouseUpHandler(event:MouseEvent):void    {         event.currentTarget.removeEventListener(MouseEvent.MOUSE_MOVE, mainMap_mouseMoveHandler);     event.currentTarget.removeEventListener(MouseEvent.MOUSE_UP, mainMap_mouseUpHandler);          mapClickPoint = mainMap.toMapFromStage(event.stageX, event.stageY);          if (event.target.parent is Graphic)      {      selectedGraphic = event.target.parent as Graphic;            mainMap.infoWindow.label = selectedGraphic.attributes.NAME;      myTextArea.text = "ID : " + selectedGraphic.attributes.ID_ITI+"\n"       + "Nombre d'arrêts : " +  selectedGraphic.attributes.STOPCOUNT + "\n"       + "Coût total : " +  selectedGraphic.attributes.TOTAL_COUT;            query.geometry = selectedGraphic.geometry;      FeatureLayer(iti).selectFeatures(query, FeatureLayer.SELECTION_NEW);            mainMap.infoWindow.show(mapClickPoint);     }     else     {      iti.clearSelection();      mainMap.infoWindow.hide();     }    }

Unfortunately,when I click on the polyline, nothing happens. Could you please help me improve my code? Or if you have other ways of graphically selecting polylines (features), I'm interested to know how.

Regards.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
IvanBespalov
Frequent Contributor
This sample demonstrates how to listen mose event on feature layer graphics
1 - listen feature layer graphic added event handler
2 - for each graphic add mouse event listener

similar discussion

View solution in original post

0 Kudos
1 Reply
IvanBespalov
Frequent Contributor
This sample demonstrates how to listen mose event on feature layer graphics
1 - listen feature layer graphic added event handler
2 - for each graphic add mouse event listener

similar discussion
0 Kudos