本文整理汇总了C#中GeoCoordinateWatcher类的典型用法代码示例。如果您正苦于以下问题:C# GeoCoordinateWatcher类的具体用法?C# GeoCoordinateWatcher怎么用?C# GeoCoordinateWatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeoCoordinateWatcher类属于命名空间,在下文中一共展示了GeoCoordinateWatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RouteDetailsPanoramaPage
public RouteDetailsPanoramaPage()
{
InitializeComponent();
pins = new List<Pushpin>();
var clusterer = new PushpinClusterer(map1, pins, this.Resources["ClusterTemplate"] as DataTemplate);
SystemTray.SetIsVisible(this, true);
if (watcher == null)
{
//---get the highest accuracy---
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High)
{
//---the minimum distance (in meters) to travel before the next
// location update---
MovementThreshold = 10
};
//---event to fire when a new position is obtained---
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
//---event to fire when there is a status change in the location
// service API---
watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
watcher.Start();
map1.Center = new GeoCoordinate(58.383333, 26.716667);
map1.ZoomLevel = 15;
map1.Mode = new MyMapMode();
}
}
示例2: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var photoResult = PhoneHelpers.GetApplicationState<PhotoResult>("PhotoResult");
if (this.watcher == null)
{
// Use high accuracy.
this.watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
this.watcher.MovementThreshold = 20;
// Use MovementThreshold to ignore noise in the signal.
this.watcher.StatusChanged += this.GeoCoordinateWatcherStatusChanged;
}
this.watcher.Start();
if ((this.ViewModel != null) && (photoResult != null))
{
this.ViewModel.LoadPhoto(photoResult);
}
else
{
this.NavigationService.GoBack();
}
}
示例3: add
public add()
{
InitializeComponent();
GeoCoordinateWatcher my_watcher = new GeoCoordinateWatcher();
var my_position = my_watcher.Position;
// set a default value, if we canot get the current location,
// the we'll default to Redmond, WA
double latitude = 47.674;
double longitude = -122.12;
if (!my_position.Location.IsUnknown)
{
latitude = my_position.Location.Latitude;
longitude = my_position.Location.Longitude;
}
myTerraService.TerraServiceSoapClient client = new myTerraService.TerraServiceSoapClient();
client.ConvertLonLatPtToNearestPlaceCompleted += new EventHandler<myTerraService.ConvertLonLatPtToNearestPlaceCompletedEventArgs>(client_ConvertLonLatPtToNearestPlaceCompleted);
client.ConvertLonLatPtToNearestPlaceAsync(new myTerraService.LonLatPt() { Lat = latitude, Lon = longitude });
}
示例4: GeoLocationService
public GeoLocationService()
{
_watcher = new GeoCoordinateWatcher();
_watcher.StatusChanged += Watcher_StatusChanged;
_watcher.PositionChanged += Watcher_PositionChanged;
_watcher.Start();
}
示例5: MainPage
public MainPage()
{
if (NetworkInterface.GetIsNetworkAvailable())
{
InitializeComponent();
if (watcher == null)
{
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
watcher.MovementThreshold = 10.0f;
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
}
geolist = new List<GeoCoordinate>();
loc = new List<Local>();
stateWatcher();
GetLocales();
navi = true;
}
else
{
InitializeComponent();
string a = "ADVERTENCIA: Sin Conexión";
string b = "Esta Aplicación requiere de conexión a internet, ya que consulta información en línea.";
MessageBox.Show(a+"\n"+b+"\nGracias");
}
}
示例6: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
gcw = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
gcw.PositionChanged += gcw_PositionChanged;
gcw.StatusChanged += gcw_StatusChanged;
map.ColorMode = Microsoft.Phone.Maps.Controls.MapColorMode.Light;
map.CartographicMode = Microsoft.Phone.Maps.Controls.MapCartographicMode.Road;
map.LandmarksEnabled = true;
map.PedestrianFeaturesEnabled = true;
map.ZoomLevel = 17;
if (!App.IsInBackground)
{
txtCurrentSpeed.Foreground = new SolidColorBrush(Colors.Black);
overlay.Content = txtCurrentSpeed;
routeQuery.TravelMode = Microsoft.Phone.Maps.Services.TravelMode.Walking;
routeQuery.QueryCompleted += rq_QueryCompleted;
MapLayer currentSpeedLayer = new MapLayer();
currentSpeedLayer.Add(overlay);
map.Layers.Add(currentSpeedLayer);
map.Layers.Add(historicalReadingsLayer);
map.MapElements.Add(polyline);
}
base.OnNavigatedTo(e);
}
示例7: MainPage
public MainPage()
{
InitializeComponent();
_watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
_watcher.MovementThreshold = 20;
_watcher.StatusChanged += (sender, args) =>
{
if (args.Status == GeoPositionStatus.Ready)
{
try
{
GeoCoordinate coordinates = _watcher.Position.Location;
DevCenterAds.Longitude = coordinates.Longitude;
DevCenterAds.Latitude = coordinates.Latitude;
}
finally
{
_watcher.Stop();
}
}
};
_watcher.Start();
LayoutUpdated += OnLayoutUpdated;
}
示例8: MainPage
// Constructor
public MainPage()
{
InitializeComponent();
if (watcher == null)
{
//Get the highest accuracy.
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High)
{
//The minimum distance (in meters) to travel before the next location update.
MovementThreshold = 10
};
//Event to fire when a new position is obtained.
watcher.PositionChanged += new
EventHandler<GeoPositionChangedEventArgs
<GeoCoordinate>>(watcher_PositionChanged);
//Event to fire when there is a status change in the location service API.
watcher.StatusChanged += new
EventHandler<GeoPositionStatusChangedEventArgs>
(watcher_StatusChanged);
watcher.Start();
}
// position change code start
watcher.PositionChanged += this.watcher_PositionChanged;
watcher.StatusChanged += this.watcher_StatusChanged;
watcher.Start();
// position chane code stop
}
示例9: GeoLocationManager
public GeoLocationManager()
{
// using high accuracy;
_watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
_watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(WatcherStatusChanged);
_watcher.PositionChanged += new System.EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(WatcherPositionChanged);
}
示例10: MapDetail
// bool MapSet = false;
public MapDetail()
{
InitializeComponent();
//sets up GeoCoordinateWatcher
if (watcher == null)
{
//---get the highest accuracy---
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High)
{
//---the minimum distance (in meters) to travel before the next
// location update---
MovementThreshold = 10
};
//---event to fire when a new position is obtained---
watcher.PositionChanged += new
EventHandler<GeoPositionChangedEventArgs
<GeoCoordinate>>(watcher_PositionChanged);
//---event to fire when there is a status change in the location
// service API---
watcher.StatusChanged += new
EventHandler<GeoPositionStatusChangedEventArgs>
(watcher_StatusChanged);
watcher.Start();
}
setMap();
}
示例11: JustRun
public JustRun()
{
InitializeComponent();
running = false;
Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode =
Microsoft.Phone.Shell.IdleDetectionMode.Disabled;
// The watcher variable was previously declared as type GeoCoordinateWatcher.
if (watcher == null)
{
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); // using high accuracy
//watcher.MovementThreshold = 1; // use MovementThreshold to ignore noise in the signal
watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
watcher.Start();
Globals.lat = watcher.Position.Location.Latitude;
Globals.lon = watcher.Position.Location.Longitude;
}
Globals.dist = 0.0;
if (Globals.usingMeters)
{
tbUnits.Text = "km";
tbV.Text = "km/h";
}
else
{
tbUnits.Text = "mi";
tbV.Text = "mph";
}
}
示例12: MapPage
public MapPage()
{
InitializeComponent();
// Define event handlers
NotificationClient.Current.NotificationReceived += new EventHandler(getNotification);
NotificationClient.Current.UriUpdated += new EventHandler(setUri);
// Reinitialize the GeoCoordinateWatcher
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
watcher.MovementThreshold = 5;//distance in metres
// Add event handlers for StatusChanged and PositionChanged events
watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
// Start data acquisition
watcher.Start();
if (firstRun)
{
firstRun = false;
// Ask for next check-in point
DisplayInfoText("Retrieving first checkpoint", 10);
QueryCidLocationWithWait(10);
// Ask for number of checkpoints
send(GlobalVars.serveraddr + "get_n?token=" + GlobalVars.token, SendType.GetN);
}
}
示例13: CustomMapControls
/// <summary>
/// Creates a new CustomMapControls class object using default images.
/// </summary>
/// <param name="map">Map object on which actions are to be performed. </param>
public CustomMapControls(Map map)
{
try
{
this._map = map;
_map.Children.Add(ImageLayer);
_homeImage.Source = new BitmapImage(new Uri("/CustomMapLibrary;component/Resources/home.png", UriKind.Relative));
_pinImage.Source = new BitmapImage(new Uri("/CustomMapLibrary;component/Resources/pin.png", UriKind.Relative));
_pinImage.Tap += new EventHandler<GestureEventArgs>(pinImage_Tap);
_map.Tap += new EventHandler<GestureEventArgs>(map_Tap);
_map.Hold += new EventHandler<GestureEventArgs>(map_Hold);
_watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
_watcher.MovementThreshold = 20;
_watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
_watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
_watcher.Start(true);
//Forward Button Press Event from Popup Window
_popupWindow.btnDetails.Click += new RoutedEventHandler(btnDetails_Click);
}
catch (Exception e)
{
MessageBox.Show("Error: " + e.Message + "\n" + e.Data + "\n" + e.StackTrace);
}
}
示例14: ConcertDetails
public ConcertDetails()
{
InitializeComponent();
GeoCoordinateWatcher geoWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
geoWatcher.StatusChanged += geoWatcher_StatusChanged;
geoWatcher.PositionChanged += geoWatcher_PositionChanged;
geoWatcher.Start();
map.ZoomLevel = 15;
if (PhoneApplicationService.Current.State["connected"].Equals(1))
{
Uri imageUriConnected = new Uri("/Images/ic_connected.png", UriKind.Relative);
BitmapImage imageBitmapConnected = new BitmapImage(imageUriConnected);
imgConnected.Source = imageBitmapConnected;
}
else
{
Uri imageUriNotConnected = new Uri("/Images/ic_not_connected.png", UriKind.Relative);
BitmapImage imageBitmapNotConnected = new BitmapImage(imageUriNotConnected);
imgConnected.Source = imageBitmapNotConnected;
}
Concert concert = (Concert)PhoneApplicationService.Current.State["Concert"];
Uri imageUri = new Uri(concert.image, UriKind.Absolute);
BitmapImage imageBitmap = new BitmapImage(imageUri);
imgConcert.Source = imageBitmap;
textBeginDate.Text = concert.start_datetime;
textEndDate.Text = concert.end_datetime;
textLocation.Text = concert.location;
textNbSeets.Text = "Number of seats : " + concert.nb_seats;
textTitle.Text = concert.name_concert;
geoWatcher = new GeoCoordinateWatcher();
geoWatcher.StatusChanged += geoWatcher_StatusChanged;
geoWatcher.Start();
}
示例15: Initialize
public void Initialize(Action<GeoPositionStatus> del)
{
if (IsInitialized)
{
_watcher.Start();
return;
}
// instantiate the GeoCoordinateWatcher
_watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
// Create an observable sequence of GeoPositionStatusChanged events.
var locationStatusEventAsObservable = Observable.FromEvent<GeoPositionStatusChangedEventArgs>(
ev => _watcher.StatusChanged += ev,
ev => _watcher.StatusChanged -= ev);
// For simplicity, create a stream of GeoPositionStatus objects from the stream of
// GeoPositionStatusChangedEventArgs objects
var statusFromEventArgs = from ev in locationStatusEventAsObservable
select ev.EventArgs.Status;
// Subscribe to the Observable stream. InvokeStatusChanged will be called each time
// a new GeoPositionStatus object arrives in the stream.
statusFromEventArgs.Subscribe(status => del(status));
// Start the GeoCoordinateWatcher
_watcher.Start();
IsInitialized = true;
}