Hopefully this will be the last issue I have:
In short, I've created a Query that detects whether a mouse click is within a polygon. If it is, a point is placed on the map, if not, an error is displayed. It works most of the time except the first time the mouse click is in a different location (with regards to in polygon/ outside polygon) than the previous.
For instance, when the map is loaded, if I click inside the polygon, nothing happens. Then if I click inside the polygon again, behavior is as expected. I can continue clicking inside the polygon and behavior is as expected. As soon as I click outside the polygon for the first time, it acts as if I've clicked inside the polygon (creating the graphic, etc.). Then if I click outside the polygon a second time, behavior is as expected (no graphic, warning, etc.). I can continue clicking outside the polygon again and again, and it works. Until I click inside the polygon again, at which point it still thinks I'm clicking outside, but only for the first click. And so on and so forth.
Any ideas? Do I have to specify some attribute in the QueryTaks, or is there something else I am missing? Thanks!
Here is the function:
private function onMapClick(event:MapMouseEvent):void
{
query.geometry = event.mapPoint;
queryTask.execute(query);
var num:int = queryTask.executeLastResult.features.length;
Alert.show(num.toString());
if ( num != 1){
Alert.show("All stops must be located inside Philadelphia County");
return;
}
var point:MapPoint = event.mapPoint;
var myGraphicMarker:Graphic = new Graphic(point,userMarks);
myGraphicMarker.toolTip = "Added stop";
userClicks.add(myGraphicMarker);
stops.push(myGraphicMarker);
messages.text = stops.length.toString() + " total stops"
}