MapPoint Forums

MapForums

Community of VE/MapPoint Users and Developers




Center pushin only if out of viewable area??

This is a discussion on Center pushin only if out of viewable area?? within the MapPoint 2006/2009 Discussion forums, part of the Map Forums category; That's my problem... I've a gps device sending coordinates to a my applications.. my app so.. get coordinates and move ...


Go Back   MapPoint Forums > Map Forums > MapPoint 2006/2009 Discussion

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 03-18-2005
Member
Yellow Belt
 
Join Date: Dec 2004
Posts: 44
Center pushin only if out of viewable area??

That's my problem...

I've a gps device sending coordinates to a my applications.. my app so.. get coordinates and move a pushpin on the MapPoint control. Till here everything is ok. Now tha problem is that... I move the pushpin and center the map to the pushpin location.. but the control is redraw each time.. is there a way to lock this redraw??? or better.. recenter the map only if pushpin location is out of vievable area?
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 03-19-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Hi,

LocationToX and LocationToY return -1 if Location object is outside visible area, so you can use these 2 to recenter when needed.
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 03-22-2005
Member
Yellow Belt
 
Join Date: Dec 2004
Posts: 44
Can you post me an example.. i use this code:

//mTarget = my moving pushpin
mTarger.Location = this.mMap.GetLocation(lat, lon, 0);

//mLoc is a MapPoint.Location
mLoc = this.mMap.GetLocation(lat, lon, 0);

//the place where i center the map
mLoc.GoTo();

Can you show me how to adapt my code to work with LocationTox and Y

regards
Gianmaria
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 03-22-2005
Junior Member
Yellow Belt
 
Join Date: Feb 2005
Posts: 19
Hi,

this is an example in C#. (not tested)

with oMap the current map, and mLoc your location.

if(oMap.LocationToX(mLoc) <0 || oMap.LocationToY <0 )
{
mLoc.GoTo();
}
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 03-22-2005
Senior Member
Black Belt
 
Join Date: Nov 2004
Posts: 2,112
Hi,

It seems that6 the help is lying a little It does not return -1 if outside.. I tryed this and this work:

Code:
        private void centeronlyifnotinviewToolStripMenuItem_Click(object sender, EventArgs e)
        {
            double Lat = 51;
            double Lon = 4.1;
            double Alt = 20;

            Location Loc = MP.ActiveMap.GetLocation(Lat, Lon, Alt);
            MP.ActiveMap.GoToLatLong(Lat, Lon, Alt);

            Thread.Sleep(1000);

            // we place a pushpin in view
            Lat = 51.02;
            Loc = MP.ActiveMap.GetLocation(Lat, Lon, Alt);
            Pushpin PP = MP.ActiveMap.AddPushpin(Loc, "");
            PP.Symbol = 1;

            // if location is out of view then we center again
            if (MP.ActiveMap.LocationToX(Loc) < 0 ||
                MP.ActiveMap.LocationToX(Loc) > MP.ActiveMap.Width ||
                MP.ActiveMap.LocationToY(Loc) < 0 ||
                MP.ActiveMap.LocationToY(Loc) > MP.ActiveMap.Height)
                PP.GoTo();

            Thread.Sleep(1000); // does not center

            // we move the pushpin out of view
            Lat = 50;
            Loc = MP.ActiveMap.GetLocation(Lat, Lon, Alt);
            PP = MP.ActiveMap.AddPushpin(Loc, "");
            PP.Symbol = 1;

            // if location is out of view then we center again
            if (MP.ActiveMap.LocationToX(Loc) < 0 ||
                MP.ActiveMap.LocationToX(Loc) > MP.ActiveMap.Width ||
                MP.ActiveMap.LocationToY(Loc) < 0 ||
                MP.ActiveMap.LocationToY(Loc) > MP.ActiveMap.Height)
                    PP.GoTo();  // jipieeee it centers :)
        }
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
area, center, pushin, viewable


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
Center Point colin_turner99 MapPoint 2006/2009 Discussion 1 07-14-2006 02:38 PM
Find center of a polygon Anonymous MapPoint 2006/2009 Discussion 11 05-25-2005 09:54 AM
Center Map to a pushpin? Anonymous MapPoint 2006/2009 Discussion 7 02-14-2005 05:31 PM
Pushin Tool Version 2.4 Now Available Eric Frost Products: Pushpin Tool, Single State Mapper 1 09-03-2003 02:32 PM
Determining Center of a Zipcode shaistasohail MapPoint 2006/2009 Discussion 0 10-21-2002 11:13 PM


All times are GMT -5. The time now is 02:13 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