Code example for GeomagneticField

Methods: getDeclination

0
        if (timestamp == 0) {
            // Hack for Samsung phones which don't populate the time field 
            timestamp = System.currentTimeMillis();
        } 
 
        GeomagneticField field = new GeomagneticField(
                (float) location.getLatitude(),
                (float) location.getLongitude(),
                (float) location.getAltitude(), timestamp);
        variation = field.getDeclination();
    } 
 
    public void onLocationChanged(Location location) {
        super.onLocationChanged(location);
 
//        if (toggle.isChecked() == true) { 
//            GeoPoint center = mv.getMapCenter(); 
//            int top = center.getLatitudeE6() - mv.getLatitudeSpan() / 2; // 画面上に見える範囲 
//            int bottom = center.getLatitudeE6() + mv.getLatitudeSpan() / 2; 
//            int left = center.getLongitudeE6() - mv.getLongitudeSpan() / 2; 
//            int right = center.getLongitudeE6() + mv.getLongitudeSpan() / 2;