Pan and Zoom

Jun 2, 2009 at 1:24 PM

Hi,

It seems like when you pan the map with the right mouse button, that the currentposition of the map does not get changed.  If you pan, and then hit the zoom scroll bar (on the demo), it will zoom in to where the map originally started, not to where you have panned it to.

Am I doing something wrong, or is this just a bug?  What would the best workaround to this be?

Jun 2, 2009 at 2:07 PM

it's just style of demos, but you can easily do that:

private void sliderZoom_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
{
         int zn = (int) e.NewValue;
         if(zn != MainMap.Zoom && this.IsLoaded)
         {
            MainMap.CurrentPosition = MainMap.FromLocalToLatLng((int) MainMap.ActualWidth/2, (int) MainMap.ActualHeight/2);
            MainMap.Zoom = zn;
         }
}
Jun 4, 2009 at 9:42 AM

Hi radioman,

this seems not to work.

When I use this code, the map zooms in where the mouse currently hovers, not where the center of the current map is.

This is true when I use the mouse wheel to zoom. If I use the slider, the map zooms in where the red dot is, and still not to the center of the visble map area.

best Regards, Marcel

Jun 4, 2009 at 10:16 AM

i repeat ;]

 

      private void sliderZoom_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
      {
         int zn = (int) e.NewValue;
         if(zn != MainMap.Zoom && this.IsLoaded)
         {
            MainMap.CurrentPosition = MainMap.FromLocalToLatLng((int) MainMap.ActualWidth/2, (int) MainMap.ActualHeight/2);
            MainMap.Zoom = zn;
         }
      }
Jun 4, 2009 at 10:23 AM

You're fast! :-) Thanks for the great control overall.

But, doing it so, did not work, it behaves as described above. Most probably I unterstand that as a bug whereas it is a feature.

I have now managed to archive what I wanted by examinig your code and overriding a method. When I use this in my GMap-derived class, I get what I want, which is zooming into the center of the visible map:

[snippet]

        protected override void OnMouseWheel(MouseEventArgs e)
        {
            ZoomToLevel(this.Zoom + Math.Sign(e.Delta));
        }

[/snippet]

 

Best Regards, Marcel

Jun 4, 2009 at 10:26 AM

ahh.. you want zoom by mouse to center?

Jun 4, 2009 at 11:31 AM

Yes, exactly as Google Earth does with the mouse wheel.

Marcel Suter, Software Developer

T. +41 31 950 42 30

M. +41 76 387 70 06

F. +41 31 950 42 49

marcel.suter@enkom.com

ENKOM INVENTIS AG

Worbstrasse 225 / Postfach

CH-3073 Guemligen

www.enkom.com

Confidentiality Notice
The information contained in this Email, and any attachments, is intended for the named recipients only. It may contain confidential and/or privileged information. If you are not the intended recipient, you must not copy, distribute, or take any action in reliance on it. Any views expressed do not necessarily reflect the views of the company. If you receive this Email by mistake, please advise the sender by using the reply facility in your Email software and then delete it.


Von: radioman [mailto:notifications@codeplex.com]
Gesendet: Donnerstag, 4. Juni 2009 11:26
An: Suter Marcel, Enkom Inventis AG
Betreff: Re: Pan and Zoom [gmap4dotnet:58192]

From: radioman

ahh.. you want zoom by mouse to center?

Read the full discussion online.

To add a post to this discussion, reply to this email (gmap4dotnet@discussions.codeplex.com)

To start a new discussion for this project, email gmap4dotnet@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Jun 5, 2009 at 2:52 PM

Using:

MainMap.CurrentPosition = MainMap.FromLocalToLatLng((int) MainMap.ActualWidth/2, (int) MainMap.ActualHeight/2);

 works perfect for centering the map.

Jun 5, 2009 at 3:22 PM

ok, check MouseWheelZoomType