Community of MapPoint and Bing Maps 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: ...
| |||||||
| Today's Posts | Twitter Feed | 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. Code: //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_SelectionChangeEvent 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);
}
}
Last edited by Eric Frost; 02-11-2010 at 10:03 AM.. |
| |||
| 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 www.comfortsoftware.be MapPoint coding demo Order MapPoint 2009 with Routing and User Tools Spreadsheet |
| |||
| Re: Making Pushpin Locations Immoveable
Hello everyone, I've found these old thread and I'm very interested in a solution to make pushpin unmovable. Is there no simple way, a flag "fixed" or something like it? Thanks, Matteo |
| ||||
| Re: Making Pushpin Locations Immoveable
No - nothing like that!
__________________ Winwaed Software Technology LLC http://www.winwaed.com See http://www.mapping-tools.com for MapPoint Tools See the Geoweb Guru for online mapping |
![]() |
| Tags |
| immoveable, locations, making, pushpin |
Currently Active Users Viewing This Thread: 2 (0 members and 2 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Making Sq. kilometre territory's | Anonymous | MapPoint Desktop Discussion | 5 | 03-03-2006 07:36 AM |
| Help making searchable state map | cptmcnair | MapPoint Desktop Discussion | 0 | 10-22-2005 06:48 PM |
| Making Maps Uneditable? | zmclean | MapPoint Desktop Discussion | 3 | 08-24-2005 02:36 AM |
| Making an automated task in a commandline | jcjdoss | MapPoint Desktop Discussion | 0 | 07-29-2005 12:31 PM |
| Making Overlay/Hiding Datasets | cexpjared | MapPoint Desktop Discussion | 0 | 07-12-2005 09:15 AM |