PDA

View Full Version : Delete pushpins from map



rowter
09-15-2009, 11:51 AM
Hi,
For deleting the pushpins on the map, i found the following code in mapforums site. However, this is not deleting for some reason. It is going through the loop but not deleting.

For Each objDataSet As MapPoint.DataSet In SplashScreen1.objMap.DataSets
MessageBox.Show(objDataSet.Name)
If objDataSet.Name = "My Pushpins" Then
objDataSet.Delete()
End If
Next

Is there any other way to delete the pushpins from the mappoint?
Thanks in advance,

Winwaed
09-15-2009, 01:56 PM
That code searches for a pushpin set called "My Pushpins". This is only the name of the default pushpin set. Change the name if you want to delete a different dataset.

If you want to delete *all* pushpin sets, then check each dataset object's DataMapType property for the value "geoDataMapTypePushpin".

Eg.


For Each objDataSet As MapPoint.DataSet In SplashScreen1.objMap.DataSets
If objDataSet.DataMapType = geoDataMapTypePushpin Then
objDataSet.Delete()
End If
Next

Richard

rowter
09-15-2009, 02:33 PM
Hi Richard,

I tried your code with geodatamaptype set to geoDataMapTypePushpin .
It gives the following error:
Name 'geoDataMapTypePushpin' is not declared.
Do i have to change the datamaptype property of the datasetbefore using this code? If yes, where do i change it?


Thanks

rowter
09-15-2009, 04:22 PM
Richard,

I had to add this "MapPoint.GeoDataMapType." before geodatamaptypepushpin. It works now


For Each objDataSet As MapPoint.DataSet In SplashScreen1.objMap.DataSets
If objDataSet.DataMapType = MapPoint.GeoDataMapType.geoDataMapTypePushpin Then
objDataSet.Delete()
End If
Next


Thanks

Winwaed
09-16-2009, 09:01 AM
Makes sense - I copied the code directly from the Help file which didn't include the enumeration's name, but often you need to add it (you do in C++, C# and most "proper" languages!).

Richard