本文整理汇总了C#中GeoCoordinateWatcher类的典型用法代码示例。如果您正苦于以下问题:C# GeoCoordinateWatcher类的具体用法?C# GeoCoordinateWatcher怎么用?C# GeoCoordinateWatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GeoCoordinateWatcher类属于命名空间,在下文中一共展示了GeoCoordinateWatcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}
开发者ID:madisp,项目名称:Omnibuss,代码行数:33,代码来源:RouteDetailsPanoramaPage.xaml.cs
示例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();
}
}
开发者ID:ayant,项目名称:Discount-aggregator,代码行数:26,代码来源:UploadPhotoPage.xaml.cs
示例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 });
}
开发者ID:enyblock,项目名称:enyblock_note,代码行数:26,代码来源:add.xaml.cs
示例4: GeoLocationService
public GeoLocationService()
{
_watcher = new GeoCoordinateWatcher();
_watcher.StatusChanged += Watcher_StatusChanged;
_watcher.PositionChanged += Watcher_PositionChanged;
_watcher.Start();
}
开发者ID:AlexanderGrant1,项目名称:PropertyCross,代码行数:7,代码来源:GeoLocationService.cs
示例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");
}
}
开发者ID:Asfiroth,项目名称:MovistApp,代码行数:25,代码来源:MainPage.xaml.cs
示例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);
}
开发者ID:WindowsPhone-8-TrainingKit,项目名称:HOL-RunningTrackerApplication,代码行数:29,代码来源:MainPage.xaml.cs
示例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;
}
开发者ID:mikkoviitala,项目名称:battlelogmobile,代码行数:26,代码来源:MainPage.xaml.cs
示例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
}
开发者ID:27kunal,项目名称:Pocket_Security,代码行数:30,代码来源:MainPage.xaml.cs
示例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);
}
开发者ID:douglaszuniga,项目名称:Reportero-Digital,代码行数:7,代码来源:GeoLocationManager.cs
示例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();
}
开发者ID:VandyApps,项目名称:dining-windows,代码行数:31,代码来源:MapDetail.xaml.cs
示例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";
}
}
开发者ID:frank44,项目名称:Just-Run,代码行数:35,代码来源:JustRun.xaml.cs
示例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);
}
}
开发者ID:bdunlay,项目名称:geoscav,代码行数:28,代码来源:MapPage.xaml.cs
示例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);
}
}
开发者ID:pankajc-optimus,项目名称:windows-lib,代码行数:30,代码来源:CustomMapControls.cs
示例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();
}
开发者ID:rcrozon,项目名称:PartyProject,代码行数:34,代码来源:ConcertDetails.xaml.cs
示例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;
}
开发者ID:ayls,项目名称:EatMyDust,代码行数:30,代码来源:PhoneLocationService.cs
示例16: 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);
}
}
}
开发者ID:jprberlin,项目名称:wheelmap-wp7,代码行数:28,代码来源:CustomMapControl.xaml.cs
示例17: 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();
}
}
开发者ID:rafaelwinter,项目名称:Ocell,代码行数:33,代码来源:TopicsModel.cs
示例18: SettingsPage
public SettingsPage()
{
InitializeComponent();
AdControl.TestMode = false;
//NavigationInTransition navigateInTransition = new NavigationInTransition();
//navigateInTransition.Backward = new SlideTransition { Mode = SlideTransitionMode.SlideDownFadeIn };
//navigateInTransition.Forward = new SlideTransition { Mode = SlideTransitionMode.SlideUpFadeIn };
//NavigationOutTransition navigateOutTransition = new NavigationOutTransition();
//navigateOutTransition.Backward = new SlideTransition { Mode = SlideTransitionMode.SlideDownFadeOut };
//navigateOutTransition.Forward = new SlideTransition { Mode = SlideTransitionMode.SlideUpFadeOut };
//TransitionService.SetNavigationInTransition(this, navigateInTransition);
//TransitionService.SetNavigationOutTransition(this, navigateOutTransition);
// Set toggleswitch checked property as per EnableLocationAd variable
LocalAdToggleSwitch.IsChecked = (Application.Current as App).EnableLocationAd;
//If enable location ad is true then enable gcw_PositionChanged event
if ((Application.Current as App).EnableLocationAd)
{
this.gcw = new GeoCoordinateWatcher();
this.gcw.Start();
this.gcw.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(gcw_PositionChanged);
}
ApplicationIdleDetection.IsChecked = (Application.Current as App).ApplicationIdleDetection;
}
开发者ID:pritamkarmakar,项目名称:Shopping4U,代码行数:25,代码来源:SettingsPage.xaml.cs
示例19: 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();
}
开发者ID:soleon,项目名称:Travlexer,代码行数:36,代码来源:ApplicationContext.cs
示例20: Add
public Add()
{
InitializeComponent();
try
{
GeoCoordinateWatcher myWatcher = new GeoCoordinateWatcher();
var myPosition = myWatcher.Position;
double latitude = 47.674;
double longitude = -122.12;
if (!myPosition.Location.IsUnknown)
{
latitude = myPosition.Location.Latitude;
longitude = myPosition.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 });
}
catch
{
// To be implemented
}
}
开发者ID:sashamyr,项目名称:wp7_notes,代码行数:30,代码来源:Add.xaml.cs
注:本文中的GeoCoordinateWatcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论