AnsweredAssumed Answered

GraphicsLayer FindGraphicsInHostCoordinates(Rect, int) and drawing a bounding box

Question asked by kuiperfoliage on Oct 22, 2013
Latest reply on Jan 27, 2014 by kuiperfoliage
Hi,

I'm using FindGraphicsInHostCoordinates(Rect, int) to determine the underlying Graphics on a Map. Do give the user a visual cue i'm also drawing a bounding box. But it seems that FindGraphicsInHostCoordinates(Rect, int) is returning items outside the specified rectangle.

here is the data from our application:
MouseEventArg e.MapPoint: x: -9859018.61, y: 5184240.00, wkid: 102100
Screen coordinates: x: 347.00, y: 388.00
Host coordinates: x: 758.00, y: 542.00
Rect based on host visual: TopLeft: x: 758.00, y: 542.00, BottomRight: x: 778.00, y: 562.00
DrawBoundingBox: TopLeft: x: -9859018.61, y: 5184240.00, BottomRight: x: -9853218.29, y: 5178439.68
Found #6 graphics in the following GraphicsLayer: Testing_Scenario-gridfile_100x100
Graphic location of single point: x: -9852833.60, y: 5180831.17, wkid: 102100
Graphic location of single point: x: -9855351.87, y: 5180845.08, wkid: 102100
Graphic location of single point: x: -9857870.16, y: 5180858.34, wkid: 102100
Graphic location of single point: x: -9852847.99, y: 5178303.00, wkid: 102100
Graphic location of single point: x: -9855365.61, y: 5178316.90, wkid: 102100
Graphic location of single point: x: -9857883.24, y: 5178330.16, wkid: 102100


As you can see, graphic 1 and 4 are outside the bounding box specified in the Rect.

The following rectangle is the input for the method:
Rect based on host visual: TopLeft: x: 758.00, y: 542.00, BottomRight: x: 778.00, y: 562.00


the rectangle is converted to map coordinates using the following method
            Point p = map.PointFromScreen(new Point(x, y));             return map.ScreenToMap(p);


I also tried using a copy of the ConvertRectToPointWidthAndHeight() method from the GraphicsLayer to get the points and then convert it to map coordinates, but to no avail.

I think the base.GetDrawingSurface().HitTestSynchronous(layer, point, num, num2, maxHits); call should be validated / checked.

Can you confirm this behavior or would you need more information?

here is simplified code snippit from our code:


           
// Convert map coordinates to screen coordinates             Point screenPoint = map.MapToScreen(e.MapPoint);              // Convert map-screen coordinates to host coordinates             Point hostPoint = map.PointToScreen(screenPoint);              // print debug information             Log.DebugFormat("Screen coordinates: x: {0:F2}, y: {1:F2}", screenPoint.X, screenPoint.Y);             Log.DebugFormat("Host coordinates: x: {0:F2}, y: {1:F2}", hostPoint.X, hostPoint.Y);              // Rectangle based on host coordinates.             Rect rectMainVisual = new Rect(hostPoint.X, hostPoint.Y, diameter, diameter);              IEnumerable<Graphic> gc = gl.FindGraphicsInHostCoordinates(rectMainVisual , 10);



EDIT: added image as example

Attachments

Outcomes