Community of VE/MapPoint Users and Developers
This is a discussion on Making Pushpin Locations Immoveable within the MP2K Magazine Articles forums, part of the Map Forums category; Fernando Velasquez shares a solution for preventing a user from moving pushpins on a map Read the full article here: ...
| |||||||
| Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Making Pushpin Locations Immoveable Read the full article here: http://www.mp2kmag.com/articles.asp?...ins.immoveable |
| |||
| Disables right click menu
Hi, Your method was very usefull but it disables the right click menu also, which was necessary in my application. So I changed your code a little bit so that it will give you the right click menu but doesnt allow you to move a push pin. //class variable to hold the last mouse //button pressed on the map control private bool lastMouseButtonLeft=false; private void MapControl_MouseDownEvent(object sender, AxMapPoint._IMappointCtrlEvents_MouseDownEvent e) { if(e.button == MapPoint.GeoMouseButtonConstants.geoLeftButton) { unSelectPushPin(MapControl.ActiveMap.Selection); lastMouseButtonLeft=true; } } private void MapControl_SelectionChange(object sender, AxMapPoint._IMappointCtrlEvents_SelectionChangeEve nt e) { if(lastMouseButtonLeft) { unSelectPushPin(e.pNewSelection); lastMouseButtonLeft=false; } } /// <summary> /// This method deselects the selected item if it is /// a pushpin /// </summary> /// <param name="MapSelection">object MapSelection</param> private void unSelectPushPin(object mapSelection) { MapPoint.Shape sp; MapPoint.Location loc; MapPoint.Pushpin pp; try { //try to get the selection if its a pushpin pp = (MapPoint.Pushpin )mapSelection; //get a location over at the arctic ocean loc = MapControl.ActiveMap.GetLocation(80, 0,0); sp = MapControl.ActiveMap.Shapes.AddShape (MapPoint.GeoAutoShapeType.geoShapeRectangle, loc, 1, 1); sp.Select(); sp.Delete(); sp = null; loc = null; pp = null; } catch (System.Exception e) { Console.WriteLine(e.Message); } } |
| |||
| Nice modification :)
Hi samitha, I'm glad my article was useful to you. You are correct, since the application I conceived the method for didn't involve the use of the right click, I didn't consider the mouse clicks when I did it. I'm glad you shared your solution with the community. See you later! Fernando |
| |||
| I've found it!!
I've just found a way to implement samitha's suggestion in Visual Basic, it is a mix between samitha's and Fernando's. Look Private Sub MappointControl1_MouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal X As Long, ByVal Y As Long) Dim sp As mappoint.Shape Dim loc As mappoint.Location If Button = mappoint.GeoMouseButtonConstants.geoLeftButton Then If Not MappointControl1.ActiveMap.Selection Is Nothing Then If TypeOf MappointControl1.ActiveMap.Selection Is Pushpin Then Set loc = MappointControl1.ActiveMap.GetLocation(80, 0) 'get a location over at the arctic ocean Set sp = MappointControl1.ActiveMap.Shapes.AddShape(GeoAuto ShapeType.geoShapeRectangle, loc, 1, 1) sp.Select sp.Delete End If End If End If End Sub If button is "right" you can see the menu, but you can't move the pushpin. I hope is usefull for someone. Thanks. |
| |||
|
Hi, This is a very good idea I made a little change to the code here: Code: pp = (Pushpin)mapSelection;
loc = MP.ActiveMap.GetLocation(80, 0, 0);
// etc
Code: pp = mapSelection as Pushpin;
if(pp != null) {
loc = MP.ActiveMap.GetLocation(80, 0, 0);
// etc
__________________ rgds, Wilfried Mestdagh www.mestdagh.biz MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
![]() |
| Tags |
| immoveable, locations, making, pushpin |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Making Sq. kilometre territory's | Anonymous | MapPoint 2006/2009 Discussion | 5 | 03-03-2006 08:36 AM |
| Help making searchable state map | cptmcnair | MapPoint 2006/2009 Discussion | 0 | 10-22-2005 07:48 PM |
| Making Maps Uneditable? | zmclean | MapPoint 2006/2009 Discussion | 3 | 08-24-2005 03:36 AM |
| Making an automated task in a commandline | jcjdoss | MapPoint 2006/2009 Discussion | 0 | 07-29-2005 01:31 PM |
| Making Overlay/Hiding Datasets | cexpjared | MapPoint 2006/2009 Discussion | 0 | 07-12-2005 10:15 AM |