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

Navigation commands

1 Answer 81 Views
Map
This is a migrated thread and some comments may be shown as answers.
Rieni De Rijke
Top achievements
Rank 1
Rieni De Rijke asked on 09 Mar 2011, 07:39 PM
When we should make our own navigationbuttons, then what kind of command could we write in the on-click-event?

private void GoEastClick(object sender, RoutedEventArgs e)
{
    RadMap1.....?
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Andrey
Telerik team
answered on 14 Mar 2011, 03:47 PM
Hi Rieni De Rijke,

Unfortunately the map control does not have API for navigation commands.
You can use available API for custom navigation buttons to change center of map or you can fire appropriate KeyDown events which will be processed by map control.
The sample code is below.

private void GoEastClick(object sender, RoutedEventArgs e)
{
    this.RaiseKeyDownEvent(Key.Right);
}
  
private void RaiseKeyDownEvent(Key key)
{
    KeyEventArgs keyEventArgs = new KeyEventArgs(Keyboard.PrimaryDevice, PresentationSource.FromVisual(this.radMap), 0, key);
    keyEventArgs.RoutedEvent = UIElement.KeyDownEvent;
    this.radMap.RaiseEvent(keyEventArgs);
}



private void GoEastClick(object sender, RoutedEventArgs e)
{
    this.MoveCenterByKey(Key.Right);
}
  
private void MoveCenterByKey(Key key)
{
    Point pixelCenter = this.RecenterByKey(key);
    this.radMap.Center = Location.GetCoordinates(this.radMap, pixelCenter);
}
  
private Point RecenterByKey(Key key)
{
    Point adjustmentFactor = new Point(this.ActualWidth / 3, this.ActualHeight / 3);
    Point pixelCenter = Location.LogicalToPixel(this.radMap, this.radMap.SpatialReference.GeographicToLogical(this.radMap.Center));
  
    switch (key)
    {
        case Key.Left:
            pixelCenter.X -= adjustmentFactor.X;
            break;
  
        case Key.Right:
            pixelCenter.X += adjustmentFactor.X;
            break;
  
        case Key.Up:
            pixelCenter.Y -= adjustmentFactor.Y;
            break;
  
        case Key.Down:
            pixelCenter.Y += adjustmentFactor.Y;
            break;
    }
  
    return pixelCenter;
}

All the best,
Andrey Murzov
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Map
Asked by
Rieni De Rijke
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or