MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




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


Go Back   MapPoint Forums > Map Forums > MP2K Magazine Articles

Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read



Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-19-2003
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
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
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-23-2003
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.

//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);
}
}
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-25-2003
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
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 01-29-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
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.
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 01-29-2004
Senior Member
Black Belt
 
Join Date: Jul 2002
Posts: 5,138
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.
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 12-28-2004
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
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
Changed to:
Code:
                pp = mapSelection as Pushpin;
                if(pp != null) {
                    loc = MP.ActiveMap.GetLocation(80, 0, 0);
                    // 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.
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
immoveable, locations, making, pushpin


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


All times are GMT -5. The time now is 04:11 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
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