I'm having a problem selecting Point features on my feature layer. I'm using code which worked for me selecting polygons and other features but I can't seem to make it work for points on this widget.When my widget opens it loads the FeatureService layer and I see all the points. On widget init I set an event listener like so:
map.addEventListener(MapMouseEvent.MAP_CLICK, map_mapClickHandler);
lnoLayer.addEventListener(FeatureLayerEvent.SELECTION_COMPLETE, featureLayer_selectionComplete, false, 1);
private function map_mapClickHandler(event:MapMouseEvent):void
{
trace("mapClickHandler()");
var queryMapClick:Query = new Query();
queryMapClick.geometry = event.mapPoint;
lnoLayer.selectFeatures(queryMapClick);
}
private function featureLayer_selectionComplete(event:FeatureLayerEvent):void
{
trace("called selection complete");
status1.text = "";
status2.text = "";
status3.text = "";
status4.text = "";
status5.text = "";
status6.text = "";
//a feature was found
if (event.featureLayer.selectedFeatures.length > 0)
{
event.featureLayer.selectionColor = 0x000000;
refreshFieldsFromServer();
}
}
When I click the map I can see that the function is being called by the trace(), but it will not select the features and I do not see "called selection complete" since the feature never gets selected. Also I will note that if I change my mapClickHandler function to something like the code below it will select the features fine. So I has to be some problem with setting the right geometry.
private function map_mapClickHandler(event:MapMouseEvent):void
{
trace("mapClickHandler()");
var queryMapClick:Query = new Query();
//queryMapClick.geometry = event.mapPoint;
queryMapClick.where = "OBJECTID = 3";
lnoLayer.selectFeatures(queryMapClick);
}
If anyone could point me in the right direction I owe you many thanks.