com.baidu.mapapi.search.core.SearchResult Java Examples

The following examples show how to use com.baidu.mapapi.search.core.SearchResult. 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: MainActivity.java    From BaiDuMapSelectDemo with Apache License 2.0 7 votes vote down vote up
@Override
public void onGetPoiDetailResult(PoiDetailSearchResult poiDetailSearchResult) {
    if (poiDetailSearchResult.error != SearchResult.ERRORNO.NO_ERROR) {
        Toast.makeText(mContext, "抱歉,未找到结果", Toast.LENGTH_SHORT).show();
    } else {
        List<PoiDetailInfo> poiDetailInfoList = poiDetailSearchResult.getPoiDetailInfoList();
        if (null == poiDetailInfoList || poiDetailInfoList.isEmpty()) {
            Toast.makeText(mContext, "抱歉,检索结果为空", Toast.LENGTH_SHORT).show();
            return;
        }

        for (int i = 0; i < poiDetailInfoList.size(); i++) {
            PoiDetailInfo poiDetailInfo = poiDetailInfoList.get(i);
            if (null != poiDetailInfo) {
                Toast.makeText(mContext,
                        poiDetailInfo.getName() + ": " + poiDetailInfo.getAddress(),
                        Toast.LENGTH_SHORT).show();
            }
        }
    }
}
 
Example #2
Source File: BaiduMapFragment.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onGetBusLineResult(BusLineResult result) {
    hideProgress();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        onMessage("未找到路线");
    } else {
        clearMarker();
        BusLineOverlay overlay = new BusLineOverlay(mBaiduMap, PoiInfo.POITYPE.fromInt(mTypePoi.getInt()));
        mBaiduMap.setOnMarkerClickListener(overlay);
        overlay.setData(result);
        overlay.addToMap();
        overlay.zoomToSpan();


    }
}
 
Example #3
Source File: AddressEditDelegate.java    From FastWaiMai with MIT License 6 votes vote down vote up
@Override
public void onGetPoiDetailResult(PoiDetailSearchResult poiDetailSearchResult) {
	if (poiDetailSearchResult.error != SearchResult.ERRORNO.NO_ERROR) {
		Toast.makeText(getContext(), "抱歉,未找到结果", Toast.LENGTH_SHORT).show();
	} else {
		List<PoiDetailInfo> poiDetailInfoList = poiDetailSearchResult.getPoiDetailInfoList();
		if (null == poiDetailInfoList || poiDetailInfoList.isEmpty()) {
			Toast.makeText(getContext(), "抱歉,检索结果为空", Toast.LENGTH_SHORT).show();
			return;
		}

		for (int i = 0; i < poiDetailInfoList.size(); i++) {
			PoiDetailInfo poiDetailInfo = poiDetailInfoList.get(i);
			if (null != poiDetailInfo) {
				Toast.makeText(getContext(),
						poiDetailInfo.getName() + ": " + poiDetailInfo.getAddress(),
						Toast.LENGTH_SHORT).show();
			}
		}
	}
}
 
Example #4
Source File: BaiduMapFragment.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
@Override
public void onGetBusLineResult(BusLineResult result) {
    hideProgress();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        onMessage("未找到路线");
    } else {
        clearMarker();
        BusLineOverlay overlay = new BusLineOverlay(mBaiduMap, PoiInfo.POITYPE.fromInt(mTypePoi.getInt()));
        mBaiduMap.setOnMarkerClickListener(overlay);
        overlay.setData(result);
        overlay.addToMap();
        overlay.zoomToSpan();


    }
}
 
Example #5
Source File: BaiduBusFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
@Override
public void onGetTransitRouteResult(final TransitRouteResult result) {
    hideProgress();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        mTextData.setVisibility(View.VISIBLE);
        mListBusRoute.setVisibility(View.GONE);
    } else {
        if (null != result.getRouteLines() && !result.getRouteLines().isEmpty()) {
            List<BusRouteModel> list = new ArrayList<>();
            for (int i = 0; i < result.getRouteLines().size(); i++) {
                TransitRouteLine line = result.getRouteLines().get(i);
                String msg = "";
                for (int j = 0; j < line.getAllStep().size(); j++) {
                    TransitRouteLine.TransitStep step = line.getAllStep().get(j);
                    if (step.getStepType() == TransitRouteLine.TransitStep.TransitRouteStepType.BUSLINE
                            || step.getStepType() == TransitRouteLine.TransitStep.TransitRouteStepType.SUBWAY) {
                        msg += line.getAllStep().get(j).getVehicleInfo().getTitle() + " -> ";
                    }
                }
                BusRouteModel route = new BusRouteModel();
                route.setName(msg);
                route.setDistance(line.getDistance());
                route.setDuration(line.getDuration());
                list.add(route);
            }

            setBusRouteAdapter(list);

            mTextData.setVisibility(View.GONE);
            mListBusRoute.setVisibility(View.VISIBLE);


        } else {
            mTextData.setVisibility(View.VISIBLE);
            mListBusRoute.setVisibility(View.GONE);
        }
    }

}
 
Example #6
Source File: LocationActivity.java    From Conquer with Apache License 2.0 5 votes vote down vote up
@Override
public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) {
	if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
		T.show(context, "抱歉,未能找到结果");
		return;
	}
	BmobLog.i("反编码得到的地址:" + result.getAddress());
	lastLocation.setAddrStr(result.getAddress());
}
 
Example #7
Source File: BusActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
/**
 * 以下是执行searchButtonProcess开始按钮后,返回的POI数据。
 * 
 */
@Override
public void onGetPoiResult(PoiResult result) {

	if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
		Toast.makeText(context, "抱歉,未找到结果", Toast.LENGTH_LONG).show();
		return;
	}
	// 遍历所有poi,找到类型为公交线路的poi
	busLineIDList.clear();

	/**
	 * 
	 * 一般以下for循环执行2次,因为同一条公交线路有正反2个方向;
	 */
	for (PoiInfo poi : result.getAllPoi()) {
		if (poi.type == PoiInfo.POITYPE.BUS_LINE
				|| poi.type == PoiInfo.POITYPE.SUBWAY_LINE) {
			busLineIDList.add(poi.uid);// 就把该poi信息存储到公交路线列表中;busLineIDList中存储的是公交线路的ID值;
			Log.i("TAG", "城市:" + poi.city + ";线路:" + poi.name);
			city_return = poi.city;
		}
	}
	// 即要把原来所有的数据清空;
	SearchNextBusline(null);
	route = null;
}
 
Example #8
Source File: BusActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
/**
 * 
 * 这是点击搜索按钮后,从服务器返回公交信息;在这里得到route值;
 */
@Override
public void onGetBusLineResult(BusLineResult result) {
	if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
		Toast.makeText(BusActivity.this, "抱歉,未找到结果", Toast.LENGTH_LONG)
				.show();
		return;
	}

	mBaiduMap.clear();
	route = result;
	nodeIndex = -1;
	BusLineOverlay overlay = new BusLineOverlay(mBaiduMap);
	mBaiduMap.setOnMarkerClickListener(overlay);
	overlay.setData(result);
	overlay.addToMap();
	overlay.zoomToSpan();
	mBtnPre.setVisibility(View.VISIBLE);
	mBtnNext.setVisibility(View.VISIBLE);
	Toast.makeText(context, result.getBusLineName(), Toast.LENGTH_SHORT)
			.show();
	Log.i("TAG", "总站数:" + result.getStations().size() + "");
	// 在这里最好使用对话框的形式把公交信息显示出来;

	String message = "";
	Builder builder = new Builder(context);
	builder.setTitle("为您查询到的地铁信息:");
	for (int i = 0; i < result.getStations().size(); i++) {

		message = message + "地铁" + (i + 1) + ":"
				+ result.getStations().get(i).getTitle() + "\n";

	}
	builder.setMessage(city_return + result.getBusLineName() + "共有"
			+ result.getStations().size() + "个地铁站:" + "\n" + message);
	builder.setPositiveButton("确定", null);
	AlertDialog alertDialog = builder.create();
	alertDialog.show();

}
 
Example #9
Source File: GeolocationModule.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) {
    WritableMap params = Arguments.createMap();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        params.putInt("errcode", -1);
    }
    else {
        ReverseGeoCodeResult.AddressComponent addressComponent = result.getAddressDetail();
        params.putString("address", result.getAddress());
        params.putString("province", addressComponent.province);
        params.putString("city", addressComponent.city);
        params.putString("district", addressComponent.district);
        params.putString("street", addressComponent.street);
        params.putString("streetNumber", addressComponent.streetNumber);

        WritableArray list = Arguments.createArray();
        List<PoiInfo> poiList = result.getPoiList();
        for (PoiInfo info: poiList) {
            WritableMap attr = Arguments.createMap();
            attr.putString("name", info.name);
            attr.putString("address", info.address);
            attr.putString("city", info.city);
            attr.putDouble("latitude", info.location.latitude);
            attr.putDouble("longitude", info.location.longitude);
            list.pushMap(attr);
        }
        params.putArray("poiList", list);
    }
    sendEvent("onGetReverseGeoCodeResult", params);
}
 
Example #10
Source File: GeolocationModule.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
@Override
public void onGetGeoCodeResult(GeoCodeResult result) {
    WritableMap params = Arguments.createMap();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        params.putInt("errcode", -1);
        params.putString("errmsg", result.error.name());
    }
    else {
        params.putDouble("latitude",  result.getLocation().latitude);
        params.putDouble("longitude",  result.getLocation().longitude);
    }
    sendEvent("onGetGeoCodeResult", params);
}
 
Example #11
Source File: GeoCoderListener.java    From VirtualLocation with Apache License 2.0 5 votes vote down vote up
/**
 * 搜索(根据坐标-->实地信息)
 * @param result
 */
@Override
public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) {
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        Toast.makeText(mContext, "抱歉,未能找到结果", Toast.LENGTH_LONG).show();
        return;
    }
    mLocationTip.setText(String.format("伪造位置:%s", result.getAddress()));
}
 
Example #12
Source File: MapPickerActivity.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void onGetReverseGeoCodeResult(ReverseGeoCodeResult result) {
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        // 没有找到检索结果
        status.setText(R.string.picker_internalerror);
        status.setVisibility(View.VISIBLE);
    }
    // 获取反向地理编码结果
    else {
        status.setVisibility(View.GONE);
        // 当前位置信息
        mLoactionLatLng = result.getLocation();
        mAddress = result.getAddress();
        mName = result.getAddressDetail().street;
        mStreet = result.getAddressDetail().street;
        mCity = result.getAddressDetail().city;

        //滑动地图.中间位置坐标记录下来发送.相当于默认点击了一下listView中的第一条
        mLatitude = result.getLocation().latitude;
        mLongitude = result.getLocation().longitude;

        mCurentInfo = new PoiInfo();
        mCurentInfo.address = result.getAddress();
        mCurentInfo.location = result.getLocation();
        mCurentInfo.name = "[当前位置]";
        mInfoList.clear();
        mInfoList.add(mCurentInfo);
        // 将周边信息加入表
        if (result.getPoiList() != null) {
            mInfoList.addAll(result.getPoiList());
        }
        mAdapter.setNotifyTip(0);
        // 通知适配数据已改变
        mAdapter.notifyDataSetChanged();
        loading.setVisibility(View.GONE);

    }
}
 
Example #13
Source File: NaviConfirmPointActivity.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * poi搜索结果回调
 **/
@Override
public void onGetPoiResult(PoiResult result) {
    mAncpPoiListBox.setRefreshing(false);
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        //Toast.makeText(this, "搜索发生错误:" + result.error, Toast.LENGTH_LONG).show();
        Snackbar.make(mAncpPoiDetailBox, NaviConfirmPointActivity.this.getResources().getString(R.string.navi_no_result), Snackbar.LENGTH_SHORT).show();

        return;
    }
    if (result.error == SearchResult.ERRORNO.NO_ERROR) {
        //创建PoiOverlay,添加搜索结果地点图层
        if (poiOverlay == null) {
            poiOverlay = new ConfirmPoiOverlay(baiduMap);
            baiduMap.setOnMarkerClickListener(poiOverlay);
        } else {
            poiOverlay.removeFromMap();
        }
        if (poiOverlay instanceof PoiOverlay) {
            ((PoiOverlay) poiOverlay).setData(result);
        }
        poiOverlay.addToMap();

        totalPageNum = result.getTotalPageNum();
        mAncpPoiBox.getLayoutParams().height = ScreenUtil.getInstance().getHeightPixels() / 2;
        list.clear();
        /* 填充数据 */
        list.addAll(result.getAllPoi());
        setAlist(list);
        /* 刷新视图 */
        mListAdapter.notifyDataSetChanged();
        mPagerAdapter.notifyDataSetChanged();
        if (firstPoiSearch) {
            firstPoiSearch = false;
            mAncpPoiBox.setVisibility(View.VISIBLE);
        }
        setPoiPosition();
    }
}
 
Example #14
Source File: SetFavoriteMapActivity.java    From AssistantBySDK with Apache License 2.0 5 votes vote down vote up
/**
 * Poi检索结果回调
 **/
@Override
public void onGetPoiResult(PoiResult result) {
    mAmosfPoiListBox.setRefreshing(false);
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        // Toast.makeText(this, "搜索发生错误:" + result.error, Toast.LENGTH_LONG).show();
        Snackbar.make(mAmosfPoiList, SetFavoriteMapActivity.this.getResources().getString(R.string.navi_no_result), Snackbar.LENGTH_SHORT).show();
        mAmosfSearchEdit.setSearchCompletedState();
        return;
    }
    if (result.error == SearchResult.ERRORNO.NO_ERROR) {
        if (poiOverlay != null) {
            poiOverlay.removeFromMap();
        }
        if (poiOverlay == null || !(poiOverlay instanceof ConfirmPoiOverlay)) {
            poiOverlay = new ConfirmPoiOverlay(baiduMap);
            baiduMap.setOnMarkerClickListener(poiOverlay);
        }

        ((ConfirmPoiOverlay) poiOverlay).setData(result);
        poiOverlay.addToMap();

        totalPageNum = result.getTotalPageNum();
        /* 设置检索结果列表高度(手机屏幕的一半) */
        mAmosfPoiBox.getLayoutParams().height = ScreenUtil.getInstance().getHeightPixels() / 2;
        list.clear();
        list.addAll(result.getAllPoi());
        setAlist(list);
        mListAdapter.notifyDataSetChanged();
        mPagerAdapter.notifyDataSetChanged();
        mAmosfPoiDetailBox.setVisibility(View.GONE);
        mAmosfSinglePoiDetailBox.setVisibility(View.GONE);
        mAmosfPoiBox.setVisibility(View.VISIBLE);
        setPoiPosition();
        return;
    }
}
 
Example #15
Source File: BaiduBusFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onGetTransitRouteResult(final TransitRouteResult result) {
    hideProgress();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        mTextData.setVisibility(View.VISIBLE);
        mListBusRoute.setVisibility(View.GONE);
    } else {
        if (null != result.getRouteLines() && !result.getRouteLines().isEmpty()) {
            List<BusRouteModel> list = new ArrayList<>();
            for (int i = 0; i < result.getRouteLines().size(); i++) {
                TransitRouteLine line = result.getRouteLines().get(i);
                String msg = "";
                for (int j = 0; j < line.getAllStep().size(); j++) {
                    TransitRouteLine.TransitStep step = line.getAllStep().get(j);
                    if (step.getStepType() == TransitRouteLine.TransitStep.TransitRouteStepType.BUSLINE
                            || step.getStepType() == TransitRouteLine.TransitStep.TransitRouteStepType.SUBWAY) {
                        msg += line.getAllStep().get(j).getVehicleInfo().getTitle() + " -> ";
                    }
                }
                BusRouteModel route = new BusRouteModel();
                route.setName(msg);
                route.setDistance(line.getDistance());
                route.setDuration(line.getDuration());
                list.add(route);
            }

            setBusRouteAdapter(list);

            mTextData.setVisibility(View.GONE);
            mListBusRoute.setVisibility(View.VISIBLE);


        } else {
            mTextData.setVisibility(View.VISIBLE);
            mListBusRoute.setVisibility(View.GONE);
        }
    }

}
 
Example #16
Source File: MainActivity.java    From BaiDuMapSelectDemo with Apache License 2.0 5 votes vote down vote up
/**
 * 获取POI详情搜索结果,得到searchPoiDetail返回的搜索结果
 * V5.2.0版本之后,该方法废弃,使用{@link #onGetPoiDetailResult(PoiDetailSearchResult)}代替
 *
 * @param poiDetailResult POI详情检索结果
 */
@Override
public void onGetPoiDetailResult(PoiDetailResult poiDetailResult) {
    if (poiDetailResult.error != SearchResult.ERRORNO.NO_ERROR) {
        Toast.makeText(mContext, "抱歉,未找到结果", Toast.LENGTH_SHORT).show();
    } else {
        Toast.makeText(mContext,
                poiDetailResult.getName() + ": " + poiDetailResult.getAddress(),
                Toast.LENGTH_SHORT).show();
    }
}
 
Example #17
Source File: MainActivity.java    From BaiDuMapSelectDemo with Apache License 2.0 5 votes vote down vote up
/**
 * 获取POI搜索结果,包括searchInCity,searchNearby,searchInBound返回的搜索结果
 *
 * @param poiResult Poi检索结果,包括城市检索,周边检索,区域检索
 */
@Override
public void onGetPoiResult(PoiResult poiResult) {
    if (poiInfoListForSearch != null) {
        poiInfoListForSearch.clear();
    }
    if (poiResult == null || poiResult.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
        Toast.makeText(mContext, "未找到结果", Toast.LENGTH_LONG).show();
        initPoiSearchListView();
        return;
    }

    if (poiResult.error == SearchResult.ERRORNO.NO_ERROR) {
        poiInfoListForSearch = poiResult.getAllPoi();
        showSeachView();
        initPoiSearchListView();
        return;
    }

    if (poiResult.error == SearchResult.ERRORNO.AMBIGUOUS_KEYWORD) {
        // 当输入关键字在本市没有找到,但在其他城市找到时,返回包含该关键字信息的城市列表
        String strInfo = "在";

        for (CityInfo cityInfo : poiResult.getSuggestCityList()) {
            strInfo += cityInfo.city;
            strInfo += ",";
        }

        strInfo += "找到结果";
        Toast.makeText(mContext, strInfo, Toast.LENGTH_LONG).show();
    }
}
 
Example #18
Source File: MainActivity.java    From BaiDuMapSelectDemo with Apache License 2.0 5 votes vote down vote up
/**
 * 反向地理解析,结果中含有poi信息,用于刚进入地图和移动地图时使用
 */
private void initGeoCoder() {
    mGeoCoder = GeoCoder.newInstance();
    mGeoCoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() {
        @Override
        public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) {

        }

        @Override
        public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) {
            if (poiInfoListForGeoCoder != null) {
                poiInfoListForGeoCoder.clear();
            }
            if (reverseGeoCodeResult.error.equals(SearchResult.ERRORNO.NO_ERROR)) {
                //获取城市
                ReverseGeoCodeResult.AddressComponent addressComponent = reverseGeoCodeResult.getAddressDetail();
                cityName = addressComponent.city;
                tv_city.setText(cityName);
                //获取poi列表
                if (reverseGeoCodeResult.getPoiList() != null) {
                    poiInfoListForGeoCoder = reverseGeoCodeResult.getPoiList();
                }
            } else {
                Toast.makeText(mContext, "该位置范围内无信息", Toast.LENGTH_SHORT);
            }
            initGeoCoderListView();
        }
    });
}
 
Example #19
Source File: LocationDelegate.java    From FastWaiMai with MIT License 5 votes vote down vote up
@Override
public void onGetPoiResult(PoiResult poiResult) {
	if (poiInfoListForSearch != null) {
		poiInfoListForSearch.clear();
	}
	if (poiResult == null || poiResult.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
		Toast.makeText(getContext(), "未找到结果", Toast.LENGTH_LONG).show();
		//initPoiSearchListView();
		return;
	}

	if (poiResult.error == SearchResult.ERRORNO.NO_ERROR) {
		poiInfoListForSearch = poiResult.getAllPoi();
		//showSeachView();
		initPoiSearchListView();
		return;
	}

	if (poiResult.error == SearchResult.ERRORNO.AMBIGUOUS_KEYWORD) {
		// 当输入关键字在本市没有找到,但在其他城市找到时,返回包含该关键字信息的城市列表
		String strInfo = "在";

		for (CityInfo cityInfo : poiResult.getSuggestCityList()) {
			strInfo += cityInfo.city;
			strInfo += ",";
		}

		strInfo += "找到结果";
		Toast.makeText(getContext(), strInfo, Toast.LENGTH_LONG).show();
	}
}
 
Example #20
Source File: LocationDelegate.java    From FastWaiMai with MIT License 5 votes vote down vote up
private void initGeoCoder() {
	mGeoCoder = GeoCoder.newInstance();
	mGeoCoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() {
		//地理编码检索监听器
		@Override
		public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) {

		}

		//逆地理编码检索监听器
		@Override
		public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) {
			if (poiInfoListForGeoCoder != null) {
				poiInfoListForGeoCoder.clear();
			}
			if (reverseGeoCodeResult.error.equals(SearchResult.ERRORNO.NO_ERROR)) {
				//获取城市
				ReverseGeoCodeResult.AddressComponent addressComponent = reverseGeoCodeResult.getAddressDetail();
				cityName = addressComponent.city;
				//获取poi列表
				if (reverseGeoCodeResult.getPoiList() != null) {
					poiInfoListForGeoCoder = reverseGeoCodeResult.getPoiList();
				}
			}
			initGeoCoderListView();
		}
	});
}
 
Example #21
Source File: AddressEditDelegate.java    From FastWaiMai with MIT License 5 votes vote down vote up
/**
 * 获取POI详情搜索结果,得到searchPoiDetail返回的搜索结果
 * V5.2.0版本之后,该方法废弃,使用{@link #onGetPoiDetailResult(PoiDetailSearchResult)}代替
 *
 * @param poiDetailResult POI详情检索结果
 */
@Override
public void onGetPoiDetailResult(PoiDetailResult poiDetailResult) {
	if (poiDetailResult.error != SearchResult.ERRORNO.NO_ERROR) {
		Toast.makeText(getContext(), "抱歉,未找到结果", Toast.LENGTH_SHORT).show();
	} else {
		Toast.makeText(getContext(),
				poiDetailResult.getName() + ": " + poiDetailResult.getAddress(),
				Toast.LENGTH_SHORT).show();
	}
}
 
Example #22
Source File: AddressEditDelegate.java    From FastWaiMai with MIT License 5 votes vote down vote up
/**
 * 获取POI搜索结果,包括searchInCity,searchNearby,searchInBound返回的搜索结果
 *
 * @param poiResult Poi检索结果,包括城市检索,周边检索,区域检索
 */
@Override
public void onGetPoiResult(PoiResult poiResult) {
	if (poiInfoListForSearch != null) {
		poiInfoListForSearch.clear();
	}
	if (poiResult == null || poiResult.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
		Toast.makeText(getContext(), "未找到结果", Toast.LENGTH_LONG).show();
		initPoiSearchListView();
		return;
	}

	if (poiResult.error == SearchResult.ERRORNO.NO_ERROR) {
		poiInfoListForSearch = poiResult.getAllPoi();
		showSeachView();
		initPoiSearchListView();
		return;
	}

	if (poiResult.error == SearchResult.ERRORNO.AMBIGUOUS_KEYWORD) {
		// 当输入关键字在本市没有找到,但在其他城市找到时,返回包含该关键字信息的城市列表
		String strInfo = "在";

		for (CityInfo cityInfo : poiResult.getSuggestCityList()) {
			strInfo += cityInfo.city;
			strInfo += ",";
		}

		strInfo += "找到结果";
		Toast.makeText(getContext(), strInfo, Toast.LENGTH_LONG).show();
	}
}
 
Example #23
Source File: AddressEditDelegate.java    From FastWaiMai with MIT License 5 votes vote down vote up
private void initGeoCoder() {
	mGeoCoder = GeoCoder.newInstance();
	mGeoCoder.setOnGetGeoCodeResultListener(new OnGetGeoCoderResultListener() {
		@Override
		public void onGetGeoCodeResult(GeoCodeResult geoCodeResult) {

		}

		@Override
		public void onGetReverseGeoCodeResult(ReverseGeoCodeResult reverseGeoCodeResult) {
			if (poiInfoListForGeoCoder != null) {
				poiInfoListForGeoCoder.clear();
			}
			if (reverseGeoCodeResult.error.equals(SearchResult.ERRORNO.NO_ERROR)) {
				//获取城市
				ReverseGeoCodeResult.AddressComponent addressComponent = reverseGeoCodeResult.getAddressDetail();
				cityName = addressComponent.city;
				mTvCurrrentCity.setText(cityName);
				//获取poi列表
				if (reverseGeoCodeResult.getPoiList() != null) {
					poiInfoListForGeoCoder = reverseGeoCodeResult.getPoiList();
				}
			} else {
				Toast.makeText(getContext(), "该位置范围内无信息", Toast.LENGTH_SHORT).show();
			}
			initGeoCoderListView();
		}
	});
}
 
Example #24
Source File: BaiduMapRouteFragment.java    From BmapLite with Apache License 2.0 4 votes vote down vote up
@Override
public void onGetWalkingRouteResult(WalkingRouteResult result) {
    hideProgress();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        onMessage("未找到路线");
    } else {
        if (null != result.getRouteLines() && !result.getRouteLines().isEmpty()) {
            setWalkingOverlay(result.getRouteLines().get(0));

            WalkingRouteLine line = result.getRouteLines().get(0);
            String info = "";
            String durationString = "";
            List<String> details = new ArrayList<>();
            for (int i = 0; i < line.getAllStep().size(); i++) {
                details.add(line.getAllStep().get(i).getInstructions());
            }

            int duration = line.getDuration() / 60;
            int distance = line.getDistance();
            if (1000 > distance) {
                info = distance + "米";
            } else {
                info = String.format("%.1f", (double) distance / 1000) + "公里";
            }

            if (duration > 60) {
                durationString = duration / 60 + "小时" + duration % 60 + "分钟";
            } else {
                durationString = duration + "分钟";
            }

            mTextInfo.setText(info);
            mTextDuration.setText(durationString);
            setRouteDetailsAdapter(details);

            mLayPlanAll.setVisibility(View.GONE);
            mLayPlan0.setVisibility(View.VISIBLE);
        } else {
            onMessage("未找到路线");
        }
    }

}
 
Example #25
Source File: BaiduMapRouteFragment.java    From BmapLite with Apache License 2.0 4 votes vote down vote up
@Override
public void onGetBikingRouteResult(BikingRouteResult result) {
    hideProgress();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        onMessage("未找到路线");
    } else {
        if (null != result.getRouteLines() && !result.getRouteLines().isEmpty()) {
            setBikeOverlay(result.getRouteLines().get(0));
            BikingRouteLine line = result.getRouteLines().get(0);
            String info = "";
            List<String> details = new ArrayList<>();
            String durationString = "";

            for (int i = 0; i < line.getAllStep().size(); i++) {
                details.add(line.getAllStep().get(i).getInstructions());
            }

            int duration = line.getDuration() / 60;
            int distance = line.getDistance();
            if (1000 > distance) {
                info = distance + "米";
            } else {
                info = String.format("%.1f", (double) distance / 1000) + "公里";
            }

            if (duration > 60) {
                durationString = duration / 60 + "小时" + duration % 60 + "分钟";
            } else {
                durationString = duration + "分钟";
            }

            setRouteDetailsAdapter(details);
            mTextInfo.setText(info);
            mTextDuration.setText(durationString);
            mLayPlanAll.setVisibility(View.GONE);
            mLayPlan0.setVisibility(View.VISIBLE);
        } else {
            onMessage("未找到路线");
        }
    }
}
 
Example #26
Source File: TrafficShowPresenter.java    From AssistantBySDK with Apache License 2.0 4 votes vote down vote up
@Override
public void onGetPoiResult(PoiResult result) {
    Log.e(TAG, "onGetPoiResult>>" + result.error);
    mTrafficShowView.setRefreshLayout(false);
    if (result == null || result.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
        //Toast.makeText(mContext, "搜索发生错误:" + result.error, Toast.LENGTH_LONG).show();
        mTrafficShowView.showSnackBar(mContext.getResources().getString(R.string.navi_no_result));
        mTrafficShowView.getedit().setSearchCompletedState();
        return;
    }
    if (result.error == SearchResult.ERRORNO.NO_ERROR) {
        //baiduMap.clear();
        if (poiOverlay != null) {
            /* 在地图上清楚覆盖物 */
            poiOverlay.removeFromMap();
        }
        if (poiOverlay == null || !(poiOverlay instanceof ConfirmPoiOverlay)) {
            poiOverlay = new ConfirmPoiOverlay(baiduMap);
            /* 设置覆盖物被点击事件 */
            baiduMap.setOnMarkerClickListener(poiOverlay);
        }

        ((ConfirmPoiOverlay) poiOverlay).setData(result);
        /* 将覆盖物添加到地图中 */
        poiOverlay.addToMap();
        setPoiPosition();

        totalPageNum = result.getTotalPageNum();
        mTrafficShowView.getPoiListBox().getLayoutParams().height = ScreenUtil.getInstance().getHeightPixels() / 2;
        poiInfoList.clear();
        poiInfoList.addAll(result.getAllPoi());
        setAlist();
        mListAdapter.notifyDataSetChanged();
        pagerAdapter.notifyDataSetChanged();
        mTrafficShowView.getPoiDetialBox().setVisibility(View.GONE);
        mTrafficShowView.getPoiListBox().setVisibility(View.VISIBLE);
        /*MapStatus.Builder builder=new MapStatus.Builder();
        builder.target(list.get(0).location)
                .targetScreen(new Point(ScreenUtil.getInstance().getWidthPixels()/2,ScreenUtil.getInstance().getHeightPixels()/4))
                .zoom(15F);
        baiduMap.setMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));*/
        return;
    }

}
 
Example #27
Source File: MapPickerActivity.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
public void onGetGeoCodeResult(GeoCodeResult result) {
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        // 没有检索到结果
    }
    // 获取地理编码结果
}
 
Example #28
Source File: BaiduMapRouteFragment.java    From BmapLite with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onGetBikingRouteResult(BikingRouteResult result) {
    hideProgress();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        onMessage("未找到路线");
    } else {
        if (null != result.getRouteLines() && !result.getRouteLines().isEmpty()) {
            setBikeOverlay(result.getRouteLines().get(0));
            BikingRouteLine line = result.getRouteLines().get(0);
            String info = "";
            List<String> details = new ArrayList<>();
            String durationString = "";

            for (int i = 0; i < line.getAllStep().size(); i++) {
                details.add(line.getAllStep().get(i).getInstructions());
            }

            int duration = line.getDuration() / 60;
            int distance = line.getDistance();
            if (1000 > distance) {
                info = distance + "米";
            } else {
                info = String.format("%.1f", (double) distance / 1000) + "公里";
            }

            if (duration > 60) {
                durationString = duration / 60 + "小时" + duration % 60 + "分钟";
            } else {
                durationString = duration + "分钟";
            }

            setRouteDetailsAdapter(details);
            mTextInfo.setText(info);
            mTextDuration.setText(durationString);
            mLayPlanAll.setVisibility(View.GONE);
            mLayPlan0.setVisibility(View.VISIBLE);
        } else {
            onMessage("未找到路线");
        }
    }
}
 
Example #29
Source File: BaiduMapRouteFragment.java    From BmapLite with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onGetWalkingRouteResult(WalkingRouteResult result) {
    hideProgress();
    if (result == null || result.error != SearchResult.ERRORNO.NO_ERROR) {
        onMessage("未找到路线");
    } else {
        if (null != result.getRouteLines() && !result.getRouteLines().isEmpty()) {
            setWalkingOverlay(result.getRouteLines().get(0));

            WalkingRouteLine line = result.getRouteLines().get(0);
            String info = "";
            String durationString = "";
            List<String> details = new ArrayList<>();
            for (int i = 0; i < line.getAllStep().size(); i++) {
                details.add(line.getAllStep().get(i).getInstructions());
            }

            int duration = line.getDuration() / 60;
            int distance = line.getDistance();
            if (1000 > distance) {
                info = distance + "米";
            } else {
                info = String.format("%.1f", (double) distance / 1000) + "公里";
            }

            if (duration > 60) {
                durationString = duration / 60 + "小时" + duration % 60 + "分钟";
            } else {
                durationString = duration + "分钟";
            }

            mTextInfo.setText(info);
            mTextDuration.setText(durationString);
            setRouteDetailsAdapter(details);

            mLayPlanAll.setVisibility(View.GONE);
            mLayPlan0.setVisibility(View.VISIBLE);
        } else {
            onMessage("未找到路线");
        }
    }

}