QueryPolygon Error

dfriebus
12-28-2007, 09:35 AM
Hi.

I am using the ActiveX control that shipped with MapPoint 2006 in a VB.NET 2005 Windows Forms application. I'm trying to get a recordset containing all the pushpins within the currently displayed portion of the map by plotting out a rectangle that represents the bounds of the map and passing the coordinates to the querypolygon method of the dataset object. The code is below.

Dim locations(5) As MapPoint.Location
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("My Pushpins")
Dim objRecordset As MapPoint.Recordset = objDataSet.QueryPolygon(locations)

When querypolygon is executed, I get the following message: "The parameter is incorrect." I've looked at a number of examples and played around with the code a bit, but I can't figure out what I'm doing wrong. Anyone have any ideas? Thanks.

Paul Larson
12-28-2007, 11:44 AM
It's a simple problem: Your array of Locations is dimensioned too large.
Instead use

Dim locations(4) As MapPoint.Location

In VB.Net, the zero-base is assumed, so you were actually creating a 6-item array, the last of which was not initialized.

HTH
-Paul

dfriebus
12-31-2007, 07:51 AM
Completely missed it. Thanks, Paul!

 
Web mp2kmag.com
mapforums.com