PDA

View Full Version : Check for pushpins on map



rowter
09-28-2009, 06:25 PM
Hi,

If there are any pushpins on the map, I have to delete them.
I want to know how to check if there are any pushpins on the map.(Assuming you do not know the name of the pushpin)

Thanks in Advance

Mattys Consulting
09-28-2009, 07:09 PM
Hi rowter,

If you're looking to get rid of all pins, just delete all datasets.
Something like (C#):

foreach(MapPoint.DataSet ds in oMap.DataSets)
{
ds.Delete();
}

Mike Mattys
Mattys Consulting Maps & Custom Programming (http://www.mattysconsulting.com)

rowter
10-19-2009, 03:54 PM
Hi Mike,
I am having a mappoint on a form and made it public so that it can be accessed anywhere in the application without having to load the map each time.
We only have the hide map and do not close the map each time. the map will go into background and remain there with whatever directions or addresses you have on it.
Now, after mapping the first time, and i hide it i want to remove the pushpins the next time open it. I do have the code to delete pushpins.

All i need is how to check if a pushpin exists on the map or not? I need this because sometimes we will not have pushpins and calling the delete pushpin functionality is giving errors as there are no pushpins on the map.
Is there anyway to check for this?
(We do not have any names given to the pushpins)

Thanks in Advance

Mattys Consulting
10-19-2009, 06:46 PM
Hello rowter,

The best way, I think, would be to check whether there are any datasets and whether any pushpins have been resolved and plotted.

foreach(MapPoint.DataSet ds in oMap.DataSets)
{
if ds.Recordcount>0 Then ds.Delete();
}

Mike Mattys

rowter
10-26-2009, 12:06 PM
Mike,

This is working great.

Thanks