GET Location details - latitude and longitide RRS feed

  • Question

  • Hi,

    I want to get the latitude and longitude for a desktop/tablet using windows services c#.

    I tried with the below code, but it doesnt work. IT always returns 'Unknown'

            public void GetGeoProperites(out double latitude, out double longitude)
                latitude = 0.0;
                longitude = 0.0;
                //Create an instance of the GeoCoordinateWatcher class
                GeoCoordinateWatcher gwatcher = new GeoCoordinateWatcher();
                // Do not suppress prompt, and wait 1000 milliseconds to start.
                gwatcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
                //Store all the Position information inside PositionNow 
                var PositionNow = gwatcher.Position;
                if (!PositionNow.Location.IsUnknown)
                    latitude = PositionNow.Location.Latitude;
                    longitude = PositionNow.Location.Longitude;

    Can anyone please help on this?

    There is 'Windows.devices.geolocation' API in windows store apps which works fine and returns the values fro both tablet and desktop irrespective of GPS sensor. I am looking at a equivalent API in windows services c#.



    Friday, July 19, 2013 7:11 AM