Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 7 of 7

Unique pushpin object identifier?

This is a discussion on Unique pushpin object identifier? within the MapPoint Desktop Discussion forums, part of the Map Forums category; I'm writing a Windows Forms app in .NET 2.0 that helps our routers and call center staff plot services stops ...

  1. #1
    citrix_99301's Avatar
    citrix_99301 is offline Junior Member Yellow Belt
    Join Date
    Mar 2006
    Posts
    17

    Unique pushpin object identifier?

    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

  2. #2
    Mattys Consulting's Avatar
    Mattys Consulting is offline Senior Member Black Belt
    Join Date
    Dec 2002
    Posts
    1,040

    Re: Unique pushpin object identifier?

    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

  3. #3
    citrix_99301's Avatar
    citrix_99301 is offline Junior Member Yellow Belt
    Join Date
    Mar 2006
    Posts
    17

    Re: Unique pushpin object identifier?

    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

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Unique pushpin object identifier?

    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.

  5. #5
    Paul Larson is offline Senior Member Green Belt
    Join Date
    Sep 2005
    Location
    Battle Creek, Michigan
    Posts
    136

    Re: Unique pushpin object identifier?

    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

  6. #6
    citrix_99301's Avatar
    citrix_99301 is offline Junior Member Yellow Belt
    Join Date
    Mar 2006
    Posts
    17

    Re: Unique pushpin object identifier?

    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

  7. #7
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433

    Re: Unique pushpin object identifier?

    Hi,

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

    Code:
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. 8 unique data ranges
    By virgilar in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-31-2009, 08:53 PM
  2. Unique Identifier Property of a Pushpin?
    By avxflyer in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 10-17-2006, 06:42 PM
  3. Cannot see the Symbol ID from the Pushpin object after searc
    By fedir in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 11-25-2003, 08:06 PM
  4. Hi, and RoadClass for pushpin object
    By andrem in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 04-04-2003, 03:00 AM
  5. Numbered Pushpins (unique identifier)
    By linawms in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 04-01-2003, 06:02 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96