Community of MapPoint and Bing Maps Users and Developers
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 ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| deleting shapes 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 |
| ||||
| 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 |
| |||
| Re: deleting shapes
Richard, Thanks for the suggestion...but how do you add a unique name to an object location? Thanks, Bart |
| |||
| 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.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz www.comfortsoftware.be www.expertsoftware.be MapPoint coding demo |
| |||
| 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 |
| |||
| 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.
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz www.comfortsoftware.be www.expertsoftware.be MapPoint coding demo |
| |||
| 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 |
![]() |
| Tags |
| deleting, shapes |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| 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 |