Precise control over map view

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

    Posted 28 Sep 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
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 30 Sep 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"                           
                               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.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top