導航:首頁 > 操作系統 > 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經緯度轉換地址相關的資料

熱點內容
冰櫃壓縮機溫度108 瀏覽:718
阿里雲郵smtp伺服器地址 瀏覽:250
解壓館認知理解 瀏覽:239
為什麼使用非官方伺服器會封號 瀏覽:9
佛山加密文檔軟體 瀏覽:813
港式5張梭哈源碼 瀏覽:241
數據中心pdf 瀏覽:524
crf源碼解析 瀏覽:853
伺服器軟體開發是什麼意思 瀏覽:941
刪除彩信android 瀏覽:862
元宵節猜燈謎h5源碼 瀏覽:69
樂培生app怎麼綁定 瀏覽:762
視頻壓縮不清楚怎麼說 瀏覽:525
加好友伺服器繁忙是怎麼回事 瀏覽:381
怎麼解綁app的支付寶賬號 瀏覽:913
ip地址伺服器不可用怎麼解決方法 瀏覽:185
為什麼軟體需要伺服器 瀏覽:64
redis操作命令大全 瀏覽:597
python字元串重復索引 瀏覽:964
為什麼香信新版本連接不上伺服器 瀏覽:52