MapPoint Forums

MapForums

Community of MapPoint and Bing Maps Users and Developers




deleting shapes

This is a discussion on deleting shapes within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi, Using vb5/activexMP2006 In a sub I add a shape based on passed lat and lon parameters. Works fine. private ...


Go Back   MapPoint Forums > Map Forums > MapPoint Desktop Discussion

Today's Posts Twitter Feed Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-25-2008
Member
Yellow Belt
 
Join Date: Jun 2008
Posts: 39
deleting shapes

Hi,

Using vb5/activexMP2006

In a sub I add a shape based on passed lat and lon parameters. Works fine.

private objmap as mappointctl.map
private objloc(1 to 3) as mappointctl.location

sub pasteshape( lat as single, lon as single)

Set objLoc(1) = objmap.getlocation(lat,lon,10)
objmap.shapes.addshape geoShapeOval, objLoc(1), .05
objmap,shapes.item(1).line.forecolor = vbred

end sub

However I am unable to create a sub which will delete this shape as the above subs object references are now out of scope. Does anyone have an alternate method of creating/deleting shapes?

Thanks,
bartj
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 06-26-2008
Winwaed's Avatar
Mapping-Tools.com
Black Belt
 
Join Date: Feb 2004
Posts: 1,463
Blog Entries: 40
Re: deleting shapes

You need to give the shape a unique name.

Then when you want to delete, it you have to manually search through the shapes until you find the shape with the name you want to delete. Then delete it.


Richard
__________________
Winwaed Software Technology LLC
http://www.winwaed.com
See http://www.mapping-tools.com for MapPoint Tools
See the Geoweb Guru for online mapping
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 06-26-2008
Member
Yellow Belt
 
Join Date: Jun 2008
Posts: 39
Re: deleting shapes

Richard,

Thanks for the suggestion...but how do you add a unique name to an object location?

Thanks,
Bart
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 06-27-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Location: Belgium
Posts: 2,407
Re: deleting shapes

Hi,

the AddShape method returns a shape object. You can declare a static or global varialbe that holds the object, or an array if you have many. Then you can use Delete method to delete individually.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5 (permalink)  
Old 07-06-2008
Member
Yellow Belt
 
Join Date: Jun 2008
Posts: 39
Re: deleting shapes

Wilfried,

Finally getting back to this.....am unsure how the AddShape method returns a shape object? I tried:

Public objMapy As MapPointCtl.Map
Public objLocy As MapPointCtl.Location


Sub PlaceShapey(itemnumber As Long, lat As Single, lon As Single, color As Long)
Static z As Object

Set objMapy = frmmap.MappointControl1.ActiveMap
Set objLocy = objMapy.GetLocation(lat, lon, alt)

' draw circle
z = objMapy.Shapes.AddShape(geoShapeOval, objLocy, 0.3, 0.3)

' define shape parameters
objMapy.Shapes.Item(itemnumber).Line.ForeColor = color
objMapy.Shapes.Item(itemnumber).Line.Weight = 4
objMapy.Shapes.Item(itemnumber).Fill.ForeColor = color
objMapy.Shapes.Item(itemnumber).Fill.Visible = True
End Sub

But I get: Object variable not set error. Function works if I remove the "z = ".

Other strange behaviour: If I also use the following delete function:

Sub hideemy(itemnumber As Long)

On Error GoTo eh

objMapy.Shapes.Item(itemnumber).Delete

Exit Sub

eh:

End Sub

All is well if I execute these without adding any other shapes, they work fine. However if I also add some shapes using different references (not objMapy or objLocy) I find that when I call the above placeshape sub, it places a black ring in expected location when adding and does not delete when attempting to do so. I have no "vbblack" anywhere in my code.

Any comments or insights?
Thanks,
Bart
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6 (permalink)  
Old 07-10-2008
Senior Member
Black Belt
 
Join Date: Nov 2004
Location: Belgium
Posts: 2,407
Re: deleting shapes

Hi Bart,

I think you have to define:
static z as Shape;

For you second question I'm not sure why there is an error generated. Can you check the ItemNumber? Remember that all indexes in Mappoint start at 1 instead of 0.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7 (permalink)  
Old 07-10-2008
Member
Yellow Belt
 
Join Date: Jun 2008
Posts: 39
Re: deleting shapes

Wilfried,

Thanks for the response. I have solved the "problem". I was initially adding say 99 shapes based on 99 defined locations. If I then added a 100th shape at a 100th location all was fine, but when I attempted to delete the 100th shape the ring would appear. I was using an index of 100 to delete the shape. However I found that if I instead used an index of 1 the ring did not appear. If I then move shape and location 100 to another position(after the shape being deleted) the shape is again shown correctly and again, I need to use index 1 to delete it. I guess the delete is based on a "most recent" basis which is a bit counter intuitive.

Again, thanks for your help and suggestions,
Bart
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
deleting, shapes


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 BobFromBoston MapPoint Desktop Discussion 5 02-20-2008 11:54 AM
Deleting pushpins in bulk brianmcg MapPoint Desktop Discussion 1 06-22-2006 01:08 PM
Deleting all CShape in CShapes discostu MapPoint Desktop Discussion 3 05-17-2005 12:46 PM
Selecting and deleting the push pin Anonymous MapPoint Desktop Discussion 1 02-10-2005 07:01 AM
New map (Deleting) Anonymous MapPoint Desktop Discussion 0 07-21-2004 03:21 AM


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


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.0 RC3
MP2K Magazine
Visitor Map



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