I am relatively new to MapPoint. I am coding a Windows Forms app (VB.NET 2005) using the OCX that ships with MapPoint 2006. In this app, I am using the QueryPolygon method to select all the pushpins that are in the currently visible area of the map control. The code:
locations(0) = objMap.XYToLocation(0, 0)
locations(1) = objMap.XYToLocation(objMap.Width, 0)
locations(2) = objMap.XYToLocation(objMap.Width, objMap.Height)
locations(3) = objMap.XYToLocation(0, objMap.Height)
locations(4) = objMap.XYToLocation(0, 0)
Dim objDataSet As MapPoint.DataSet = objMap.DataSets(1)
objSelectedPushpins = objDataSet.QueryPolygon(locations)
I'm finding that when I have pushpins near the edges of the map, some of the pushpins at the top of the map are not always being selected while some pushpins just below the visible portion of the map are being selected. This seems to most prevalent when I'm zoomed out.
My theory is that while I'm feeding the QueryPolygon method coordinates of a perfect rectangle, that rectangle needs to be applied to a spherical object in the background (i.e. the Earth) before the data can be queried. The rectangle is distorted by the curvature of the Earth. This causes a visual discrepancy between what you think should be selected and what actually gets selected.
Am I making any sense at all? If so, does anyone know if my theory is correct? Does QueryPolygon take the curvature of the Earth into consideration and might that account for what I'm seeing? Or do I just have a bug?