本文整理汇总了C#中GeoCoordinateWatcher.Start方法的典型用法代码示例。如果您正苦于以下问题:C# GeoCoordinateWatcher.Start方法的具体用法?C# GeoCoordinateWatcher.Start怎么用?C# GeoCoordinateWatcher.Start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoCoordinateWatcher
的用法示例。
在下文中一共展示了GeoCoordinateWatcher.Start方法的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: 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;
}
示例3: NewStore
public NewStore()
{
InitializeComponent();
markerLayer = new MapLayer();
map2.Layers.Add(markerLayer);
//geoQ = new GeocodeQuery();
//geoQ.QueryCompleted += geoQ_QueryCompleted;
//Debug.WriteLine("All construction done for GeoCoding");
System.Windows.Input.Touch.FrameReported += Touch_FrameReported;
map2.Tap += map2_Tap;
resultList.SelectionChanged += resultList_SelectionChanged;
watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
watcher.MovementThreshold = 20; // 20 meters
watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(OnStatusChanged);
watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(OnPositionChanged);
newCenter();
watcher.Start();
}
示例4: GeoLocationService
public GeoLocationService()
{
_watcher = new GeoCoordinateWatcher();
_watcher.StatusChanged += Watcher_StatusChanged;
_watcher.PositionChanged += Watcher_PositionChanged;
_watcher.Start();
}
示例5: 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";
}
}
示例6: 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();
}
示例7: 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);
}
}
示例8: 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);
}
}
示例9: 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();
}
示例10: Button_Click_1
private void Button_Click_1(object sender, RoutedEventArgs e)
{
gcw = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
gcw.MovementThreshold = 20;
gcw.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(gcw_StatusChanged);
gcw.Start();
}
示例11: OnNavigatedTo
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
_watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High) { MovementThreshold = 0 };
_watcher.PositionChanged += WatcherPositionChanged;
_watcher.StatusChanged += _watcher_StatusChanged;
_watcher.Start();
}
示例12: Initialize
/// <summary>
/// Initializes the application context for use through out the entire application life time.
/// </summary>
/// <param name="frame">
/// The <see cref="T:Microsoft.Phone.Controls.PhoneApplicationFrame" /> of the current application.
/// </param>
public static void Initialize(PhoneApplicationFrame frame)
{
// Initialize Ioc container.
var kernel = new StandardKernel();
kernel.Bind<Func<Type, NotifyableEntity>>().ToMethod(context => t => context.Kernel.Get(t) as NotifyableEntity);
kernel.Bind<PhoneApplicationFrame>().ToConstant(frame);
kernel.Bind<INavigationService>().To<NavigationService>().InSingletonScope();
kernel.Bind<IStorage>().To<IsolatedStorage>().InSingletonScope();
kernel.Bind<ISerializer<byte[]>>().To<BinarySerializer>().InSingletonScope();
kernel.Bind<IGoogleMapsClient>().To<GoogleMapsClient>().InSingletonScope();
kernel.Bind<IDataContext>().To<DataContext>().InSingletonScope();
kernel.Bind<IConfigurationContext>().To<ConfigurationContext>().InSingletonScope();
Initialize(kernel);
// Initialize event handlers and other properties.
GeoCoordinateWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High) {MovementThreshold = 10D};
((DataContext) Data).AppVersion = new AssemblyName(Assembly.GetExecutingAssembly().FullName).Version;
Data.PreventScreenLock.ValueChanged += (old, @new) => { PhoneApplicationService.Current.UserIdleDetectionMode = @new ? IdleDetectionMode.Disabled : IdleDetectionMode.Enabled; };
Data.UseLocationService.ValueChanged += (old, @new) =>
{
if (@new) GeoCoordinateWatcher.Start();
else GeoCoordinateWatcher.Stop();
};
IsNetworkAvailable = NetworkInterface.GetIsNetworkAvailable();
NetworkChange.NetworkAddressChanged += (s, e) => IsNetworkAvailable = NetworkInterface.GetIsNetworkAvailable();
}
示例13: 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
}
示例14: InitializeMap
/// <summary>
/// Initializes the map.
/// </summary>
private async void InitializeMap()
{
_watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High) { MovementThreshold = 10 };
_watcher.PositionChanged += this.OnPositionChanged;
_watcher.Start();
var geoLocator = new Geolocator { DesiredAccuracyInMeters = 10 };
try
{
Geoposition geoposition = await geoLocator.GetGeopositionAsync(TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(10));
var coordinate = geoposition.Coordinate;
var currentLocation = new GeoCoordinate(
coordinate.Latitude,
coordinate.Longitude,
coordinate.Altitude ?? double.NaN,
coordinate.Accuracy,
coordinate.AltitudeAccuracy ?? double.NaN,
coordinate.Speed ?? double.NaN,
coordinate.Heading ?? double.NaN);
Pushpin pushpin = (Pushpin)this.FindName("UserLocation");
pushpin.GeoCoordinate = currentLocation;
}
catch (Exception)
{
// Inform the user that the location cannot be determined.
App.ViewModel.CurrentLocation = null;
}
}
示例15: TopicsModel
public TopicsModel()
: base("TrendingTopics")
{
this.PropertyChanged += (sender, e) =>
{
if (e.PropertyName == "ListSelection")
OnSelectionChanged();
if (e.PropertyName == "SelectedLocation")
UserChoseLocation();
};
geoWatcher = new GeoCoordinateWatcher();
if (Config.EnabledGeolocation == true)
geoWatcher.Start();
Locations = new ObservableCollection<string>();
LocationMap = new Dictionary<string, long>();
refresh = new DelegateCommand((obj) => GetTopics());
showGlobal = new DelegateCommand((obj) => { currentLocation = 1; PlaceName = Localization.Resources.Global; GetTopics(); });
showLocations = new DelegateCommand((obj) => RaiseShowLocations(), (obj) => Locations.Any());
ServiceDispatcher.GetCurrentService().ListAvailableTrendsLocations(ReceiveLocations);
IsLoading = true;
if (Config.EnabledGeolocation == true && (Config.TopicPlaceId == -1 || Config.TopicPlaceId == null))
ServiceDispatcher.GetCurrentService().ListClosestTrendsLocations(new ListClosestTrendsLocationsOptions{ Lat = geoWatcher.Position.Location.Latitude, Long = geoWatcher.Position.Location.Longitude }, ReceiveMyLocation);
else
{
currentLocation = Config.TopicPlaceId.HasValue ? (long)Config.TopicPlaceId : 1;
PlaceName = Config.TopicPlace;
GetTopics();
}
}