Hallo Leute,
ich möchte in Windows Phone 8 meinen Kompass auf eine bestimmte Koordinate zeigen lassen.
Das ist mein Code den ich verwende, nur zeigt er immer nach Norden und ich stehe etwas auf dem Schlauch, wie ich die Richtung ändern kann. Könnt ihr mir helfen?
Danke
PSP_GIGA
ich möchte in Windows Phone 8 meinen Kompass auf eine bestimmte Koordinate zeigen lassen.
PHP:
if (IsInDesignMode)
{
// Code runs in Blend --> create design time data.
}
else
{
if (Compass.IsSupported)
{
// If compass sensor is supported create new compass object and attach event handlers
Compass myCompass = new Compass();
myCompass.CurrentValueChanged += myCompass_CurrentValueChanged;
myCompass.TimeBetweenUpdates = System.TimeSpan.FromMilliseconds(100); // This defines how often heading is updated
myCompass.Calibrate += new System.EventHandler<CalibrationEventArgs>((s, e) =>
{
// This will show the calibration screen
this.IsCalibrationNeeded = true;
});
myCompass.CurrentValueChanged += new System.EventHandler<SensorReadingEventArgs<CompassReading>>((s, e) =>
{
// This will update the current heading value. We have to put it in correct direction
Deployment.Current.Dispatcher.BeginInvoke(() => { this.CurrentHeading = 360 - e.SensorReading.TrueHeading; });
});
// Start receiving data from compass sensor
myCompass.Start();
}
else
{
//MessageBox.Show("Compass is not supported in this device."); // This line produces error if no compass present.
}
}
// Initialize commands
this.CalibrationOKButtonClickCommand = new RelayCommand(() => CalibrationOKButtonClick());
}
void myCompass_CurrentValueChanged(object sender, SensorReadingEventArgs<CompassReading> e)
{
e.SensorReading.MagneticHeading.CompareTo(13.22);
}
Das ist mein Code den ich verwende, nur zeigt er immer nach Norden und ich stehe etwas auf dem Schlauch, wie ich die Richtung ändern kann. Könnt ihr mir helfen?
Danke
PSP_GIGA