Java Code Examples for com.amap.api.services.core.AMapException#CODE_AMAP_SUCCESS
The following examples show how to use
com.amap.api.services.core.AMapException#CODE_AMAP_SUCCESS .
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: RouteActivity.java From TraceByAmap with MIT License | 6 votes |
/** * 公交路线搜索结果方法回调 */ @Override public void onBusRouteSearched(BusRouteResult result, int errorCode) { dissmissProgressDialog(); mBottomLayout.setVisibility(View.GONE); aMap.clear();// 清理地图上的所有覆盖物 if (errorCode == AMapException.CODE_AMAP_SUCCESS) { if (result != null && result.getPaths() != null) { if (result.getPaths().size() > 0) { mBusRouteResult = result; BusResultListAdapter mBusResultListAdapter = new BusResultListAdapter(mContext, mBusRouteResult); mBusResultList.setAdapter(mBusResultListAdapter); } else if (result != null && result.getPaths() == null) { ToastUtil.show(mContext, R.string.no_result); } } else { ToastUtil.show(mContext, R.string.no_result); } } else { ToastUtil.showerror(this.getApplicationContext(), errorCode); } }
Example 2
Source File: GeocoderActivity.java From TraceByAmap with MIT License | 6 votes |
/** * 地理编码查询回调 */ @Override public void onGeocodeSearched(GeocodeResult result, int rCode) { dismissDialog(); if (rCode == AMapException.CODE_AMAP_SUCCESS) { if (result != null && result.getGeocodeAddressList() != null && result.getGeocodeAddressList().size() > 0) { GeocodeAddress address = result.getGeocodeAddressList().get(0); if(address != null) { aMap.animateCamera(CameraUpdateFactory.newLatLngZoom( AMapUtil.convertToLatLng(address.getLatLonPoint()), 15)); geoMarker.setPosition(AMapUtil.convertToLatLng(address .getLatLonPoint())); addressName = "经纬度值:" + address.getLatLonPoint() + "\n位置描述:" + address.getFormatAddress(); ToastUtil.show(GeocoderActivity.this, addressName); } } else { ToastUtil.show(GeocoderActivity.this, R.string.no_result); } } else { ToastUtil.showerror(this, rCode); } }
Example 3
Source File: WeatherSearchActivity.java From TraceByAmap with MIT License | 6 votes |
/** * 实时天气查询回调 */ @Override public void onWeatherLiveSearched(LocalWeatherLiveResult weatherLiveResult, int rCode) { if (rCode == AMapException.CODE_AMAP_SUCCESS) { if (weatherLiveResult != null && weatherLiveResult.getLiveResult() != null) { weatherlive = weatherLiveResult.getLiveResult(); reporttime1.setText(weatherlive.getReportTime() + "发布"); weather.setText(weatherlive.getWeather()); Temperature.setText(weatherlive.getTemperature() + "°"); wind.setText(weatherlive.getWindDirection() + "风 " + weatherlive.getWindPower() + "级"); humidity.setText("湿度 " + weatherlive.getHumidity() + "%"); } else { ToastUtil.show(WeatherSearchActivity.this, R.string.no_result); } } else { ToastUtil.showerror(WeatherSearchActivity.this, rCode); } }
Example 4
Source File: ShareActivity.java From TraceByAmap with MIT License | 5 votes |
@Override public void onDrivingRouteShareUrlSearched(String url, int errorCode) { // TODO Auto-generated method stub dissmissProgressDialog(); if (errorCode == AMapException.CODE_AMAP_SUCCESS) { mUrlView.loadUrl(url); } else { ToastUtil.showerror(this.getApplicationContext(), errorCode); } }
Example 5
Source File: InputtipsActivity.java From TraceByAmap with MIT License | 5 votes |
/** * 输入提示结果的回调 * @param tipList * @param rCode */ @Override public void onGetInputtips(final List<Tip> tipList, int rCode) { if (rCode == AMapException.CODE_AMAP_SUCCESS) { List<HashMap<String, String>> listString = new ArrayList<HashMap<String, String>>(); if(tipList != null) { int size = tipList.size(); for (int i = 0; i < size; i++) { Tip tip = tipList.get(i); if(tip != null) { HashMap<String, String> map = new HashMap<String, String>(); map.put("name", tipList.get(i).getName()); map.put("address", tipList.get(i).getDistrict()); listString.add(map); } } SimpleAdapter aAdapter = new SimpleAdapter(getApplicationContext(), listString, R.layout.item_layout, new String[]{"name", "address"}, new int[]{R.id.poi_field_id, R.id.poi_value_id}); minputlist.setAdapter(aAdapter); aAdapter.notifyDataSetChanged(); } } else { ToastUtil.showerror(this.getApplicationContext(), rCode); } }
Example 6
Source File: ShareActivity.java From TraceByAmap with MIT License | 5 votes |
@Override public void onWalkRouteShareUrlSearched(String url, int errorCode) { // TODO Auto-generated method stub dissmissProgressDialog(); if (errorCode == AMapException.CODE_AMAP_SUCCESS) { mUrlView.loadUrl(url); } else { ToastUtil.showerror(this.getApplicationContext(), errorCode); } }
Example 7
Source File: AmapRouteFragment.java From BmapLite with GNU General Public License v3.0 | 5 votes |
@Override public void onWalkRouteSearched(WalkRouteResult result, int code) { mAmap.clear();// 清理地图上的所有覆盖物 if (code == AMapException.CODE_AMAP_SUCCESS) { if (result != null && result.getPaths() != null) { if (result.getPaths().size() > 0) { final WalkPath walkPath = result.getPaths() .get(0); WalkRouteOverlay overlay = new WalkRouteOverlay(getActivity(), mAmap, walkPath, result.getStartPos(), result.getTargetPos()); overlay.setNodeIconVisibility(false);//设置节点marker是否显示 overlay.removeFromMap(); overlay.addToMap(); overlay.zoomToSpan(); setLineInfo((int) walkPath.getDistance(), (int) walkPath.getDuration() / 60); List<String> details = new ArrayList<>(); if (null != walkPath.getSteps() && !walkPath.getSteps().isEmpty()) { for (WalkStep step : walkPath.getSteps()) { details.add(step.getInstruction()); } } setRouteDetailsAdapter(details); } } } }
Example 8
Source File: PoiIDSearchActivity.java From TraceByAmap with MIT License | 5 votes |
@Override public void onPoiItemSearched(PoiItem item, int rCode) { if (rCode == AMapException.CODE_AMAP_SUCCESS) { if (item != null) { mPoi = item; detailMarker.setPosition(AMapUtil.convertToLatLng(mPoi.getLatLonPoint())); setPoiItemDisplayContent(mPoi); whetherToShowDetailInfo(true); } } else { ToastUtil.showerror(this, rCode); } }
Example 9
Source File: AmapBusFragment.java From BmapLite with Apache License 2.0 | 5 votes |
@Override public void onBusRouteSearched(BusRouteResult result, int errorCode) { if (errorCode == AMapException.CODE_AMAP_SUCCESS) { if (result != null && result.getPaths() != null) { if (result.getPaths().size() > 0) { BusPath bus = new BusPath(); bus.setCost(0); bus.setBusDistance(0); bus.setNightBus(false); bus.setWalkDistance(0); bus.setSteps(null); List<BusPath> list = new ArrayList<>(); list.addAll(result.getPaths()); setBusRouteAdapter(list, result); } else { mTextData.setVisibility(View.VISIBLE); mListBusRoute.setVisibility(View.GONE); } } else { mTextData.setVisibility(View.VISIBLE); mListBusRoute.setVisibility(View.GONE); } } else { mTextData.setVisibility(View.VISIBLE); mListBusRoute.setVisibility(View.GONE); } }
Example 10
Source File: PoiKeywordSearchActivity.java From TraceByAmap with MIT License | 5 votes |
/** * POI信息查询回调方法 */ @Override public void onPoiSearched(PoiResult result, int rCode) { dissmissProgressDialog();// 隐藏对话框 if (rCode == AMapException.CODE_AMAP_SUCCESS) { if (result != null && result.getQuery() != null) {// 搜索poi的结果 if (result.getQuery().equals(query)) {// 是否是同一条 poiResult = result; // 取得搜索到的poiitems有多少页 List<PoiItem> poiItems = poiResult.getPois();// 取得第一页的poiitem数据,页数从数字0开始 List<SuggestionCity> suggestionCities = poiResult .getSearchSuggestionCitys();// 当搜索不到poiitem数据时,会返回含有搜索关键字的城市信息 if (poiItems != null && poiItems.size() > 0) { aMap.clear();// 清理之前的图标 PoiOverlay poiOverlay = new PoiOverlay(aMap, poiItems); poiOverlay.removeFromMap(); poiOverlay.addToMap(); poiOverlay.zoomToSpan(); } else if (suggestionCities != null && suggestionCities.size() > 0) { showSuggestCity(suggestionCities); } else { ToastUtil.show(PoiKeywordSearchActivity.this, R.string.no_result); } } } else { ToastUtil.show(PoiKeywordSearchActivity.this, R.string.no_result); } } else { ToastUtil.showerror(this, rCode); } }
Example 11
Source File: SubPoiSearchActivity.java From TraceByAmap with MIT License | 5 votes |
@Override public void onPoiSearched(PoiResult result, int rCode) { if (rCode == AMapException.CODE_AMAP_SUCCESS) { if (result != null ) { List<PoiItem> poiItems = result.getPois(); mpoiadapter=new PoiListAdapter(this, poiItems); mPoiSearchList.setAdapter(mpoiadapter); } } else { ToastUtil.showerror(this, rCode); } }
Example 12
Source File: SubPoiSearchActivity.java From TraceByAmap with MIT License | 5 votes |
@Override public void onPoiItemSearched(PoiItem item, int rCode) { if (rCode == AMapException.CODE_AMAP_SUCCESS) { List<PoiItem> poiItems = new ArrayList<PoiItem>(); poiItems.add(item); mpoiadapter=new PoiListAdapter(this, poiItems); mPoiSearchList.setAdapter(mpoiadapter); } else { ToastUtil.showerror(this, rCode); } }
Example 13
Source File: MapActivity.java From xposed-rimet with Apache License 2.0 | 5 votes |
@Override public void onPoiSearched(PoiResult poiResult, int resultCode) { if (resultCode != AMapException.CODE_AMAP_SUCCESS) { Alog.e("搜索出错了"); return; } if (poiResult == null || poiResult.getQuery() == null) { Alog.e("没有搜索到结果"); ToastUtil.show("没有搜索结果!"); return; } // 获取搜索的结果 List<PoiItem> poiItems = poiResult.getPois(); ViewUtil.setVisibility(mTvPrompt, CollectionUtil.isEmpty(poiItems) ? View.VISIBLE : View.GONE); mSearchResultAdapter.setSelectedPosition(0); mSearchResultAdapter.setItems(poiItems); mSearchResultAdapter.setBeginAddress(null); mSearchResultAdapter.notifyDataSetChanged(); if (CollectionUtil.isNotEmpty(poiItems)) { // 移动到第一个位置 PoiItem poiItem = mSearchResultAdapter.getItem(0); LatLng latLng = MapUtil.newLatLng(poiItem.getLatLonPoint()); isItemClickAction = true; mAMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16f)); } }
Example 14
Source File: RouteActivity.java From TraceByAmap with MIT License | 4 votes |
/** * 驾车路线搜索结果方法回调 */ @Override public void onDriveRouteSearched(DriveRouteResult result, int errorCode) { dissmissProgressDialog(); aMap.clear();// 清理地图上的所有覆盖物 if (errorCode == AMapException.CODE_AMAP_SUCCESS) { if (result != null && result.getPaths() != null) { if (result.getPaths().size() > 0) { mDriveRouteResult = result; final DrivePath drivePath = mDriveRouteResult.getPaths() .get(0); if(drivePath == null) { return; } DrivingRouteOverlay drivingRouteOverlay = new DrivingRouteOverlay( mContext, aMap, drivePath, mDriveRouteResult.getStartPos(), mDriveRouteResult.getTargetPos(), null); drivingRouteOverlay.setNodeIconVisibility(false);//设置节点marker是否显示 drivingRouteOverlay.setIsColorfulline(true);//是否用颜色展示交通拥堵情况,默认true drivingRouteOverlay.removeFromMap(); drivingRouteOverlay.addToMap(); drivingRouteOverlay.zoomToSpan(); mBottomLayout.setVisibility(View.VISIBLE); int dis = (int) drivePath.getDistance(); int dur = (int) drivePath.getDuration(); String des = AMapUtil.getFriendlyTime(dur)+"("+AMapUtil.getFriendlyLength(dis)+")"; mRotueTimeDes.setText(des); mRouteDetailDes.setVisibility(View.VISIBLE); int taxiCost = (int) mDriveRouteResult.getTaxiCost(); mRouteDetailDes.setText("打车约"+taxiCost+"元"); mBottomLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(mContext, DriveRouteDetailActivity.class); intent.putExtra("drive_path", drivePath); intent.putExtra("drive_result", mDriveRouteResult); startActivity(intent); } }); } else if (result != null && result.getPaths() == null) { ToastUtil.show(mContext, R.string.no_result); } } else { ToastUtil.show(mContext, R.string.no_result); } } else { ToastUtil.showerror(this.getApplicationContext(), errorCode); } }
Example 15
Source File: RouteActivity.java From TraceByAmap with MIT License | 4 votes |
/** * 步行路线搜索结果方法回调 */ @Override public void onWalkRouteSearched(WalkRouteResult result, int errorCode) { dissmissProgressDialog(); aMap.clear();// 清理地图上的所有覆盖物 if (errorCode == AMapException.CODE_AMAP_SUCCESS) { if (result != null && result.getPaths() != null) { if (result.getPaths().size() > 0) { mWalkRouteResult = result; final WalkPath walkPath = mWalkRouteResult.getPaths() .get(0); if(walkPath == null) { return; } WalkRouteOverlay walkRouteOverlay = new WalkRouteOverlay( this, aMap, walkPath, mWalkRouteResult.getStartPos(), mWalkRouteResult.getTargetPos()); walkRouteOverlay.removeFromMap(); walkRouteOverlay.addToMap(); walkRouteOverlay.zoomToSpan(); mBottomLayout.setVisibility(View.VISIBLE); int dis = (int) walkPath.getDistance(); int dur = (int) walkPath.getDuration(); String des = AMapUtil.getFriendlyTime(dur)+"("+AMapUtil.getFriendlyLength(dis)+")"; mRotueTimeDes.setText(des); mRouteDetailDes.setVisibility(View.GONE); mBottomLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(mContext, WalkRouteDetailActivity.class); intent.putExtra("walk_path", walkPath); intent.putExtra("walk_result", mWalkRouteResult); startActivity(intent); } }); } else if (result != null && result.getPaths() == null) { ToastUtil.show(mContext, R.string.no_result); } } else { ToastUtil.show(mContext, R.string.no_result); } } else { ToastUtil.showerror(this.getApplicationContext(), errorCode); } }
Example 16
Source File: RideRouteActivity.java From TraceByAmap with MIT License | 4 votes |
@Override public void onRideRouteSearched(RideRouteResult result, int errorCode) { dissmissProgressDialog(); aMap.clear();// 清理地图上的所有覆盖物 if (errorCode == AMapException.CODE_AMAP_SUCCESS) { if (result != null && result.getPaths() != null) { if (result.getPaths().size() > 0) { mRideRouteResult = result; final RidePath ridePath = mRideRouteResult.getPaths() .get(0); if(ridePath == null) { return; } RideRouteOverlay rideRouteOverlay = new RideRouteOverlay( this, aMap, ridePath, mRideRouteResult.getStartPos(), mRideRouteResult.getTargetPos()); rideRouteOverlay.removeFromMap(); rideRouteOverlay.addToMap(); rideRouteOverlay.zoomToSpan(); mBottomLayout.setVisibility(View.VISIBLE); int dis = (int) ridePath.getDistance(); int dur = (int) ridePath.getDuration(); String des = AMapUtil.getFriendlyTime(dur)+"("+AMapUtil.getFriendlyLength(dis)+")"; mRotueTimeDes.setText(des); mRouteDetailDes.setVisibility(View.GONE); mBottomLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(mContext, RideRouteDetailActivity.class); intent.putExtra("ride_path", ridePath); intent.putExtra("ride_result", mRideRouteResult); startActivity(intent); } }); } else if (result != null && result.getPaths() == null) { ToastUtil.show(mContext, R.string.no_result); } } else { ToastUtil.show(mContext, R.string.no_result); } } else { ToastUtil.showerror(this.getApplicationContext(), errorCode); } }
Example 17
Source File: DriveRouteActivity.java From TraceByAmap with MIT License | 4 votes |
@Override public void onDriveRouteSearched(DriveRouteResult result, int errorCode) { dissmissProgressDialog(); aMap.clear();// 清理地图上的所有覆盖物 if (errorCode == AMapException.CODE_AMAP_SUCCESS) { if (result != null && result.getPaths() != null) { if (result.getPaths().size() > 0) { mDriveRouteResult = result; final DrivePath drivePath = mDriveRouteResult.getPaths() .get(0); if(drivePath == null) { return; } DrivingRouteOverlay drivingRouteOverlay = new DrivingRouteOverlay( mContext, aMap, drivePath, mDriveRouteResult.getStartPos(), mDriveRouteResult.getTargetPos(), null); drivingRouteOverlay.setNodeIconVisibility(false);//设置节点marker是否显示 drivingRouteOverlay.setIsColorfulline(true);//是否用颜色展示交通拥堵情况,默认true drivingRouteOverlay.removeFromMap(); drivingRouteOverlay.addToMap(); drivingRouteOverlay.zoomToSpan(); mBottomLayout.setVisibility(View.VISIBLE); int dis = (int) drivePath.getDistance(); int dur = (int) drivePath.getDuration(); String des = AMapUtil.getFriendlyTime(dur)+"("+AMapUtil.getFriendlyLength(dis)+")"; mRotueTimeDes.setText(des); mRouteDetailDes.setVisibility(View.VISIBLE); int taxiCost = (int) mDriveRouteResult.getTaxiCost(); mRouteDetailDes.setText("打车约"+taxiCost+"元"); mBottomLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(mContext, DriveRouteDetailActivity.class); intent.putExtra("drive_path", drivePath); intent.putExtra("drive_result", mDriveRouteResult); startActivity(intent); } }); } else if (result != null && result.getPaths() == null) { ToastUtil.show(mContext, R.string.no_result); } } else { ToastUtil.show(mContext, R.string.no_result); } } else { ToastUtil.showerror(this.getApplicationContext(), errorCode); } }
Example 18
Source File: RouteDistanceActivity.java From TraceByAmap with MIT License | 4 votes |
@Override public void onDistanceSearched(DistanceResult distanceResult, int errorCode) { dissmissProgressDialog(); if (errorCode == AMapException.CODE_AMAP_SUCCESS) { try { Log.i("amap", "onDistanceSearched " + distanceResult); List<DistanceItem> distanceItems = distanceResult.getDistanceResults(); DistanceSearch.DistanceQuery distanceQuery = distanceResult.getDistanceQuery(); List<LatLonPoint> origins = distanceQuery.getOrigins(); LatLonPoint destLatlon = distanceQuery.getDestination(); if(distanceItems == null) { return; } int index = 1; for (DistanceItem item : distanceItems) { StringBuffer stringBuffer = new StringBuffer(); //item.getOriginId() - 1 是因为 下标从1开始 stringBuffer.append("\n\torid: ").append(item.getOriginId()).append(" ").append(origins.get(item.getOriginId() - 1)).append("\n"); stringBuffer.append("\tdeid: ").append(item.getDestId()).append(" ").append(destLatlon).append("\n"); stringBuffer.append("\tdis: ").append(item.getDistance()).append(" , "); stringBuffer.append("\tdur: ").append(item.getDuration()); if (item.getErrorInfo() != null) { stringBuffer.append(" , ").append("err: ").append(item.getErrorCode()).append(" ").append(item.getErrorInfo()); } stringBuffer.append("\n"); Log.i("amap", "onDistanceSearched " + index + " : " + stringBuffer.toString()); mDistanceText.get(index - 1).setText(item.getDistance() + " 米 " + item.getDuration() + " 秒"); index++; } } catch (Throwable e) { e.printStackTrace(); } } }
Example 19
Source File: WalkRouteActivity.java From TraceByAmap with MIT License | 4 votes |
@Override public void onWalkRouteSearched(WalkRouteResult result, int errorCode) { dissmissProgressDialog(); aMap.clear();// 清理地图上的所有覆盖物 if (errorCode == AMapException.CODE_AMAP_SUCCESS) { if (result != null && result.getPaths() != null) { if (result.getPaths().size() > 0) { mWalkRouteResult = result; final WalkPath walkPath = mWalkRouteResult.getPaths() .get(0); if(walkPath == null) { return; } WalkRouteOverlay walkRouteOverlay = new WalkRouteOverlay( this, aMap, walkPath, mWalkRouteResult.getStartPos(), mWalkRouteResult.getTargetPos()); walkRouteOverlay.removeFromMap(); walkRouteOverlay.addToMap(); walkRouteOverlay.zoomToSpan(); mBottomLayout.setVisibility(View.VISIBLE); int dis = (int) walkPath.getDistance(); int dur = (int) walkPath.getDuration(); String des = AMapUtil.getFriendlyTime(dur)+"("+AMapUtil.getFriendlyLength(dis)+")"; mRotueTimeDes.setText(des); mRouteDetailDes.setVisibility(View.GONE); mBottomLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(mContext, WalkRouteDetailActivity.class); intent.putExtra("walk_path", walkPath); intent.putExtra("walk_result", mWalkRouteResult); startActivity(intent); } }); } else if (result != null && result.getPaths() == null) { ToastUtil.show(mContext, R.string.no_result); } } else { ToastUtil.show(mContext, R.string.no_result); } } else { ToastUtil.showerror(this.getApplicationContext(), errorCode); } }
Example 20
Source File: CloudActivity.java From TraceByAmap with MIT License | votes |
@Override public void onCloudItemDetailSearched(CloudItemDetail item, int rCode) { dissmissProgressDialog();// 隐藏对话框 if (rCode == AMapException.CODE_AMAP_SUCCESS && item != null) { if (mCloudIDMarer != null) { mCloudIDMarer.destroy(); } mAMap.clear(); LatLng position = AMapUtil.convertToLatLng(item.getLatLonPoint()); mAMap.animateCamera(CameraUpdateFactory .newCameraPosition(new CameraPosition(position, 18, 0, 30))); mCloudIDMarer = mAMap.addMarker(new MarkerOptions() .position(position) .title(item.getTitle()) .icon(BitmapDescriptorFactory .defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); items.add(item); Log.d(TAG, "_id" + item.getID()); Log.d(TAG, "_location" + item.getLatLonPoint().toString()); Log.d(TAG, "_name" + item.getTitle()); Log.d(TAG, "_address" + item.getSnippet()); Log.d(TAG, "_caretetime" + item.getCreatetime()); Log.d(TAG, "_updatetime" + item.getUpdatetime()); Log.d(TAG, "_distance" + item.getDistance()); Iterator iter = item.getCustomfield().entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); Object key = entry.getKey(); Object val = entry.getValue(); Log.d(TAG, key + " " + val); } } else { ToastUtil.showerror(this, rCode); } }