Newer
Older
import {Component} from '@angular/core';
import {IonicPage, NavController, NavParams} from 'ionic-angular';
import {AppService} from "../../../service/appHttpService";
import {Geolocation} from "@ionic-native/geolocation";
//市委组织部坐标
mainLat = 31.205033; //纬度
// mainLat = 31.231871; //纬度test 31.231871, 121.393319
mainLng = 121.444888; //经度
// mainLng = 121.393319; //经度test
nowDay;
constructor(public navCtrl: NavController, public navParams: NavParams,
public appService: AppService, public geolocation: Geolocation) {
}
this.appService.ObserverHttpGetOption('/wisdomgroup/schedule/myScheduleOfToday', null)
this.appService.ObserverHttpGetOption('/wisdomgroup/schedule/signIn', data)
address:'上海市委组织部' //签到地址
};
this.appService.ObserverHttpGet('/wisdomgroup/schedule/signOut',data)
.subscribe((res)=>{
})
}
//计算距离
calcuDistance() {
this.geolocation.getCurrentPosition().then((resp) => {
const distance = this.getDisance(this.mainLat, this.mainLng, resp.coords.latitude, resp.coords.longitude);
alert('距离:' + distance);
}).catch((error) => {
console.log(error);
});
}
let radLat1 = this.toRad(lat1);
let radLat2 = this.toRad(lat2);
let deltaLat = radLat1 - radLat2;
let deltaLng = this.toRad(lng1) - this.toRad(lng2);
let dis = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(deltaLat / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(deltaLng / 2), 2)));
dis = dis * 6378137;
dis = Math.round(dis * 10) / 10;
return dis;
}
toRad(d) {