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

Center pushin only if out of viewable area??

This is a discussion on Center pushin only if out of viewable area?? within the MapPoint Desktop 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 ...

  1. #1
    Gianmaria is offline Member Yellow Belt
    Join Date
    Dec 2004
    Posts
    47

    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?

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

    LocationToX and LocationToY return -1 if Location object is outside visible area, so you can use these 2 to recenter when needed.

  3. #3
    Gianmaria is offline Member Yellow Belt
    Join Date
    Dec 2004
    Posts
    47
    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

  4. #4
    Jeurink is offline 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();
    }

  5. #5
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    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&#40;object sender, EventArgs e&#41;
            &#123;
                double Lat = 51;
                double Lon = 4.1;
                double Alt = 20;
    
                Location Loc = MP.ActiveMap.GetLocation&#40;Lat, Lon, Alt&#41;;
                MP.ActiveMap.GoToLatLong&#40;Lat, Lon, Alt&#41;;
    
                Thread.Sleep&#40;1000&#41;;
    
                // we place a pushpin in view
                Lat = 51.02;
                Loc = MP.ActiveMap.GetLocation&#40;Lat, Lon, Alt&#41;;
                Pushpin PP = MP.ActiveMap.AddPushpin&#40;Loc, ""&#41;;
                PP.Symbol = 1;
    
                // if location is out of view then we center again
                if &#40;MP.ActiveMap.LocationToX&#40;Loc&#41; < 0 ||
                    MP.ActiveMap.LocationToX&#40;Loc&#41; > MP.ActiveMap.Width ||
                    MP.ActiveMap.LocationToY&#40;Loc&#41; < 0 ||
                    MP.ActiveMap.LocationToY&#40;Loc&#41; > MP.ActiveMap.Height&#41;
                    PP.GoTo&#40;&#41;;
    
                Thread.Sleep&#40;1000&#41;; // does not center
    
                // we move the pushpin out of view
                Lat = 50;
                Loc = MP.ActiveMap.GetLocation&#40;Lat, Lon, Alt&#41;;
                PP = MP.ActiveMap.AddPushpin&#40;Loc, ""&#41;;
                PP.Symbol = 1;
    
                // if location is out of view then we center again
                if &#40;MP.ActiveMap.LocationToX&#40;Loc&#41; < 0 ||
                    MP.ActiveMap.LocationToX&#40;Loc&#41; > MP.ActiveMap.Width ||
                    MP.ActiveMap.LocationToY&#40;Loc&#41; < 0 ||
                    MP.ActiveMap.LocationToY&#40;Loc&#41; > MP.ActiveMap.Height&#41;
                        PP.GoTo&#40;&#41;;  // jipieeee it centers &#58;&#41;
            &#125;

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Center Point
    By colin_turner99 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-14-2006, 02:38 PM
  2. Find center of a polygon
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 11
    Last Post: 05-25-2005, 09:54 AM
  3. Center Map to a pushpin?
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 7
    Last Post: 02-14-2005, 05:31 PM
  4. Pushin Tool Version 2.4 Now Available
    By Eric Frost in forum Products: Pushpin Tool, Single State Mapper
    Replies: 1
    Last Post: 09-03-2003, 02:32 PM
  5. Determining Center of a Zipcode
    By shaistasohail in forum MapPoint Desktop Discussion
    Replies: 0
    Last Post: 10-21-2002, 11:13 PM

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