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 5 of 5

MapPoint inconsistently failing to match waypoint/pushpin names

This is a discussion on MapPoint inconsistently failing to match waypoint/pushpin names within the Development forums, part of the MapPoint Desktop Discussion category; MapPoint 2011. I have several pages of VBA code that, in part, does this: 1. Sends addresses to the map ...

  1. #1
    Brian is offline Member Yellow Belt
    Join Date
    Sep 2008
    Posts
    42

    MapPoint inconsistently failing to match waypoint/pushpin names

    MapPoint 2011.


    I have several pages of VBA code that, in part, does this:


    1. Sends addresses to the map as pushpins, with an option to automatically route and/or optimize.
    2. Waits for the user to route and optimize all or some of the points.
    3. On click of a button in my Access application, updates the external database by recording the newly-assigned stop numbers, then continues with the next two steps.
    4. Deletes the already-routed waypoints, along with pushpins whose names match the names of those waypoints. This gets them off the map so the user can see if he missed any points and/or continue routing the rest of the points on the map.
    5. Closes the map if there are no more pushpins remaining on the map (i.e. user has routed all the points).


    The problem occurs in this bit of code that occurs in #4 above. Except for LocationName (string), the variables are all object variables, and they all work correctly.


    For Each WaypointCurrent In RouteCurrent.Waypoints
    Set LocationCurrent = WaypointCurrent.Location
    LocationName = LocationCurrent.Name
    Set PushPinCurrent = MapCurrent.FindPushpin(LocationName)
    WaypointCurrent.Delete
    If Not PushPinCurrent Is Nothing Then PushPinCurrent.Delete 'avoids error; if user moved waypoint, there will be no matching pushpin
    Next


    You can see that I get the name of the waypoint, then find the pushpin with a matching name--which should be simple because the waypoint inherited its name from the pushpin when it was created in step #2 above. However, MapPoint inconsistently fails to create the reference to the pushpin having the same name as the waypoint.


    The scale of the problem is small but fairly persistent. In today's testing, there is one address of 60 that fails consistently and a few others that depending on a variety of seemingly unrelated factors. For instance, if I pop up a message box to show the name of the waypoint and/or, the consistent one works and one or two others fail (different ones different times). And yesterday, when a user was actually using my app with these exact same addresses (one time through his process), the "problematic" address and three other pushpins got left on the map.


    Any ideas?

  2. #2
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60

    Re: MapPoint inconsistently failing to match waypoint/pushpin names

    Our MPRouteWriter product ( RouteWriter: Export Routes from Microsoft MapPoint ) does something very similar, and it works.

    The only time FindPushpin might give the wrong result is if the pushpin name is non-unique. Then, MapPoint will return the first it finds - it has no idea which you actually want!
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  3. #3
    Brian is offline Member Yellow Belt
    Join Date
    Sep 2008
    Posts
    42

    Re: MapPoint inconsistently failing to match waypoint/pushpin names

    I know it should work, but it does not work consistently. Even with a single pushpin on the map (i.e. a specific address of a few that are problematic), this code fails to delete it:


    LocationName = WaypointCurrent.Name
    Set PushPinCurrent = MapCurrent.FindPushpin(LocationName)
    PushPinCurrent.Delete


    However, the same exact pushpin is deleted every time using the code below:


    LocationName = WaypointCurrent.Name
    For Each dsMapPoint In MapCurrent.DataSets
    Set rsMapPoint = dsMapPoint.QueryAllRecords
    rsMapPoint.MoveFirst
    Do While Not rsMapPoint.EOF
    Set PushPinCurrent = rsMapPoint.Pushpin
    PushPinName = PushPinCurrent.Name
    If PushPinName = LocationName Then 'pin name matches waypoint name
    PushPinCurrent.Delete
    End If
    rsMapPoint.MoveNext
    Loop
    Next dsMapPoint


    Why, given the same exact search string, can it find the pushpin by its name as a member of the dataset but not using FindPushPin--but only that one point out of 68 in today's example? It is consistent in that it is the same points that fail but inconsistent in that changing the method of identifying the pushpin changes the result.

  4. #4
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60

    Re: MapPoint inconsistently failing to match waypoint/pushpin names

    Probably because you are deleting a pushpin from within a recordset.

    You'll have the same problem if you iterate over shapes and delete a few - it will mess the iterators up.

    So loop over, find the ones you want to delete, keep references to them, and then delete them after the recordset is finished and closed.
    Winwaed Software Technology LLC
    http://www.winwaed.com
    See http://www.mapping-tools.com for MapPoint Tools

  5. #5
    Brian is offline Member Yellow Belt
    Join Date
    Sep 2008
    Posts
    42

    Re: MapPoint inconsistently failing to match waypoint/pushpin names

    Can you please explain "iterators"? There is no explicit recordset open in my code at the point at which this code is running. Are you saying that the FindPushpin method uses an implicit recordset made up of all DataSets on the map and that this recordset is static?

    I can understand the concept of an implied recordset but not one that is static. Much of the usefulness of the MapPoint API (and functionality in my various MapPoint-related applications) depends heavily on the successful deletion of waypoints and pushpins from the Waypoints collection and Dataset object, respectively, without affecting subsequent references to the Waypoints collection and parent Dataset object.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Waypoint and PushPin Information
    By m62 in forum Development
    Replies: 2
    Last Post: 01-25-2011, 03:50 PM
  2. Identify/match pushpin by number, not name
    By Brian in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 10-28-2008, 08:08 PM
  3. Creating pushpin/waypoint from Lat/Long
    By Brian in forum Development
    Replies: 2
    Last Post: 10-28-2008, 07:38 PM
  4. Prevent Pushpin/Waypoint deletion
    By EdB in forum MapPoint Desktop Discussion
    Replies: 8
    Last Post: 08-17-2005, 10:55 AM
  5. Check if a waypoint and a pushpin exist
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 08-19-2003, 09:27 AM

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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127