Hi
I have an application that :
1- displays a map
2- retrieves coordinates from a remote application
3- add these coordinates on a map as pushpins
I would like to know if there's a way to access to these pushpins with an array ? I need to show the label of a selected pushpin only and I need to access to an array of all the pushpins that were added to the map...
Is that possible ? :)
Winwaed
01-12-2005, 09:14 AM
Yes, they're stored as "pushpin sets". You can have multiple pushpinsets, but you have probably added your pushpins to the default "My Pushpins".
This in turn is a "Recordset". If you look up "Recordset" in the help it will show you how to access them.
Eg. to get the names of the pushpins in VB6, I have the following code:
' pushpinset, dsidx is an index that is passed in
' you could query oMap.DataSets until you find the required pushpinset
Dim oDS As MapPoint.DataSets
Set oDS = oMap.DataSets
Dim thisDS As MapPoint.DataSet
Set thisDS = oDS.Item(dsidx)
' loop over each pushpin, saving the name
Dim oRS As MapPoint.Recordset
Set oRS = thisDS.QueryAllRecords()
Dim n As Long
n = thisDS.RecordCount
ReDim SrcNameArray(n) As String
oRS.MoveFirst
Dim ii As Integer
ii = 0
Do While Not oRS.EOF
ii = ii + 1
Set pp = oRS.Pushpin
SrcNameArray(ii) = pp.Name
oRS.MoveNext
Loop
The above is an extra of a program I have - I've taken out some extra code to keep things simple and easier to understand what is happening.
Combined with the help that comes with MapPoint, it should get you going!
Richard
Anonymous
01-12-2005, 11:06 AM
Thank you... But I work in C#...
Anyway I've found an alternative but very specific to my code (using ID in a listbox...) so posting the source wouldn't be helpful for anyone...
Anyway your source could help me because I work on many projects :)
Thanks!!!
Wilfried
01-12-2005, 01:07 PM
I've found an alternative
Possible that your alternative way can benefit other. If you like to post code snippets it should be very welcome !
I won't post the code because there are many parts... and these are very specific to my source code... But I can describe how to do :
The purpose is to add pushpins on a map and access them individually without using datasets :)
1- Add many pushpins on the control with AddPushpin() function
1b- For each added pushpin, add a value in a listbox
1c- The value in the listbox must be unique and must also be assigned to the PushPin.Name property
2- When the user need to find a pushpin, he must click on a value in the listbox and then we search for the clicked pushpin by FindPushpin(ClickedValueInList) function
Thats'all folks :)