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

Zoom on SHIFT drag

2 Answers 12 Views
Map
This is a migrated thread and some comments may be shown as answers.
Renier Pretorius
Top achievements
Rank 1
Iron
Renier Pretorius asked on 05 Jan 2017, 08:26 AM

Hi, I am trying to implement a shift drag zoom on my map. The map has several layers and I have bound the Center property of the map to my ViewModel as I use this to pan the map when selecting a feature on one of the layers through an external control, e.g. selecting a node from a list of nodes would then select the map shape and pan it into view. Now if I shift+drag to zoom to a rectangle, the map does zoom, but the center remains static. Any suggestion how to accomplish both use cases?

<telerik:RadMap x:Name="radMap"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                MouseClickMode="SelectItem"
                MouseSelectionMode="ZoomIn"
                MouseWheelMode="ZoomToPoint"
                MinZoomLevel="6"
                MaxZoomLevel="14"
                ZoomLevel="6"
                Center="{Binding MapCentre, Mode=TwoWay}"
                GeoBoundsNW="-21.8, 13.9"
                GeoBoundsSE="-35.0, 35.8"
                UseDefaultLayout="False"
                >

Regards

Renier

2 Answers, 1 is accepted

Sort by
0
Renier Pretorius
Top achievements
Rank 1
Iron
answered on 06 Jan 2017, 05:20 AM

SOLVED: Figured this out by myself. The issue seem to be the way the zoom to rectangle is implemented and the sequence of evvents. As my application is concerned with only a certain area on the map I restrict the user from panning outside of this area by setting the GeoBound properties and always load the map zoomed out over these bounds. it seems as if the RadMap's zoom to rectangle event sequence is to first centre the view on the centre of the rectangle and then to zoom into the extend of the rectangle. however as the map is geo bound, the centre action produce no change at the initial zoom and thus it merely zooms in at the initial center position.

Removing the geo bounds sorted the problem. I also "manually" implemented the actual zoom event by setting the MouseSelectionMode to raise an event and implementing the SelectionRectangleChanged event as follows:

<telerik:RadMap x:Name="radMap"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                MouseClickMode="None"
                MouseSelectionMode="RaiseEvent"
                SelectionRectangleChanged="radMap_SelectionRectangleChanged"
                MouseWheelMode="ZoomToPoint"
                MinZoomLevel="6"
                MaxZoomLevel="14"
                Center="{Binding MapCentre}"
                ZoomLevel="6"
                UseDefaultLayout="True"
                NavigationVisibility="Collapsed"
                ZoomBarVisibility="Collapsed"
                CommandBarVisibility="Collapsed"
                MouseLocationIndicatorVisibility="Visible"
                ScaleVisibility="Visible"
                >

 

private void radMap_SelectionRectangleChanged(object sender, SelectionRectangleChangedEventArgs e)
{
    var map = sender as Telerik.Windows.Controls.RadMap;
    if (map != null)
    {
        map.SetView(e.Rect);
    }
     
}

 

Not sure if anyone else is still using silverlight, but maybe this helps them.

 

0
Martin Ivanov
Telerik team
answered on 06 Jan 2017, 09:25 AM
Hello Renier,

Thank you for sharing your solution with the community. 

Regards,
Martin
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Map
Asked by
Renier Pretorius
Top achievements
Rank 1
Iron
Answers by
Renier Pretorius
Top achievements
Rank 1
Iron
Martin Ivanov
Telerik team
Share this question
or