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

Precise control over map view

1 Answer 113 Views
Map
This is a migrated thread and some comments may be shown as answers.
Pete
Top achievements
Rank 1
Pete asked on 28 Sep 2016, 10:18 AM

I've been evaluating the RadMap control for use on one of our applications. I'd like to be able to zoom the map so that the area I am interested in entirely fills the width of the available space for the control e.g. if I shift-select an area such that the selection box left edge touches point "A" and the right edge touches point "B" I want the redrawn map to show "A" at the extreme left edge of the viewing area and "B" at the extreme right edge. It seems that the control selects the nearest discrete zoom level that will include "A" and "B" but this leaves "A" and "B" slightly in from the edge of the viewing area.

Is it possible to achieve what I want, and if so, is there an event that fires allowing me to when the map has redrawn? 

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 30 Sep 2016, 12:26 PM
Hello Pete,

In order to use Selection Rectangle over the RadMap and use the underlying selection event you can set:
<telerik:RadMap x:Name="radMap"                           
                           MouseDragMode="Select"
                           MouseSelectionMode="RaiseEvent"
                           SelectionRectangleChanged="radMap_SelectionRectangleChanged_1"

In the handler you can use the LocationRect returned from event args and pass it to the SetView function:
private void radMap_SelectionRectangleChanged_1(object sender, SelectionRectangleChangedEventArgs e)
       {          
           this.radMap.SetView(e.Rect);              
       }

The RadMap internally will try to bring the rect into the ViewPort. However it does not guarantee the top left and the bottom right will become the exact new topleft and bottomright of the next viewport. 
To achieve this you will need to :
-- calculate the physical positions of the points in question (Location.LogicalToPixel method)
        -- calculate the desired width of the Map
        - set width / height / rendertransform of the map so that the points in question become top left and bottom right

Regards,
Petar Mladenov
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Map
Asked by
Pete
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or