Search code examples
c#windows-phone-7windows-phonebing-mapscompass-geolocation

Show the heading direction of a compass on a map


I have a Windows Phone application with a map. On this map, there are several pushpins (different infos on the map) and a pushpin of the current position. I want to show the heading direction (the direction the user looks with his phone) on the current position pushpin (using the compass angle). I already have a custom control that rotates according to the compass value. What I don't know is how to incorporate it into the map, i.e. show it on the current position on the map.

Do you have any ideas?

Thank you very much.

PS: If you don't know what I mean, I intend to do something like it's available in the (Nokia) Here Maps Here Maps heading direction with compass.


Solution

  • I don't have a complete answer. What I know is you can add any control to a map using this technique:

    myMap.Layers.Add(new MapLayer()
     {    
        new MapOverlay()
        {
            GeoCoordinate = new GeoCoordinate(37.795032,-122.394927),
            Content = new Ellipse
            {
                Fill = new SolidColorBrush(Colors.Red),
                Width = 40,
                Height = 40
            }
        }});
    

    This comes from http://developer.nokia.com/Community/Wiki/What's_new_in_Windows_Phone_8

    Now this will display a simple red dot, but I understand you can put just about any control in there. Use your control, bind the rotation to a value that will hold the rotation in your view model and I think you are quite done. Does this work for you?