android 百度地圖v3.2.0擷取實際地址

來源:互聯網
上載者:User

android 百度地圖v3.2.0擷取實際地址

百度地圖升級到v3.2.0後,api發生挺大的變化的,但是下載的Demo卻不是最新版本的。

在v3.2.0之前擷取詳細地址只要:option.setIsNeedAddress(true);

但是升級後api發生了挺大的變化,該屬性找不到了。so 只能研究使用新的api,但是很遺憾我找了好久都沒找到最新擷取詳細地址的用法(如果有知道,求告知!!)


皇天不負有心人啊,終於在一個不小心中發現了類GeoCoder,成功擷取到詳細地址,使用如下:

GeoCoder coder = GeoCoder.newInstance();ReverseGeoCodeOption reverseCode = new ReverseGeoCodeOption();ReverseGeoCodeOption result = reverseCode.location(new LatLng(location.getLatitude(), location.getLongitude()));coder.reverseGeoCode(result);coder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() {@Overridepublic void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) {Log.i("===","onGetReverseGeoCodeResult:" + result.getAddress());}@Overridepublic void onGetGeoCodeResult(GeoCodeResult result) {Log.i("===", "onGetGeoCodeResult:" + result.getAddress());}});
註:location是定位後返回的結果,在介面BDLocationListener中!!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.