This is a migrated thread and some comments may be shown as answers.

Zooming bugs

3 Answers 192 Views
Map
This is a migrated thread and some comments may be shown as answers.
Jason D
Top achievements
Rank 1
Veteran
Jason D asked on 03 Dec 2018, 07:32 PM

I checked this in a new project and see the same results. Seeing this with multiple versions, including the latest.

MouseWheelMode="ZoomToPoint" does not work. It zooms but does not center on the point.

The ZoomLevel binding is not updating correctly and/or partially ignoring MaxZoomLevel. For example, if I set a MaxZoomLevel of 19, and use the mouse wheel to zoom, I will receive the following values:

17,18,19,20

If I keep zooming in with the mouse wheel, I will continue to receive "20", even though the zoom isn't changing. If I then zoom out with the wheel, the ZoomLevel then changes from 20 to 18.

<telerik:RadMap MaxZoomLevel="19" UseSpringAnimations="False"
    ZoomLevel="{Binding ZoomLevel, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Center="30.11,-91"
    MouseClickMode="None" MouseWheelMode="ZoomToPoint">
    <telerik:RadMap.Provider>
        <telerik:OpenStreetMapProvider/>
    </telerik:RadMap.Provider>
</telerik:RadMap>

3 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 06 Dec 2018, 02:50 PM
Hello Jason,

Thank you for the provided code snippet.

I am going to address your questions in order.

By default the MouseWheelMode - ZoomToPoint does not center the map on the point of the mouse. However, you can achieve this by setting the MouseDoubleClickMode or MouseClickMode to "ZoomPointToCenter".

As for the ZoomLevel and MaxZoomLevel properties, I investigated this scenario thoroughly and what you have observed is the expected behavior. Please, allow me to elaborate:
Internally the RadMap keeps the ZoomLevel property within the bounds of the min and max zoom level through dependency property coercion. This way the internal ZoomLevel of the map is kept within the required range and the control won't zoom outside that range. However, when you have bound the ZoomLevel property to a property in your view model, the binding gets updated before the dependency property is coerced. (In that specific case, the binding is updated to 20 and only after that the property is coerced to 19) You can check out the following topic, where this wpf behavior is discussed: Why does my data binding see the real value instead of the coerced value? If you want to coerce the value of the bound property in your view model, you can implement some logic in the setter which keeps the ZoomLevel value between the min and max zoom levels.

Hope you find this helpful.

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Jason D
Top achievements
Rank 1
Veteran
answered on 18 Dec 2018, 10:02 PM

Thanks for the info on the coereced value. That is disappointing.

The MouseWheel still seems to be a bug, though. The RadMap source code shows that OnMouseWheel calls ChangeZoomOnMouseWheel which calls ZoomToPoint when using MouseWheelBehavior.ZoomToPoint. This works fine when double-clicking, but not for the Wheel. It looks like OnMouseWheel is being called with a Point with no values, but it's hard to tell. I think the problem is in this code:

        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            if (this.MouseControl != null)
            {
                Point point = e.GetPosition(this);

                e.Handled = this.MouseControl.HandleMouseWheel(e.Delta, point);
            }

            base.OnMouseWheel(e);
        }

Compare with DoubleClick which calls:

            this.OnMouseDoubleClick(e.GetPosition(this));

0
Vladimir Stoyanov
Telerik team
answered on 21 Dec 2018, 03:55 PM
Hello Jason,

Thank you for the provided code snippets.

The ZoomToPoint method is called when the MouseDoubleClickMode or MouseWheelMode behavior is ZoomToPoint. You can observe that when the MouseDoubleClickMode is ZoomToPoint, the OnMouseDoubleClick method calls the ClickModeAction method which in turn calls the ZoomToPoint method. Thus the behavior of zooming with mouse click or mouse wheel is identical when the mode is ZoomToPoint. The difference is that the MouseClickMode and MouseDoubleClickMode can be set to ZoomPointToCenter which first centers the map. My understanding was that this is what you were going for. Currently, the MouseWheelMode does not have this option.

To summarize the ZoomToPoint and ZoomPointToCenter modes provide different behaviors and the MouseWheelMode does not provide an option to zoom the point to center. In order to achieve that you can use the MouseClickMode or MouseDoubleClickMode.

I hope this helps.

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Map
Asked by
Jason D
Top achievements
Rank 1
Veteran
Answers by
Vladimir Stoyanov
Telerik team
Jason D
Top achievements
Rank 1
Veteran
Share this question
or