本文整理汇总了C#中GeoCoordinateWatcher.TryStart方法的典型用法代码示例。如果您正苦于以下问题:C# GeoCoordinateWatcher.TryStart方法的具体用法?C# GeoCoordinateWatcher.TryStart怎么用?C# GeoCoordinateWatcher.TryStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoCoordinateWatcher
的用法示例。
在下文中一共展示了GeoCoordinateWatcher.TryStart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CustomMapControl_Loaded
void CustomMapControl_Loaded( object sender, RoutedEventArgs e )
{
// initialize image overlay layer
imageLayer = new MapLayer();
map.Children.Add(imageLayer);
// setup map control
try {
Settings.IsoManager.Instance.Load();
map.SetView(
Settings.IsoManager.Instance.MapSettings.Coordinate,
Settings.IsoManager.Instance.MapSettings.ZoomLevel
);
}
catch (Exception) { }
// activate geo location watcher
if (watcher == null) {
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
watcher.MovementThreshold = 1.0;
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
if (!watcher.TryStart(true, TimeSpan.FromSeconds(5))) {
MessageBox.Show("Please enable Location Service on the Phone.", "Warning", MessageBoxButton.OK);
}
}
}
示例2: PhoneApplicationPage_Loaded
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
GeoCoordinateWatcher TopCarrotwatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
TopCarrotwatcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(TopCarrotwatcher_StatusChanged);
TopCarrotwatcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(TopCarrotwatcher_PositionChanged);
TopCarrotwatcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
}
示例3: Location
public void Location()
{
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
// Do not suppress prompt, and wait 1000 milliseconds to start.
watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
GeoCoordinate coord = watcher.Position.Location;
if (coord.IsUnknown != true)
{
System.Diagnostics.Debug.WriteLine("Lat: {0}, Long: {1}",
coord.Latitude,
coord.Longitude);
// return ("Lat: " + coord.Latitude + ", Long: " + coord.Longitude);
latitude = coord.Latitude;
longitude = coord.Longitude;
}
else
{
System.Diagnostics.Debug.WriteLine("Unknown");
latitude = -1;
longitude = -1;
}
}
示例4: MainPage
// Constructor
public MainPage()
{
InitializeComponent();
// Init watcher with default accuracy
watcher = new GeoCoordinateWatcher();
// Start listen for coordinates
watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
}
示例5: LocationProvider
public LocationProvider()
{
// Setup position watcher
this.watcher = new System.Device.Location.GeoCoordinateWatcher(System.Device.Location.GeoPositionAccuracy.Default);
watcher.MovementThreshold = MovementTreshold;
watcher.TryStart(false, TimeSpan.FromSeconds(WatcherStartDelay));
watcher.PositionChanged += OnLocationChanged;
}
示例6: map_page
private Pushpin myPushpin; //точка для отображеия координат
#endregion Fields
#region Constructors
//конструктор
public map_page()
{
InitializeComponent();
myGeoWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
myGeoWatcher.MovementThreshold = 100.0f;
myGeoWatcher.StatusChanged += myGeoWatcher_StatusChanged;
myGeoWatcher.PositionChanged += myGeoWatcher_PositionChanged;
//myAccel = new Accelerometer();
//myAccel.CurrentValueChanged += myAccel_CurrentValueChanged;
//myAccel.Start();
myPushpin = new Pushpin();
myGeoWatcher.TryStart(false, TimeSpan.FromSeconds(60));
}
示例7: InitializeGeoCoordinateWatcher
bool InitializeGeoCoordinateWatcher()
{
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
if (watcher.Permission == GeoPositionPermission.Denied)
{
LocationData = new Location { HasPermission = false };
return false;
}
watcher.MovementThreshold = 0;
return watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
}
示例8: GetCurrentLocation
/// <summary>
/// Returns the current cached location from GPS
/// </summary>
/// <returns></returns>
public static GeoCoordinate GetCurrentLocation()
{
//// Simulate location in debugger:
//if (System.Diagnostics.Debugger.IsAttached)
//{
// return new GeoCoordinate((double)32095676 / (double)1000000, (double)34798484 / (double)1000000);
//}
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
watcher.TryStart(true,TimeSpan.FromSeconds(13));
return watcher.Position.Location;
}
示例9: TrackMe
private void TrackMe()
{
startingPoint = null;
CurrentPosition.Children.Clear();
if (myWatcher != null)
{
myWatcher.PositionChanged -= myWatcher_PositionChanged;
myWatcher.Dispose();
myWatcher = null;
}
myWatcher = new GeoCoordinateWatcher();
myWatcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
myWatcher.PositionChanged += myWatcher_PositionChanged;
}
示例10: Init
private void Init()
{
initialized = true;
if (!SettingsManager.Instance.GetApplicationSetting(SettingsManager.App_UseWin7LocationAPI, SettingsManager.Default_UseWin7LocationAPI))
return;
watcher = new GeoCoordinateWatcher();
watcher.TryStart(false, TimeSpan.FromMilliseconds(1000));
watcher.MovementThreshold = double.Parse(ConfigurationManager.AppSettings["Windows7LocationThreshold"]);
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
EnsureIfAvailable();
}
示例11: PlatformSpecificStart
protected override void PlatformSpecificStart(MvxLocationOptions options)
{
if (_geolocator != null)
throw new MvxException("You cannot start the MvxLocation service more than once");
_geolocator = new GeoCoordinateWatcher
{
MovementThreshold = options.MovementThresholdInM
};
_geolocator.TryStart(false, TimeSpan.FromMilliseconds((uint)options.TimeBetweenUpdates.TotalMilliseconds));
_geolocator.StatusChanged += OnStatusChanged;
_geolocator.PositionChanged += OnPositionChanged;
}
示例12: LocationCondition
static LocationCondition()
{
while (true)
{
geo = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
geo.PositionChanged += geo_PositionChanged;
if (!geo.TryStart(true, new TimeSpan(0, 0, 5)))
{
MessageBox.Show("Locality requires location access to function properly.", "Locality", MessageBoxButton.OK, MessageBoxImage.Exclamation);
Environment.Exit(0);
}
else
{
break;
}
}
}
示例13: Get
/// <summary>
/// Get the current location from the Windows location API.
/// </summary>
/// <returns>
/// The <see cref="LatLong"/> instance.
/// </returns>
/// <remarks>
/// This currently includes Thread.Sleep hack to ensure the device is ready.
/// </remarks>
public static LatLong Get()
{
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
watcher.TryStart(true, TimeSpan.FromMilliseconds(1000));
// TODO: hack hack hack
Thread.Sleep(1000);
GeoCoordinate coord = watcher.Position.Location;
return new LatLong()
{
Latitude = coord.Latitude,
Longitude = coord.Longitude
};
}
示例14: GetLocationCourseAndSpeed
public String GetLocationCourseAndSpeed()
{
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher();
watcher.TryStart(true, TimeSpan.FromMilliseconds(1000));
if (watcher.Position.Location.IsUnknown != true)
{
GeoCoordinate coord = watcher.Position.Location;
System.Diagnostics.Debug.WriteLine("Course: {0}, Speed: {1}",
coord.Course,
coord.Speed);
return ("Course: "+coord.Course+", Speed: "+coord.Speed);
}
else
{
System.Diagnostics.Debug.WriteLine("Unknown");
return ("Return Unknown");
}
}
示例15: GetCurrentGpsPosition
private void GetCurrentGpsPosition()
{
//request for Location services
if (SettingsHelper.IsLocationServicesEnabled())
{
GeoCoordinateWatcher geoWatcher = new GeoCoordinateWatcher();
geoWatcher.MovementThreshold = 50;
geoWatcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(geoWatcher_PositionChanged);
if (!geoWatcher.TryStart(false, TimeSpan.FromSeconds(30)))
{
Debug.WriteLine("Unsuccessful gps start");
}
}
else
{
PrivacyHelper.ShowLocationServicesPrivacyPrompt();
if (SettingsHelper.IsLocationServicesEnabled())
{
GetCurrentGpsPosition();
}
}
}