com.amap.api.services.geocoder.RegeocodeAddress Java Examples

The following examples show how to use com.amap.api.services.geocoder.RegeocodeAddress. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReGeocoderActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 响应逆地理编码的批量请求
 */
private void getAddresses() {
	List<LatLonPoint> geopointlist = readLatLonPoints();
	for (final LatLonPoint point : geopointlist) {
		ThreadUtil.getInstance().execute(new Runnable() {
			@Override
			public void run() {
				try {
					RegeocodeQuery query = new RegeocodeQuery(point, 200,
							GeocodeSearch.AMAP);// 第一个参数表示一个Latlng,第二参数表示范围多少米,第三个参数表示是火系坐标系还是GPS原生坐标系
					RegeocodeAddress result = geocoderSearch.getFromLocation(query);// 设置同步逆地理编码请求

					if (result != null && result.getFormatAddress() != null) {
						aMap.addMarker(new MarkerOptions()
								.position(new LatLng(point.getLatitude(), point.getLongitude()))
								.title(result.getFormatAddress()));
					}
				} catch (AMapException e) {
					Message msg = msgHandler.obtainMessage();
					msg.arg1 = e.getErrorCode();
					msgHandler.sendMessage(msg);
				}
			}
		});
	}
}
 
Example #2
Source File: AMAPLocationActivity.java    From sealtalk-android with MIT License 6 votes vote down vote up
@Override
public void onRegeocodeSearched(RegeocodeResult regeocodeResult, int i) {
    if (i == 0) {
        if (regeocodeResult != null && regeocodeResult.getRegeocodeAddress() != null) {
            endAnim();
            centerMarker.setIcon(successDescripter);
            RegeocodeAddress regeocodeAddress = regeocodeResult.getRegeocodeAddress();
            String formatAddress = regeocodeResult.getRegeocodeAddress().getFormatAddress();
            String shortAdd = formatAddress.replace(regeocodeAddress.getProvince(), "").replace(regeocodeAddress.getCity(), "").replace(regeocodeAddress.getDistrict(), "");
            tvCurLocation.setText(shortAdd);
            double latitude = regeocodeResult.getRegeocodeQuery().getPoint().getLatitude();
            double longitude = regeocodeResult.getRegeocodeQuery().getPoint().getLongitude();
            mMsg = LocationMessage.obtain(latitude, longitude, shortAdd, getMapUrl(latitude, longitude));
            NLog.e("LocationChange", shortAdd + latitude + "----" + longitude);
        } else {
            NToast.shortToast(AMAPLocationActivity.this, "没有搜索到结果");
        }
    } else {
        NToast.shortToast(AMAPLocationActivity.this, "搜索失败,请检查网络");
    }
}
 
Example #3
Source File: AmapActivity.java    From sealtalk-android with MIT License 6 votes vote down vote up
@Override
    public void onRegeocodeSearched(RegeocodeResult regeocodeResult, int i) {
        if(i == 0){
            if(regeocodeResult != null&& regeocodeResult.getRegeocodeAddress() != null){
                endAnim();
                centerMarker.setIcon(successDescripter);
                RegeocodeAddress regeocodeAddress = regeocodeResult.getRegeocodeAddress();
                String formatAddress = regeocodeResult.getRegeocodeAddress().getFormatAddress();
                String shortAdd = formatAddress.replace(regeocodeAddress.getProvince(), "").replace(regeocodeAddress.getCity(), "").replace(regeocodeAddress.getDistrict(), "");
                tvCurLocation.setText(shortAdd);
            }else{
//                ToastUtil.show(AmapActivity.this, R.string.no_result);
            }
        }else{
//            ToastUtil.show(AmapActivity.this, R.string.error_network);
        }
    }
 
Example #4
Source File: MapActivity.java    From xposed-rimet with Apache License 2.0 5 votes vote down vote up
@Override
public void onRegeocodeSearched(RegeocodeResult result, int resultCode) {

    if (resultCode != AMapException.CODE_AMAP_SUCCESS) {
        Alog.e("搜索出错了");
        return;
    }

    if (result == null
            || result.getRegeocodeAddress() == null
            || result.getRegeocodeAddress().getPois() == null) {
        Alog.e("没有搜索结果!");
        ToastUtil.show("没有搜索结果!");
        return;
    }

    RegeocodeAddress regeocodeAddress = result.getRegeocodeAddress();

    // 当前位置
    PoiItem curPoiItem = new PoiItem(
            "regeo", mSearchLatLonPoint, "标记的位置", regeocodeAddress.getFormatAddress());


    List<PoiItem> tmpList = new ArrayList<>();
    tmpList.add(curPoiItem);
    tmpList.addAll(regeocodeAddress.getPois());

    ViewUtil.setVisibility(mTvPrompt, View.GONE);
    mSearchResultAdapter.setBeginAddress(regeocodeAddress.getProvince() + regeocodeAddress.getCity() + regeocodeAddress.getDistrict());
    mSearchResultAdapter.setSelectedPosition(0);
    mSearchResultAdapter.setItems(tmpList);
    mSearchResultAdapter.notifyDataSetChanged();
}