Unique pushpin object identifier?

citrix_99301
05-21-2007, 01:52 PM
I'm writing a Windows Forms app in .NET 2.0 that helps our routers and call center staff plot services stops on a MapPoint 2006 Active-X map.

The trick is when a user clicks on a pushpin on the map, the axMapPoint_SelectionChange event is supposed to figure out the invoice number of the selected pushpin, the associated invoice number then highlight the corresponding node in a treeview adjacent to the map and display information about that stop.

I'm trying to figure out the best way to uniquely identify the pin objects on the map. I've tried capturing the pin.GetHashCode() values to a ADO.NET data table as the pins are created, however, I've noticed that sometimes these numbers don't stay the same even if I don't update the map. If any of the pushpin has code values change, I have no way of looking up which pin has been selected.

Right now I'm stuck setting the pin.Name property to the corresponding stop's invoice number but this is really awkward because I'd like to name the pin something more intuitive than the invoice number of the stop.

Does anybody have any recommendations for uniquely identifying pushpins on a map?

Thanks,



Andre Ranieri

Mattys Consulting
05-21-2007, 08:32 PM
Andre,

Since no answers have been put forth, I'd like to say that I think the invoice
number are most appropriate - though you might rather put them in the Note
property or define the SetFieldsVisibleInBalloon property for .ImportData.

Mike Mattys

citrix_99301
05-21-2007, 09:42 PM
Is .ImportData something that's exposed in the Active-X object through .NET 2.0? I thought it was somehow used for importing addressess from an Excel file, not for adding properties when coding through .NET.

My attempts to build a hash table around the pins' GetHashCode() method have been a miserable failure - for whatever reason, after the active map's _SelectionChange has been invoked a few times some or all of the pins' hash values change.

Andre Ranieri

Wilfried
05-22-2007, 04:03 AM
Hi,

Another possibilitie is that you hold an array of objects containing all the pushpins in your code. Another member of the object can be the number you wants.

Paul Larson
05-22-2007, 06:14 AM
Forgive me if I'm missing something, but I believe that your situation doesn't really require unique identifiers, since you have already "uniquely" selected a single pushpin object? Also, isn't it possible that multiple pushpins would represent a single invoice number?

This being the case, you should simply store the invoice number in the pushpin's Name property, or more effectively as a field in the DataSet.Fields collection just as Mike Mattys suggests.

In the latter method, you can easily find the pushpin's field data by using the Recordset.MoveToPushpin() method, and then accessing the recordset's underlying field data to "pop-up" the invoice information.

If this is unclear or you have questions, please post back. I'd be happy to provide some sample code.

HTH
Paul

citrix_99301
05-22-2007, 09:23 AM
Paul, Mike, Willfired:

Thanks so much for the help - I might just need a nudge in the right direction to get me started.

In our lawn and tree care corporation, each unique invoice number represents a stop that the truck makes. A customer might have two invoices on a given day, if the truck is servicing both lawn and tree care for the customer. But the invoices have a one-to-one relationship with pushpins on the map.

Currently, I've populated the pins' Name field with the invoice number but the users find this cumbersome since the seven digit invoice number is not human-intuitive, especially when two or more invoices are at the same location and MapPoint brings up the "select a place" menu and shows a bunch of invoice numbers. I need some way to uniquely identify each pushpin in code so when the axMap's SelectionChanged event is fired I can sync the selection with what other controls on the form are displaying. I've been trying to do that with the pins' GetHashCode() method but it hasn't worked as the has code seems to change after a few clicks.

I would love to take you up on your offer for a few lines of sample code to show how to effectively create and populate a dataset's fields property.

Thanks again,


Andre

Wilfried
05-22-2007, 11:57 AM
Hi,

I was thinking on a separate class, something like this:


public class MyPushpin
{
public Pushpin pp;
public string invoice;
}


Now, for each pushpin you place on the map you create a new object and hold it in an array together with the invoice or any other information you need.

When user select a pushpin you parse your array to find the right one and you have the invoice number.

Of course you have to maintain the object list when added but also if user delete a pushpin on the map, unless you make deletion impossible for the user.

 
Web mp2kmag.com
mapforums.com