Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 8 of 8

Making Pushpin Locations Immoveable

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: ...

  1. #1
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    Making Pushpin Locations Immoveable

    Fernando Velasquez shares a solution for preventing a user from moving pushpins on a map

    Read the full article here: http://www.mp2kmag.com/articles.asp?...ins.immoveable

  2. #2
    samitha is offline Junior Member White Belt
    Join Date
    Jun 2003
    Posts
    1

    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 11:03 AM.

  3. #3
    Fer
    Fer is offline Junior Member White Belt
    Join Date
    Jun 2003
    Posts
    11

    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

  4. #4
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137
    thanks samitha, is very usefull for me your new code using the mouse buttons, but i'm using Visual Basic, not C and I don't know how to implement the "unSelectPushpin". Any idea?
    Thanks very much.

  5. #5
    Anonymous is offline Senior Member Black Belt
    Join Date
    Jul 2002
    Posts
    5,137

    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.

  6. #6
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    This is a very good idea
    I made a little change to the code here:

    Code:
                    pp = &#40;Pushpin&#41;mapSelection;
                    loc = MP.ActiveMap.GetLocation&#40;80, 0, 0&#41;;
                    // etc
    Changed to:
    Code:
                    pp = mapSelection as Pushpin;
                    if&#40;pp != null&#41; &#123;
                        loc = MP.ActiveMap.GetLocation&#40;80, 0, 0&#41;;
                        // etc
    In this case pp will evaluate to null if mapSelection is not of type Pushpin, and in the first case if it is object of wrong type it will generate an exception because of the tyepcast.

  7. #7
    Shaman is offline Junior Member White Belt
    Join Date
    Jan 2010
    Posts
    1

    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

  8. #8
    Winwaed's Avatar
    Winwaed is offline Mapping-Tools.com Black Belt
    Join Date
    Feb 2004
    Location
    Irving,Texas
    Posts
    1,859
    Blog Entries
    60

    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Making Sq. kilometre territory's
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 03-03-2006, 08:36 AM
  2. Help making searchable state map
    By cptmcnair in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 10-22-2005, 07:48 PM
  3. Making Maps Uneditable?
    By zmclean in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 08-24-2005, 03:36 AM
  4. Making an automated task in a commandline
    By jcjdoss in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 07-29-2005, 01:31 PM
  5. Making Overlay/Hiding Datasets
    By cexpjared in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 07-12-2005, 10:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


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