:::: MENU ::::

Adding controls over Map in Windows Phone 8.1

In windows phone 8 or 8.1 we can put icon/pin to show the location at any coordinate. Adding MapIcon object will do for that. But some time we have to show more details about that location or coordinate at that time adding grid, text block helps to show more data in map. Putting controls over map is easy if we do not have to show those controls in coordinate(lat/long) basis. But if we have to show those controls in exact location then we have to do more exercise.

In map control you can add any object that inherits from DependencyObject to the children collection. You can add location(coordinate) and position using SetLocation and SetNomalizedAnchorPoint properties. So here is code how I did.

So here is code you create pin with having some grid and TextBlock and returns it in form of DependecyObject type object. And other are basic part that you did in map.

Here is how it looks:

Above image is the small part of my project where I have to show the details of particular plane in map dynamically (because of changing lat/long). Writing controls in Xaml and adding over map is not possible because the controls that we write in Xaml is already added in the children collection of Page Control which holds maps control too. So As mention above writing controls in c# (Grid, Rectangle whatever…), wrapping it as DependencyObject type and passing it to the children collection of map control will help to achieve our goal.

[Tips] Do not forgot to check Location Capabilities in AppxManifest file. And full source code is here.

Happy Coding!!! 🙂