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

delete all pushpins on a map

This is a discussion on delete all pushpins on a map within the MapPoint Desktop Discussion forums, part of the Map Forums category; hi all i have this problem: how can i delete all pushpins which were added to a map ? i ...

  1. #1
    bule is offline Junior Member Yellow Belt
    Join Date
    Sep 2006
    Posts
    14

    delete all pushpins on a map

    hi all i have this problem:

    how can i delete all pushpins which were added to a map ?

    i don't want to add a pushpin anf then delete it but add for example 10 pushpins and then from a control, it would be a button , delete all those i have added

    i hope someone can help me

  2. #2
    masty is offline Junior Member White Belt
    Join Date
    Sep 2006
    Posts
    6
    Hi Bule,

    To remove all the pushpin you've created you should use the follow code snippet (assuming your map is called "map"):

    Code:
    foreach (MapPoint.DataSet objDataSet in map.DataSets)
    {
    if (objDataSet.Name == "My Pushpins")
    {
    objDataSet.Delete();
    }
    This because all the Pushpin added by the user ar added in the DataSet "My Pushpins".

    Otherwise, if you want to remove only some pushpin you should use something like the follow code snippet:

    Code:
    foreach (MapPoint.DataSet objDataSet in map.DataSets)
    {
    if (objDataSet.Name == "My Pushpins")
    {
      Recordset rs = objDataSet.QueryAllRecords();
      while (!rs.EOF)
      {
          if (rs.Pushpin.Name.StartsWith("PushPinToDelete1") ||
              rs.Pushpin.Name.StartsWith("PushPinToDelete2"))
          rs.Pushpin.Delete();
          rs.MoveNext();
       }
     }
    }
    In this example the pushpin named "PushPinToDelete1" and "PushPinToDelete2" will be deleted.
    Of course you should use the same pushpin names you used to create them.

    Bye!

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

    Very right. In addition, remember that if you delete the dataset (first example and very fast), then you have to check for NULL if other parts of code want to work with it. The dataset is automically recreated if adding a pushpin again.

  4. #4
    bule is offline Junior Member Yellow Belt
    Join Date
    Sep 2006
    Posts
    14
    Thanks a lot ....this is the replay i was waiting for...

  5. #5
    doMapPoint is offline Junior Member Yellow Belt
    Join Date
    May 2007
    Location
    Germany
    Posts
    13

    Re: delete all pushpins on a map

    Hi!

    This is also the code I looked for... and it works great!

    But... what if you have the German or, for example, the French version of MapPoint? In the German version the DataSet's name is "Meine Pins" instead of "My Pushpins".

    Is there a solution which is language-independent?

    Regards,
    Dietmar

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

    Re: delete all pushpins on a map

    If you wish to delete all pushpins from the map, simply:

    Code:
    foreach (MapPoint.DataSet objDataSet in map.DataSets)
    {
    if (objDataSet.DataMapType == geoDataMapTypePushpin)
    {
    objDataSet.Delete();
    }

  7. #7
    doMapPoint is offline Junior Member Yellow Belt
    Join Date
    May 2007
    Location
    Germany
    Posts
    13

    Re: delete all pushpins on a map

    Hi Paul,

    thanks! I use Delphi, but I understand your code.
    There is only a little question I have: Of what type is your "MapPoint" object? I think I have to use the Map Object to access the DataSets, e.g. FMap.DataSets

    Regards
    Dietmar

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

    Re: delete all pushpins on a map

    hi Dietmar,

    Yes MP.ActiveMap (where MP is the name of the activeX component) translate to you as TMappointClass.FMap.

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

    Re: delete all pushpins on a map

    Sorry I was incomplete. Map in Paul his reply is the ActiveMap property.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Need to add Pushpins, but be able to delete them easily
    By BobFromBoston in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 04-18-2006, 03:12 PM
  2. don't delete pushpin
    By sdonta in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 03-03-2005, 01:57 PM
  3. Don't delete my pushpins!
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 06-15-2004, 12:39 PM
  4. Add and Delete pushpins on mappoint
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 06-12-2003, 02:55 AM
  5. delete countries
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 11-19-2002, 11:59 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