重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
安卓的话哪基尘可以用GPS取。
创新互联 - 托管服务器,四川服务器租用,成都服务器租用,四川网通托管,绵阳服务器托管,德阳服务器托管,遂宁服务器托管,绵阳服务器托管,四川云主机,成都云主机,西南云主机,托管服务器,西南服务器托管,四川/成都大带宽,服务器机柜,四川老牌IDC服务商
import android.app.Activity;
import android.os.Bundle;
import android.location.*;
import android.content.*;
import android.util.Log;
import android.widget.TextView;
public class GPSLocationListenActivity extends Activity implements LocationListener {
LocationManager locman;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
locman = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
}
@Override
protected void onResume(){
if (locman != null){
locman.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,0,this);
}
super.onResume();
}
@Override
protected void onPause(){
if (locman != null){
locman.removeUpdates(this);
}
super.onPause();
}
@Override
public void onLocationChanged(Location location){
TextView textView1 = (TextView)findViewById(R.id.textView1);
textView1.setText("Latitude:Longitude - "
+String.valueOf(location.getLatitude()) +":"+String.valueOf(location.getLongitude()));
锋逗
TextView textView2 = (TextView)findViewById(R.id.textView2);
textView2.setText(String.valueOf(location.getTime()));
Log.v("----------", "----------");
Log.v("Latitude", String.valueOf(location.getLatitude()));
Log.v("Longitude", String.valueOf(location.getLongitude()));
Log.v("Accuracy", String.valueOf(location.getAccuracy()));
Log.v("Altitude", String.valueOf(location.getAltitude()));
Log.v("Time", String.valueOf(location.getTime()));
Log.v("Speed", String.valueOf(location.getSpeed()));
Log.v("Bearing", 李禅String.valueOf(location.getBearing()));
}
@Override
public void onProviderDisabled(String provider){
}
@Override
public void onProviderEnabled(String provider){
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras){
switch(status){
case LocationProvider.AVAILABLE:
Log.v("Status","AVAILABLE");
break;
case LocationProvider.OUT_OF_SERVICE:
Log.v("Status","OUT_OF_SERVICE");
break;
case LocationProvider.TEMPORARILY_UNAVAILABLE:
Log.v("Status","TEMPORARILY_UNAVAILABLE");
break;
}
}
}
// 地址解析器 根据经纬度获取当前车辆所在地址
var gc = new BMap.Geocoder();
gc.getLocation(pointAdd, function(rs)
{
var addComp = rs.addressComponents;
var adr="车辆: "旦正备+chepai+"\r\r"+"位于: "+addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber;
//创建信息窗口,点击标注时显示标注对应的模毁车牌号码以及当前清敬地址
var infoWindow1 = new BMap.InfoWindow(adr);
marker.addEventListener("click", function(){this.openInfoWindow(infoWindow1);});
});
由于键盘上没有 ° 键,所以我在程镇樱序中把它换成 * 键了。
运行下面御派丛程序,从控制台输入 40582974 ,回车 ,输出结果:22*32.7658′
若
输入:57335948
则
输出:31*51.1983'
import java.math.BigDecimal;
import java.util.Scanner;
public class LatitudeTransform {
public static void main(String[] args) {
Scanner sca = new Scanner(System.in);
String in = sca.nextLine();
//将控制台接收到的输入转成数字
long num = Long.parseLong(in);
//利用整除舍弃余数得到度数值
long du = (num / 30000) / 60;
//将控制台接收到的数值除以30000,得到度和分的混合结果,再对60取余,得到分的部分
BigDecimal fen = new BigDecimal(num).divide(new BigDecimal(30000), 4, BigDecimal.ROUND_HALF_UP).remainder(
new BigDecimal(60));
System.out.println(du + "*" + fen + "'");
}
}
下面的部分是,在控制台输入22°32.7658′ ,回车得到40582974。开始的时候读你的问题理解反了,所以先写的这个,也给你吧,要是没用就算了~呵呵。
import java.util.Scanner;
public class LatitudeTransform {
public static void main(String[] args) {
Scanner sca = new Scanner(System.in);
String in = sca.nextLine();
String result = transform(in);
System.out.println(result);
}
private static String transform(String in) {
/羡烂/将输入的字符串分成两截,分别为度数du_string,分数fen_string
String du_string = in.substring(0, in.indexOf("*"));
//substring方法两个参数遵循规则"前包含后不包含",例,”1234“.substring(0,2)返回的结果是index为0到1的子串,即"12"
String fen_string = in.substring(in.indexOf("*") + 1, in.indexOf("'"));
double du = Double.parseDouble(du_string);
double fen = Double.parseDouble(fen_string);
Long result = (long) ((du * 60 + fen) * 30000);
return result.toString();
}
}
range = 180 / PI * 1 / 6372.797; //里面的 1 就代表搜索 1km 之内,单位坦大km
lngR = range / Math.cos(myLat * PI / 180);
maxLat =myLat + range;//最大纬度
minLat = myLat - range;//最圆判小纬度
maxLng = myLng + lngR;//最大经度
minLng = myLng - lngR;//最小经度橘信改
类型全部是double
还有一种估算方法
请参考