The GeoCoordinateWatcher class lets you to get the Geo Coordinates in Windows Phone . It is part of the Location Services which lets you to retrieve the current location (latitude,longitude) , speed etc.
How to get the Current Geo Coordinates in Windows Phone using C# ?
To use the GeoCoordinateWatcher to retreive the GPS location , you should add the reference to the System.Devices.Location namespace.
Below is a sample source code that demonstrates the usage of the GeoCoordinateWatcher class to get the current Geo Coordinates in Windows Phone using C#
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Microsoft.Phone.Controls; using Microsoft.Phone.Tasks; using System.Device.Location; namespace PhoneApp1 { public partial class MainPage : PhoneApplicationPage { // Constructor public MainPage() { InitializeComponent(); } private void button1_Click(object sender, RoutedEventArgs e) { GeoCoordinateWatcher GeoCoordinater; GeoCoordinater = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); GeoCoordinater.PositionChanged += new EventHandler<GeoPositionChangedEventArgs>(watcher_PositionChanged); GeoCoordinater.Start(); } void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs e) { MessageBox.Show("Latitude = " + e.Position.Location.Latitude + " : Longitude = " + e.Position.Location.Longitude); } } }
1 Comment
does this use internet or just use gps ???