The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

Marking current location on Map RRS feed

  • General discussion

  • Hi everyone,

      I am pretty new to Windows Phone app development, I working on a small app in which i need to display the current location of the user on the map. I tried it using following code snippet from a example.  Is there a way to get the current location coordinates ???  I heard using GPS we can get the current location lat,long values how can we get that ???

    #code snippet


                Geolocator myGeolocator = new Geolocator();
                Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();
                Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
                GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);

                this.mapWithMyLocation.Center = myGeoCoordinate;
                this.mapWithMyLocation.ZoomLevel = 14;

                Ellipse myCircle = new Ellipse();
                myCircle.Fill = new SolidColorBrush(Colors.Blue);
                myCircle.Height = 20;
                myCircle.Width = 20;
                myCircle.Opacity = 50;

                MapOverlay myLocationOverlay = new MapOverlay();
                myLocationOverlay.Content = myCircle;
                myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
                myLocationOverlay.GeoCoordinate = myGeoCoordinate;

                MapLayer myLocationLayer = new MapLayer();



     public static GeoCoordinate ConvertGeocoordinate(Geocoordinate geocoordinate)
                return new GeoCoordinate
                    geocoordinate.Altitude ?? Double.NaN,
                    geocoordinate.AltitudeAccuracy ?? Double.NaN,
                    geocoordinate.Speed ?? Double.NaN,
                    geocoordinate.Heading ?? Double.NaN

    My actual requirement is to display the location of user on the map. If i know the latitide, langitude values I able to do It, My major problem is finding them.  


    Any suggestion is Appreciated


    Wednesday, May 14, 2014 6:56 AM

All replies