Precise control over map view

2 posts, 0 answers
  1. Pete
    Pete avatar
    2 posts
    Member since:
    Apr 2012

    Posted 28 Sep 2016 Link to this post

    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? 

  2. Petar Mladenov
    Petar Mladenov avatar
    2991 posts

    Posted 30 Sep 2016 Link to this post

    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"                           

    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)

    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

    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.
Back to Top