Hi,
it looks to me that zooming XamMap with the mouse wheel always zooms relative to the center of the map. I don't find this logical and want to center the zoom operation on the mouse pointer position. Is there an option in XamMap to enable this ? If not, what is the best way to achieve this ?
Regards,Leif
HI,
You should consider using our XamGeographicMap instead.
Here a help link
Sincerely, Matt Developer Support Engineer
pointing to a different control (XamGeographicMap) makes the following questions pop up immediately:What is the difference between the XamGeographicMap and the XamMap control, and why do you have two such related map controls in the control suite ?
I have invested a lot of time/coding to get the XamMap work in my scenario (see e.g. http://es.infragistics.com/community/forums/t/78334.aspx and http://es.infragistics.com/community/forums/t/78465.aspx). I don't like that idea of switching control if I can't utilize most of my XamMap code, just to get mouse centric zoom. I've played a bit with the XamGeographicMap and it looks like my custom MapTileSource (used to implement local caching) can be used through the GeographicMapImagery class, and I think that my rotation workarounds might also possibly work.
What I don't get to work is simply setting the correct viewport of the XamGeographicMap. I use the XamMap for background map images only and its viewport is fully controlled by a custom control that is in a WPF layer on top of the map. With the XamMap control I use the XamMap.MapProjection.ProjectToMap method to convert my geodetic (Wgs84) lon/lat coordinates to XamMap viewport coordinates, and this works perfectly.
With the XamGeographicMap control I've tried using the XamGeographicMap.GetZoomFromGeographic method to convert my lon/lat coordinates to XamGeographicMap viewport coordinates, but the result is always wrong. It covers the wrong area bounds and the error is dependent on zoom level.
I also can't find anything like the XamMap.WindowZoomMaximum, XamMap.MapProjectionType, XamMap.IsPannable and XamMap.IsZoomable properties in the XamGeographicMap class.
If there is no simple solution to my existing problem of mouse centric zoom in XamMap, how can I easily migrate my XamMap code to XamGeographicMap ?
I am attaching a sample that may help you resolve your issue.
I Wired up the Element Hover Event and stored the element being hovered over.
Then in the XamMap PreviewMouseWheel, I set the XamMap Window's Rect to the hovered Elements Rect.
Sincerely,
Matt Developer Support Engineer
the attached sample does not seem to give me exactly what I want, since the mouse cursor no longer point to the same location within the hovered element after using the mouse wheel, but I guess I can use related features to implement a workaround. I was hoping for something out-of-the box, though, and hope this essential feature will be added in a later release.
I'm also still very interested in knowing why my test to set the four corners of a XamGeographicMap does not work as easy as for the XamMap, and what I can do to implement this. However, I guess I probably should ask this question in the XamGeograhicMap forum instead (?)
HI Leif,
Yes, you should place your XamGeoGraphicMap question in the XamGeogrphicMap forum.
Matt
Developer Support Engineer
I've now tried to use the attached sample for a workaround, but it is of no use at all. The attached sample simply puts the hovered element at the center of the view. I need a zoom that behaves just as the default zoom, but zooms in/out on the exact position of the mouse pointer, keeping the same part of the map below the mouse pointer. This is the default operation of the XamGeographicMap and should at least be an option for the XamMap as well. I've posted a feature request for this, but need an immediate workaround.
I've now made a workaround myself that seems to work, using the XamMap mouse wheel preview event. If anyone else needs the solution, please see the attached code snippet.