com.amap.api.services.core.AMapException Java Examples

The following examples show how to use com.amap.api.services.core.AMapException. 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: WeatherSearchActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 实时天气查询回调
 */
@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 #2
Source File: SubPoiSearchActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
@Override
  public void onGetInputtips(List<Tip> tipList, int rCode) {
      if (rCode == AMapException.CODE_AMAP_SUCCESS) {
          if (tipList != null) {
              List<String> listString = new ArrayList<String>();
              int size = tipList.size();
              for (int i = 0; i < size; i++) {
                  listString.add(tipList.get(i).getName());
              }
              ArrayAdapter<String> aAdapter = new ArrayAdapter<String>(
                      getApplicationContext(),
                      R.layout.route_inputs, listString);
              mKeywordText.setAdapter(aAdapter);
              aAdapter.notifyDataSetChanged();
          }
      } else {
      	ToastUtil.showerror(this, rCode);
}     
  }
 
Example #3
Source File: PoiKeywordSearchActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 调起高德地图导航功能,如果没安装高德地图,会进入异常,可以在异常中处理,调起高德地图app的下载页面
 */
public void startAMapNavi(Marker marker) {
	// 构造导航参数
	NaviPara naviPara = new NaviPara();
	// 设置终点位置
	naviPara.setTargetPoint(marker.getPosition());
	// 设置导航策略,这里是避免拥堵
	naviPara.setNaviStyle(NaviPara.DRIVING_AVOID_CONGESTION);

	// 调起高德地图导航
	try {
		AMapUtils.openAMapNavi(naviPara, getApplicationContext());
	} catch (com.amap.api.maps.AMapException e) {

		// 如果没安装会进入异常,调起下载页面
		AMapUtils.getLatestAMapApp(getApplicationContext());

	}

}
 
Example #4
Source File: WeatherSearchActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 天气预报查询结果回调
 */
@Override
public void onWeatherForecastSearched(
        LocalWeatherForecastResult weatherForecastResult, int rCode) {
    if (rCode == AMapException.CODE_AMAP_SUCCESS) {
        if (weatherForecastResult != null && weatherForecastResult.getForecastResult() != null
                && weatherForecastResult.getForecastResult().getWeatherForecast() != null
                && weatherForecastResult.getForecastResult().getWeatherForecast().size() > 0) {
            weatherforecast = weatherForecastResult.getForecastResult();
            forecastlist = weatherforecast.getWeatherForecast();
            fillforecast();

        } else {
            ToastUtil.show(WeatherSearchActivity.this, R.string.no_result);
        }
    } else {
        ToastUtil.showerror(WeatherSearchActivity.this, rCode);
    }
}
 
Example #5
Source File: PoiKeywordSearchActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
@Override
public void onGetInputtips(List<Tip> tipList, int rCode) {
	if (rCode == AMapException.CODE_AMAP_SUCCESS) {// 正确返回
		List<String> listString = new ArrayList<String>();
		for (int i = 0; i < tipList.size(); i++) {
			listString.add(tipList.get(i).getName());
		}
		ArrayAdapter<String> aAdapter = new ArrayAdapter<String>(
				getApplicationContext(),
				R.layout.route_inputs, listString);
		searchText.setAdapter(aAdapter);
		aAdapter.notifyDataSetChanged();
	} else {
		ToastUtil.showerror(this, rCode);
	}
	
}
 
Example #6
Source File: RoutePOIActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
@Override
public void onRoutePoiSearched(RoutePOISearchResult result, int errorCode) {
	if (errorCode == AMapException.CODE_AMAP_SUCCESS) {
		if(result != null){
			List<RoutePOIItem> items = result.getRoutePois();
			if (items != null && items.size() > 0) {
				if (overlay != null) {
					overlay.removeFromMap();
				}
				overlay = new myRoutePoiOverlay(aMap, items);
				overlay.addToMap();
			} else {
				ToastUtil.show(RoutePOIActivity.this,R.string.no_result);
			}
		}
	}else{
		ToastUtil.showerror(RoutePOIActivity.this, errorCode);
	}
	
}
 
Example #7
Source File: GeocoderActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 地理编码查询回调
 */
@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 #8
Source File: BusRouteActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 规划路线结果回调方法
    */
@Override
public void onBusRouteSearched(BusRouteResult result, int errorCode) {
	dissmissProgressDialog();
	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 #9
Source File: RouteActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 公交路线搜索结果方法回调
    */
@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 #10
Source File: ReGeocoderActivity.java    From TraceByAmap with MIT License 6 votes vote down vote up
/**
 * 逆地理编码回调
 */
@Override
public void onRegeocodeSearched(RegeocodeResult result, int rCode) {
	dismissDialog();
	if (rCode == AMapException.CODE_AMAP_SUCCESS) {
		if (result != null && result.getRegeocodeAddress() != null
				&& result.getRegeocodeAddress().getFormatAddress() != null) {
			addressName = result.getRegeocodeAddress().getFormatAddress()
					+ "附近";
			aMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
					AMapUtil.convertToLatLng(latLonPoint), 15));
			regeoMarker.setPosition(AMapUtil.convertToLatLng(latLonPoint));
			ToastUtil.show(ReGeocoderActivity.this, addressName);
		} else {
			ToastUtil.show(ReGeocoderActivity.this, R.string.no_result);
		}
	} else {
		ToastUtil.showerror(this, rCode);
	}
}
 
Example #11
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 #12
Source File: BusStationActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * 公交站点查询结果回调
 */
@Override
public void onBusStationSearched(BusStationResult result, int rCode) {
	dissmissProgressDialog();
	if (rCode == AMapException.CODE_AMAP_SUCCESS) {
		if (result != null && result.getPageCount() > 0
				&& result.getBusStations() != null
				&& result.getBusStations().size() > 0) {
			ArrayList<BusStationItem> item = (ArrayList<BusStationItem>) result
					.getBusStations();
			StringBuffer buf = new StringBuffer();
			for (int i = 0; i < item.size(); i++) {
				BusStationItem stationItem = item.get(i);


				buf.append(" station: ").append(i).append(" name: ")
						.append(stationItem.getBusStationName());
				Log.d("LG", "stationName:"
						+ stationItem.getBusStationName() + "stationpos:"
						+ stationItem.getLatLonPoint().toString());
			}
			String text = buf.toString();
			Toast.makeText(BusStationActivity.this, text,
					Toast.LENGTH_SHORT).show();
		} else {
			ToastUtil.show(BusStationActivity.this, R.string.no_result);
		}
	} else  {
		ToastUtil.showerror(BusStationActivity.this, rCode);
	} 
}
 
Example #13
Source File: BuslineActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**
 * 公交线路查询结果回调
 */
@Override
public void onBusLineSearched(BusLineResult result, int rCode) {
	dissmissProgressDialog();
	if (rCode == AMapException.CODE_AMAP_SUCCESS) {
		if (result != null && result.getQuery() != null
				&& result.getQuery().equals(busLineQuery)) {
			if (result.getQuery().getCategory() == SearchType.BY_LINE_NAME) {
				if (result.getPageCount() > 0
						&& result.getBusLines() != null
						&& result.getBusLines().size() > 0) {
					busLineResult = result;
					lineItems = result.getBusLines();
					if(lineItems != null) {
						showResultList(lineItems);
					}
				}
			} else if (result.getQuery().getCategory() == SearchType.BY_LINE_ID) {
				aMap.clear();// 清理地图上的marker
				busLineResult = result;
				lineItems = busLineResult.getBusLines();
				if(lineItems != null && lineItems.size() > 0) {
					BusLineOverlay busLineOverlay = new BusLineOverlay(this,
							aMap, lineItems.get(0));
					busLineOverlay.removeFromMap();
					busLineOverlay.addToMap();
					busLineOverlay.zoomToSpan();
				}
			}
		} else {
			ToastUtil.show(BuslineActivity.this, R.string.no_result);
		}
	} else {
		ToastUtil.showerror(BuslineActivity.this, rCode);
	}
}
 
Example #14
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();
}
 
Example #15
Source File: RoutePOIActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
@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);
				DrivingRouteOverlay drivingRouteOverlay = new DrivingRouteOverlay(
						mContext, aMap, drivePath,
						mDriveRouteResult.getStartPos(),
						mDriveRouteResult.getTargetPos(), null);
				drivingRouteOverlay.setNodeIconVisibility(false);//设置节点marker是否显示
				drivingRouteOverlay.removeFromMap();
				drivingRouteOverlay.addToMap();
				drivingRouteOverlay.zoomToSpan();

			} 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: DriveRoutePlanActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
@Override
public void onDriveRoutePlanSearched(final DriveRoutePlanResult result, int errorCode) {
	dissmissProgressDialog();
	aMap.clear();// 清理地图上的所有覆盖物
	if (errorCode == AMapException.CODE_AMAP_SUCCESS) {
		if (result != null && result.getPaths() != null) {
			travelView.setVisibility(View.VISIBLE);
			travelView.init(result, new TravelView.IndexListener() {
				@Override
				public void onClicked(int index) {
					Log.d("qyd","onDriveRoutePlanSearched onClicked index:" + index);
                       if (result.getPaths().size() > 0) {
                           mDriveRoutePlanResult = result;

                           DrivingRoutePlanOverlay drivingRouteOverlay = new DrivingRoutePlanOverlay(
                                   mContext, aMap, mDriveRoutePlanResult, index);
                           drivingRouteOverlay.setNodeIconVisibility(false);//设置节点marker是否显示
                           drivingRouteOverlay.setIsColorfulline(true);//是否用颜色展示交通拥堵情况,默认true
                           drivingRouteOverlay.removeFromMap();
                           drivingRouteOverlay.addToMap();
                           drivingRouteOverlay.zoomToSpan();

                       } else if (result != null && result.getPaths() == null) {
                           ToastUtil.show(mContext, R.string.no_result);
                       }
				}
			}, arriveTime );

		} else {
			ToastUtil.show(mContext, R.string.no_result);
		}
	} else {
		ToastUtil.showerror(this.getApplicationContext(), errorCode);
	}
}
 
Example #17
Source File: AmapBusFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@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 #18
Source File: AmapRouteFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@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 #19
Source File: AmapRouteFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onRideRouteSearched(RideRouteResult result, int code) {
    mAmap.clear();// 清理地图上的所有覆盖物
    if (code == AMapException.CODE_AMAP_SUCCESS) {
        if (result != null && result.getPaths() != null) {
            if (result.getPaths().size() > 0) {
                final RidePath ridePath = result.getPaths()
                        .get(0);
                RideRouteOverlay overlay = new RideRouteOverlay(getActivity(), mAmap, ridePath,
                        result.getStartPos(),
                        result.getTargetPos());
                overlay.setNodeIconVisibility(false);//设置节点marker是否显示
                overlay.removeFromMap();
                overlay.addToMap();
                overlay.zoomToSpan();

                setLineInfo((int) ridePath.getDistance(), (int) ridePath.getDuration() / 60);

                List<String> details = new ArrayList<>();

                if (null != ridePath.getSteps() && !ridePath.getSteps().isEmpty()) {
                    for (RideStep step : ridePath.getSteps()) {
                        details.add(step.getInstruction());
                    }
                }
                setRouteDetailsAdapter(details);
            }
        }
    }
}
 
Example #20
Source File: AmapBusFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
@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 #21
Source File: AmapRouteFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
@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 #22
Source File: AmapRouteFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
@Override
public void onRideRouteSearched(RideRouteResult result, int code) {
    mAmap.clear();// 清理地图上的所有覆盖物
    if (code == AMapException.CODE_AMAP_SUCCESS) {
        if (result != null && result.getPaths() != null) {
            if (result.getPaths().size() > 0) {
                final RidePath ridePath = result.getPaths()
                        .get(0);
                RideRouteOverlay overlay = new RideRouteOverlay(getActivity(), mAmap, ridePath,
                        result.getStartPos(),
                        result.getTargetPos());
                overlay.setNodeIconVisibility(false);//设置节点marker是否显示
                overlay.removeFromMap();
                overlay.addToMap();
                overlay.zoomToSpan();

                setLineInfo((int) ridePath.getDistance(), (int) ridePath.getDuration() / 60);

                List<String> details = new ArrayList<>();

                if (null != ridePath.getSteps() && !ridePath.getSteps().isEmpty()) {
                    for (RideStep step : ridePath.getSteps()) {
                        details.add(step.getInstruction());
                    }
                }
                setRouteDetailsAdapter(details);
            }
        }
    }
}
 
Example #23
Source File: InputTipTask.java    From Android_UsingCar_Example with Apache License 2.0 5 votes vote down vote up
public void searchTips(String keyWord,String city){
	try {
		mInputTips.requestInputtips(keyWord, city);
	} catch (AMapException e) {
		e.printStackTrace();  
		
	}
}
 
Example #24
Source File: ShareActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
@Override
public void onLocationShareUrlSearched(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 #25
Source File: MapActivity.java    From xposed-rimet with Apache License 2.0 5 votes vote down vote up
@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 #26
Source File: SubPoiSearchActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
@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 #27
Source File: SubPoiSearchActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
@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 #28
Source File: PoiKeywordSearchActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
/**

	 * 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 #29
Source File: PoiIDSearchActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
@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 #30
Source File: ShareActivity.java    From TraceByAmap with MIT License 5 votes vote down vote up
@Override
public void onBusRouteShareUrlSearched(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);
	}
}