导航:首页 > 操作系统 > android经纬度转换地址

android经纬度转换地址

发布时间:2022-09-13 06:29:25

A. android编程怎么把GPS坐标转换为百度地图坐标

实现将一组GPS模块获取的经纬度数据在网络地图上绘制轨迹
/**
* 标准的GPS经纬度坐标直接在地图上绘制会有偏移,这是测绘局和地图商设置的加密,要转换成网络地图坐标
*
* @return 网络地图坐标
*/
publicGeoPoint gpsToBai(String data) {//data格式 nmea标准数据 ddmm.mmmmm,ddmm.mmmm 如3030.90909,11449.1234
String[] p = data.split(",");
intlat = (int) (((int) (Float.valueOf(p[0]) /100) + (100* (Float//将ddmm.mmmm格式转成dd.ddddd
.valueOf(p[0]) /100.0- (int) (Float.valueOf(p[0]) /100)) /60.0)) * 1E6);
intlon = (int) (((int) (Float.valueOf(p[1]) /100) + (100* (Float
.valueOf(p[1]) /100.0- (int) (Float.valueOf(p[1]) /100)) /60.0)) * 1E6);
GeoPoint pt =newGeoPoint(lat, lon);
returnCoordinateConvert.fromWgs84ToBai(pt);//转成网络坐标
}

B. android关于后台给定经纬度不同地图怎么转换

有的时候,我们需要在自己的应用中获取到经纬度,然后打开别的地图应用并显示该经纬度的当前位置. 前提是手机上已经安装了高德或者网络之类的地图应用. 如果有多个,系统会有一个默认的选择打开提示.
下面是具体代码:

[java] view plain
Uri uri = Uri.parse("geo:38.899533,-77.036476");
Intent it = new Intent(Intent.Action_VIEW,uri);
startActivity(it);

另外找到一些其他常用的调用应用的代码片段,放到这里备用:

[java] view plain
<p>//显示某个坐标在地图上</p><p>Uri uri = Uri.parse("geo:38.899533,-77.036476");
Intent it = new Intent(Intent.Action_VIEW,uri);
startActivity(it); </p><p>//显示路径</p>Uri uri = Uri.parse("<a href="http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en">http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en</a>");
Intent it = new Intent(Intent.ACTION_VIEW,URI);

//发送短信或彩信

Intent it = new Intent(Intent.ACTION_VIEW);
it.putExtra("sms_body", "The SMS text");
it.setType("vnd.android-dir/mms-sms");
startActivity(it);

//发送短信

Uri uri = Uri.parse("smsto:10086");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.putExtra("sms_body", "cwj");
startActivity(it);

//发送彩信

Uri uri = Uri.parse("content://media/external/images/media/23");
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra("sms_body", "some text");
it.putExtra(Intent.EXTRA_STREAM, uri);
it.setType("image/png");
startActivity(it);

//发送邮件
Uri uri = Uri.parse("mailto:[email protected]");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
startActivity(it);

Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_EMAIL, [email protected]);
it.putExtra(Intent.EXTRA_TEXT, "The email body text");
it.setType("text/plain");
startActivity(Intent.createChooser(it, "Choose Email Client"));

Intent it=new Intent(Intent.ACTION_SEND);
String[] tos={"[email protected]"};
String[] ccs={"[email protected]"};
it.putExtra(Intent.EXTRA_EMAIL, tos);
it.putExtra(Intent.EXTRA_CC, ccs);
it.putExtra(Intent.EXTRA_TEXT, "The email body text");
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
it.setType("message/rfc822");
startActivity(Intent.createChooser(it, "Choose Email Client"));

//播放媒体文件

Intent it = new Intent(Intent.ACTION_VIEW);
Uri uri = Uri.parse("file:///sdcard/cwj.mp3");
it.setDataAndType(uri, "audio/mp3");
startActivity(it);

Uri uri = Uri.withAppendedPath(MediaStore.Audio.Media.INTERNAL_CONTENT_URI, "1");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);

//卸载APK

Uri uri = Uri.fromParts("package", strPackageName, null);
Intent it = new Intent(Intent.ACTION_DELETE, uri);
startActivity(it);

//卸载apk 2
Uri uninstallUri = Uri.fromParts("package", "xxx", null);
returnIt = new Intent(Intent.ACTION_DELETE, uninstallUri);

//安装APK
Uri installUri = Uri.fromParts("package", "xxx", null);
returnIt = new Intent(Intent.ACTION_PACKAGE_ADDED, installUri);

//播放音乐

Uri playUri = Uri.parse("file:///sdcard/download/sth.mp3");
returnIt = new Intent(Intent.ACTION_VIEW, playUri);

//发送附近

Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");
it.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/cwj.mp3");
sendIntent.setType("audio/mp3");
startActivity(Intent.createChooser(it, "Choose Email Client"));

//market上某个应用信,pkg_name就是应用的packageName

Uri uri = Uri.parse("market://search?q=pname:pkg_name");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);

//market上某个应用信息,app_id可以通过www网站看下

Uri uri = Uri.parse("market://details?id=app_id");
Intent it = new Intent(Intent.ACTION_VIEW, uri);
startActivity(it);

//调用搜索

Intent intent = new Intent();
intent.setAction(Intent.ACTION_WEB_SEARCH);
intent.putExtra(SearchManager.QUERY,"android123")
startActivity(intent);

C. 怎么在android百度地图通过经纬度来定位并且显示出地图位置

1、设置AndroidManfest.xml权限ViewCode2、配置jar包3、初始化设置BMapManagerViewCodemapManager=newBMapManager(this);mapManager.init("",newMyMKGeneralListener());//设置通知间隔:iMaxSecond-最大通知间隔,单位:秒;iMinSecond-最小通知间隔,单位:秒mapManager.getLocationManager().setNotifyInternal(20,5);4、获取手机经纬度,并显示地址信息ViewCodemapManager.getLocationManager().requestLocationUpdates(newMyLocationListener());mapManager.start();在LocationListener中获取经纬度{@(Locationarg0){intjin=(int)(arg0.getLatitude()*1000000);intwei=(int)(arg0.getLongitude()*1000000);tv1.setText("经度:"+jin+",纬度:"+wei);MKSearchsearch=newMKSearch();search.init(mapManager,newMyMKSearchListener());search.reverseGeocode(newGeoPoint(jin,wei));}}在MKSearch接口中进行地址转化

D. android中怎么经纬度怎么转换为地址

使用网络地图API的地理编码呀

E. android 输入一个地址 转成经纬度 为什么第二次就不进ongetaddrresult

如果打算写一些LBS方面的的应用,可能用到地址与经纬度的互相转换。android.location.Geocoder类提供了此功能。实际上,Geocoder既提供了前向转换,也提供了后向转换——它可以获取地址并返回经纬度,也可以将经纬度对转换为一组地址。

可以通过各种方式来描述位置。例如,getFromLocationName() 方法可以获得地方的名称、物理地址和机场编号,或者该位置的流行名称。这些方法提供了一个地址列表(List<Address>),而不是一个地址。因为这些方法返回多个结果,官方建议最好提供1~5的maxResults 值来限制结果集,下面我们来看一个查询地址的例子,和上次一样我们得自己定义一个类继承MapActivity。

我们可以试着写一个输入地名返回经纬度的程序。

在XML中定义一个输入框,一个按钮,一个MapView.

用户输入一个地名点击按钮,返回经纬度。

这是按钮的OnCliclk方法,其他省略。

public void onClick(View v) {
try {
EditText loc = (EditText) findViewById(R.id.location);
String locationName = loc.getText().toString();
List<Address> addressList = geocoder.getFromLocationName(
locationName, 5);
if (addressList != null && addressList.size() > 0) {
int lat = (int) (addressList.get(0).getLatitude() * 1E6);
int lng = (int) (addressList.get(0).getLongitude() * 1E6);

GeoPoint pt = new GeoPoint(lat, lng);
mapView.getController().setZoom(15);
mapView.getController().setCenter(pt);
}
} catch (Exception e) {
e.printStackTrace();
}
}

这样写感觉是没什么错,实际测试时发现,如果输入“tian an men”就可以返回经纬度,但输入“天安门”就会抛异常,说服务不可以用什么的,网上也有遇到这问题的人,eoe上边也有,但都不了了之了。国外也有输入英文抛异常的,http://code.google.com/p/android/issues/detail?id=8816,

在21楼发现了新的方法,完全放弃了getFromLocationName方法,用的是The Google Geocoding API

这个API整合可以代替先前的方法,输入地名返回JSON或者XML格式的文件,包含一对地址信息。

XML为http://maps.googleapis.com/maps/api/geocode/xml?address=北京交通大学&sensor=false

JSON为http://maps.googleapis.com/maps/api/geocode/json?address=北京交通大学&sensor=false

现在需要自己写一个静态方法去解析XML或者JSON,以JSON为例:

public class MapUtility {
public static JSONObject getLocationInfo(String address) {

HttpGet httpGet = new HttpGet("http://maps.google."

+ "com/maps/api/geocode/json?address=" + address

+ "&sensor=false");

HttpClient client = new DefaultHttpClient();

HttpResponse response;

StringBuilder stringBuilder = new StringBuilder();

try {

response = client.execute(httpGet);

HttpEntity entity = response.getEntity();

InputStream stream = entity.getContent();

int b;

while ((b = stream.read()) != -1) {

stringBuilder.append((char) b);

}

} catch (ClientProtocolException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

JSONObject jsonObject = new JSONObject();

try {

jsonObject = new JSONObject(stringBuilder.toString());

} catch (JSONException e) {

e.printStackTrace();

}

return jsonObject;

}

// converts JSONObject into a GeoPoint.

public static GeoPoint getGeoPoint(JSONObject jsonObject) {

Double lon = new Double(0);

Double lat = new Double(0);

try {

lon = ((JSONArray) jsonObject.get("results")).getJSONObject(0)

.getJSONObject("geometry").getJSONObject("location")

.getDouble("lng");

lat = ((JSONArray) jsonObject.get("results")).getJSONObject(0)

.getJSONObject("geometry").getJSONObject("location")

.getDouble("lat");

} catch (JSONException e) {

e.printStackTrace();

}

return new GeoPoint((int) (lat * 1E6), (int) (lon * 1E6));

}

}

第一个方法根据地址取得JSON,第二个方法从JSON提取坐标。

最后程序效果如下:

Android地址与经纬度转换

最后,应该考虑在不同于UI线程的线程中执行地理编码操作。很明显:这项操作很耗时,而且你一定不希望UI在进行地理编码时停顿,如果停顿会阻塞整个用户界面。当在执行一些耗时的操作的时候,不能及时地分发 事件,包括用户界面重绘事件。从用户的角度来看,应用程序看上去像挂掉了。更糟糕的是,如果阻塞应用程序的时间过长,Android会向用户提示 一些信息,即打开一个“应用程序没有相应(application not responding)” 的对话框。

F. 如何通过百度地图将经纬度转换为地址信息

网络地图AndroidSDK是一套基于Android2.1及以上版本设备的应用程序接口。您可以使用该套SDK开发适用于Android系统移动设备的地图应用,通过调用地图SDK接口,您可以轻松访问网络地图服务和数据,构建功能丰富、交互性强的地图类应用程序。自v4.0起,适配AndroidWear,支持Android穿戴设备,新增室内图相关功能。网络地图AndroidSDK提供的所有服务是免费的,接口使用无次数限制。您需申请密钥(key)后,才可使用网络地图AndroidSDK。任何非营利性产品请直接使用,商业目的产品使用前请参考使用须知。在您使用网络地图AndroidSDK之前,请先阅读网络地图API使用条款。

G. Android高德通过经纬度获取地理位置

首先导入依赖:
首次导入依赖的过程可能有点慢

然后在需要用到逆地理编码的类或弹窗或其他地方中实现 GeocodeSearch.OnGeocodeSearchListener
监听
例子:

并实现其两个方法:

通过经纬度逆地理编码得到位置核心编码

这样我们就可以实现通过经纬度得到一个位置信息了

福利赠送~~~

1、继承 OnGeocodeSearchListener 监听。
2、构造 GeocodeSearch 对象,并设置监听。

3、通过 GeocodeQuery(java.lang.String locationName, java.lang.String city) 设置查询参数,调用 GeocodeSearch 的 getFromLocationNameAsyn(GeocodeQuery geocodeQuery) 方法发起请求。

4、通过回调接口 onGeocodeSearched 解析返回的结果。

说明:

1)可以在回调中解析result,获取坐标信息。

2)返回结果成功或者失败的响应码。1000为成功,其他为失败(详细信息参见网站开发指南-实用工具-错误码对照表)

H. 安卓开发高德地图得到经纬度如何得到地址信息

直接在gps工程测试模式下定位,就可以得到经纬度还有你所在地的高度。你也可以使用凯立德这类的导航软件。

I. 怎么在android百度地图通过经纬度来定位并且显示出地图位置

可以参考如下内容:

使用Android自带的LocationManager和Location获取位置的时候,经常会有获取的location为null的情况,并且操作起来也不是很方便,在这个Demo里我使用了网络地图API中的定位SDK,可以一次性获取当前位置经纬度以及详细地址信息,还可以获取周边POI信息,同时可以设定位置通知点,当到达某一位置时,发出通知信息等方式来告知用户。jar包下载以及官方文档请参照:网络定位SDK,前提是需要注册网络开发者账号。
下面来看看定位的基本原理,目前,定位SDK可以通过GPS、基站、Wifi信号进行定位。基本定位流程如下图所示,当应用程序向定位SDK发起定位请求时,定位SDK会根据当前的GPS、基站、Wifi信息生成相对应的定位依据。然后定位SDK会根据定位依据来进行定位。如果需要,定位SDK会向定位服务器发送网络请求。定位服务器会根据请求的定位依据推算出对应的坐标位置,然后根据用户的定制信息,生成定位结果返回给定位SDK。

阅读全文

与android经纬度转换地址相关的资料

热点内容
2k21公园怎么换服务器 浏览:724
php释放数据库连接 浏览:722
php网页抓取工具 浏览:726
android设置对齐方式 浏览:23
linux创建网页 浏览:280
净化车间门算法 浏览:934
安卓怎么搞jpg 浏览:546
如来佛祖命令雷神去下界 浏览:856
新电脑管家下载好怎么解压 浏览:530
php获取接口数据 浏览:766
最后的命令 浏览:921
如何添加手机app桌面快捷图标 浏览:427
ui设计师与程序员 浏览:417
寿司pdf 浏览:828
pythonbg是什么 浏览:248
c数值算法程序大全 浏览:787
android整点报时 浏览:221
稀土pdf 浏览:536
单片机电子锁 浏览:596
通达信机智资金流指标公式源码 浏览:216