MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Deleting all CShape in CShapes

This is a discussion on Deleting all CShape in CShapes within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; Hi, I have a member variable CShapes m_carPath for which I do AddLine( oldlocation, newlocation ) each time I update ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-16-2005
Junior Member
White Belt
 
Join Date: May 2005
Posts: 9
Deleting all CShape in CShapes

Hi, I have a member variable CShapes m_carPath for which I do AddLine( oldlocation, newlocation ) each time I update the car's position (represented by a pushpin). I have a reset button in this MFC app that when pressed deletes the pushpin representing the car and also attempts to delete all the lines associated with m_carPath (these are of type CShape). My code below seems to only delete every other line:
Code:
	VARIANT idx;
	VariantInit( &idx );
	V_VT(&idx) = VT_I4;
	for( long i = 1; i <= m_carPath.GetCount(); i++ ) {
		V_I4(&idx) = i;
		CShape shape = m_carPath.GetItem( &idx );
		shape.Delete();
	}
If I hit "Reset" over and over, more and more lines go away.
Any idea why? Please help. Thanks! -Stu
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2 (permalink)  
Old 05-16-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,094
Hi,

I dont understeand the question very whell but is it not more easy to just move the pushpin to the new position and eventually change balloon information ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3 (permalink)  
Old 05-16-2005
Junior Member
White Belt
 
Join Date: May 2005
Posts: 9
Ok, my question was not about the pushpin. It was about a line that I am drawing to trail the pushpin. But your answer posts another question for me. So, I'm going to try and make it clear with two questions.
  1. How do you just move a pushpin in c++? I read on the forums that you have to delete it everytime and make a new one at the new location.
  2. My original question: Why does my code not delete all CShape instances in CShapes. In my OnTimer() function I "move" the pushpin (by deleting it, and making a new one -- see question 1). In the same OnTimer() function I also do AddLine(oldLocation, newLocation) to my CShapes instance. When I try to delete all these lines in CShapes instance. Only some, get deleted (it looks to be every other one).

If this is not clear let me know.
Thanks!
Stu
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4 (permalink)  
Old 05-17-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,094
Hi,

Now I understeand

This example try to find a pushpin on the map, create a new if not found, and move the existing with the same name if found:

Code:
        private Pushpin MovePP(string name, double lat, double lon)
        {
            Location Loc = MP.ActiveMap.GetLocation(lat, lon, 1);
            Pushpin PP = MP.ActiveMap.FindPushpin(name);
            if (PP == null)
                PP = MP.ActiveMap.AddPushpin(Loc, name);
            PP.Location = Loc;
            PP.GoTo();
            return PP;
        }
As for your code, it will delet every other one because you delete very other one because of the index (i).. If you change it with a while loop it will work. Now you delete, then the index is removed, count is decrement, you increment index and delete 1 step higher. Common mistakes we all do once a while
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
cshape, cshapes, deleting


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Deleting pushpins in bulk brianmcg MapPoint 2006/2009 Discussion 1 06-22-2006 01:08 PM
Selecting and deleting the push pin Anonymous MapPoint 2006/2009 Discussion 1 02-10-2005 07:01 AM
deleting city names Anonymous MapPoint 2006/2009 Discussion 0 11-04-2004 06:53 PM
New map (Deleting) Anonymous MapPoint 2006/2009 Discussion 0 07-21-2004 03:21 AM
disabling deleting pushpin Anonymous MapPoint 2006/2009 Discussion 1 05-28-2004 08:14 AM


All times are GMT -5. The time now is 06:34 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
MP2K Magazine
Visitor Map

Flights to Sardinia
Sardinia has exquisite seafood as well as fantastic weather, superb seas and stunning scenery. Holiday Hypermarket can help you to book cheap flights to Sardinia with ease.

Italy Holidays
Find great Italy Holidays with Travel Counsellors. A personal Travel Counsellor can help you plan the perfect holiday to Italy.

Holidays Italy
Book your holidays in Italy. Italy has a great climate and the beaches to go with it. Book a great deal for great value online at dealchecker.co.uk.

Holidays in Cuba
Holidays in Cuba are an eclectic mix of golden beaches, rich, colourful scenery and a proud cultural heritage. Book a break in Cuba now!

Cheap Spain Holidays
Stay well informed when you are searching for cheap holidays online. For useful advice on when to book cheap Spain holidays make sure you look on ulookubook.com

Cheap Holidays
Looking for holidays that are cheap, but still what you want? Visit Travel.co.uk.

Florida Holidays
Take a sunny holiday break! Find info on Florida holidays at On The Beach!


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