I can move around the map using Map.MapTools control on the upper left of the Map Control,
but how do we Navigate/Move around the Map using Arrow Key?
How to Navigate/Move the Map using Arrow Key?
Hi Anggi,
Thanks for your post, but would you please give me more information about what Arrow Key is? is it a customized button?
Waiting for your further information.
Best Regards
Summer
Hi Summer,
What I meant by Arrow Keys are: Up, Left, Right, and Down Key,
Hi Anggi,
We don’t support keyboard pan for silverlight edition.
But you can implement that by add event like this:
Map1.KeyDown += new System.Windows.Input.KeyEventHandler(Map1_KeyDown);
void Map1_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == System.Windows.Input.Key.Left)
{
Map1.Pan(PanDirection.Left, 20);
}
else if (e.Key == System.Windows.Input.Key.Right)
{
Map1.Pan(PanDirection.Right, 20);
}
}
You should make sure the map control always get focus if you follow this way.
Regards,
Don
Hi Anggi,
We don’t support keyboard pan for silverlight edition.
But you can implement that by add event like this:
Map1.KeyDown += new KeyEventHandler(Map1_KeyDown);
void Map1_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.Key == System.Windows.Input.Key.Left)
{
Map1.Pan(PanDirection.Left, 20);
}
else if (e.Key == System.Windows.Input.Key.Right)
{
Map1.Pan(PanDirection.Right, 20);
}
}
You should make sure the map control always get focus if you follow this way.
Regards,
Don
Hi Don,
Thank you for your reply.
I tried to debug your code, but the Map1_KeyDown event never fired.
Is there some sample .SLN that I can try? Thanks.
Hi Anggi,
That’s only a workaround, in fact we don’t really support keyboard operation in SilverLight edition.
I found the event only be fired if your focus keep on our map control, for test you can try to switch focus to map control by tab key for it, but I am not sure whether it can works stably.
Regards,
Don
Hi Don,
Finally I am able to workaround this issue by adding the event to the LayoutRoot.
LayoutRoot.KeyDown += Map1_KeyDown;
Is this some bug or am I missing something?
Hi Anggi,
The LayoutRoot is the container of map in your project, the KeyDown event provided by system, so we cannot handle the event popup in Silverlight’s visual tree.
I think you can add a logic to see whether the mouse position is in map control, if mouse position in map, make LayoutRoot’s KeyDown event works.
Regards,
Don