vanDijk
11-02-2007, 03:40 AM
Hello,
Is there an easy way to get all the pushpins in the current map view? (Mappoint 2004)
Now I have the following solution:
MapPoint.Location[] locations = new MapPoint.Location[5];
locations[0] = myMap.XYToLocation(myMap.Left, myMap.Top);
locations[2] = myMap.XYToLocation(myMap.Left, myMap.Height);
locations[4] = myMap.XYToLocation(myMap.Width, myMap.Height);
locations[6] = myMap.XYToLocation(myMap.Width, myMap.Top);
locations[8] = myMap.XYToLocation(myMap.Left, myMap.Top);
and then a do a QueryPolygon on my dataset.
Is there another (better/easier) way to do this?
Thanks
tfmiltz
11-02-2007, 03:45 AM
Not sure if you are are working in vb6 or what lang.
Or with Dataset
but perhaps the following will help bring further insight:
The useful bit I found in a similar pursuit was the QueryAllRecords
I've got some other non-relevant info here (some might say more than less !) just ignore that though.
'For each pushpin, output the lat/lon and symbol lines.
For Each objDataSet In m_objMap.DataSets
Set objRecordset = objDataSet.QueryAllRecords
objRecordset.MoveFirst
Do Until objRecordset.EOF
CalcPos m_objMap, objRecordset.Pushpin.Location, dblLat, dblLon
m_colMIFLines.Add "Point " & CStr(Round(dblLon, 6)) & " " & CStr(Round(dblLat, 6)) & vbCrLf
m_colMIFLines.Add " Symbol (44,13395711,10)" & vbCrLf
strnote = ""
'Add information in the balloon and note fields to the data to be written.
For Each objField In objRecordset.Fields
If objField.VisibleInBalloon Then
strnote = strnote & objField.Name & ": " & CStr(objField.Value) & "> "
End If
Next
If Len(strnote) >= 2 Then
strnote = left$(strnote, (Len(strnote) - 2))
End If
If objRecordset.Pushpin.Note <> "" Then
strnote = strnote & IIf(strnote <> "", "> Note: ", "") & objRecordset.Pushpin.Note
End If
'Add a data line to the mid file, including the pushpin data and symbol.
m_colMIDLines.Add Chr$(34) & objRecordset.Pushpin.Name & Chr$(34) & "," & CStr(m_lObjectCount) & "," & objRecordset.Pushpin.Symbol & ",0," & Chr$(34) & left$(strnote, 255) & Chr$(34) & vbCrLf
'Update the object count.
' frmSpatialDataImport.lblRecordCount.Caption = "Shape Count: " & m_lObjectCount
DoEvents
m_lObjectCount = m_lObjectCount + 1
objRecordset.MoveNext
Loop
Next
Tim Miltz
vanDijk
11-02-2007, 04:05 AM
Thanks for your reply.
I am working in C# .Net.
To explain further, my goal is to get only the PushPins visible in the current view.
I have a MapPoint dataset containing al the puspins that are placed on the map. Now I want a subset of this dataset containing only that pushpins that are visible in the current view of the map.
E. van Dijk
Wilfried
11-02-2007, 01:51 PM
Hi,
Then calculate lat/long of the 4 corners of the map in view and you can easy calculate wht is in view or not