मेरे आवश्यकता में सही ढंग से बढ़ रहा है, कंपास मोड में Google maps apps
की तरह में असर है (आप जब current location button twice
लिए क्लिक डेमो देख सकते हैं):की गणना सही एंड्रॉयड
- इस
compass
मोड में, मैप्स हमेशा इतना है कि एक कोण तक घुमायाbluedot arrow
हमेशा शीर्ष स्क्रीन पर इंगित करें।
लेकिन मुझे नहीं पता कि azimuth, pitch, roll
मानों से सही गणना कैसे करें।
public void onSensorChanged(SensorEvent sensorEvent) {
switch (sensorEvent.sensor.getType()) {
case Sensor.TYPE_ACCELEROMETER:
System.arraycopy(sensorEvent.values, 0, mAccelerometers, 0, 3);
break;
case Sensor.TYPE_MAGNETIC_FIELD:
System.arraycopy(sensorEvent.values, 0, mMagnetometers, 0, 3);
break;
default:
break;
}
float[] rotationMatrix = new float[9];
boolean success =
SensorManager.getRotationMatrix(rotationMatrix, null, mAccelerometers, mMagnetometers);
if (success) {
SensorManager.getOrientation(rotationMatrix, mOrientation);
float azimuth = Math.toDegrees(mOrientation[0]);
float pitch = Math.toDegrees(mOrientation[1]);
float roll = Math.toDegrees(mOrientation[2]);
}
// cal to updateBearing();
}
आईओएस में, CLHeading
बिल्कुल सच heading
लौट सकते हैं। क्या android
में कक्षा में एक ही सुविधा है या मैं इसकी गणना कैसे कर सकता हूं? आपकी समस्या असर-उदाहरण
इसके अलावा उत्तर नीचे के लिए लिंक नीचे
क्या इससे मदद मिलती है? http://stackoverflow.com/q/7355679/7292819 – Gary99
@ गैरी 99, कोई आदमी नहीं। – NamNH
क्या आपने यह जांच की है [http://stackoverflow.com/a/4316717/5993410) –