com.amap.api.services.core.PoiItem Java Examples
The following examples show how to use
com.amap.api.services.core.PoiItem.
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: PoiSearchTask.java From Android_UsingCar_Example with Apache License 2.0 | 6 votes |
@Override public void onPoiSearched(PoiResult poiResult, int resultCode) { if (resultCode == 0 && poiResult != null) { ArrayList<PoiItem> pois=poiResult.getPois(); if(pois==null){ return; } List<PositionEntity>entities=new ArrayList<PositionEntity>(); for(PoiItem poiItem:pois){ PositionEntity entity=new PositionEntity(poiItem.getLatLonPoint().getLatitude(), poiItem.getLatLonPoint().getLongitude(),poiItem.getTitle() ,poiItem.getCityName()); entities.add(entity); } mRecommandAdapter.setPositionEntities(entities); mRecommandAdapter.notifyDataSetChanged(); } //TODO 可以根据app自身需求对查询错误情况进行相应的提示或者逻辑处理 }
Example #2
Source File: LocationActivity.java From Socket.io-FLSocketIM-Android with MIT License | 6 votes |
private void sendLocation() { double lat = 0.0; double lon = 0.0; if (selectedIndex == 0 ){ lat = oldLocation.latitude; lon = oldLocation.longitude; } else { PoiItem poiItem = (PoiItem) aroundLocationList.get(selectedIndex); lat = poiItem.getLatLonPoint().getLatitude(); lon = poiItem.getLatLonPoint().getLongitude(); } Intent intent = new Intent(); intent.putExtra("lat", lat); intent.putExtra("lon", lon); intent.putExtra("location", currentLocationName); intent.putExtra("detailLocation", currentDetailLocationName); setResult(101, intent); goBack(); }
Example #3
Source File: SearchResultAdapter.java From xposed-rimet with Apache License 2.0 | 6 votes |
public String poiItemToString(PoiItem poiItem) { if ("regeo".equals(poiItem.getPoiId())) { return poiItem.getSnippet(); } if (beginAddress != null) { return beginAddress + poiItem.getSnippet(); } StringBuilder builder = new StringBuilder(poiItem.getProvinceName()); if (!TextUtils.equals(poiItem.getProvinceName(), poiItem.getCityName())) { builder.append(poiItem.getCityName()); } builder.append(poiItem.getAdName()); if (!TextUtils.equals(poiItem.getAdName(), poiItem.getSnippet())) { builder.append(poiItem.getSnippet()); } return builder.toString(); }
Example #4
Source File: MapActivity.java From xposed-rimet with Apache License 2.0 | 6 votes |
/** * 返回选择的结果 */ private void returnChooseResult() { if (mSearchResultAdapter.isEmpty()) { // 没有结果 setResult(Activity.RESULT_OK, new Intent()); onBackPressed(); return; } // 返回的结果 PoiItem poiItem = mSearchResultAdapter .getItem(mSearchResultAdapter.getSelectedPosition()); Intent data = new Intent(); data.putExtra("address", mSearchResultAdapter.poiItemToString(poiItem)); data.putExtra("latitude", poiItem.getLatLonPoint().getLatitude()); data.putExtra("longitude", poiItem.getLatLonPoint().getLongitude()); setResult(Activity.RESULT_OK, data); onBackPressed(); }
Example #5
Source File: MapsFragment.java From Maps with GNU General Public License v2.0 | 6 votes |
@Override public void showSearchResult(List<PoiItem> poiItems) { if (poiItems == null || poiItems.isEmpty()){ ToastUtil.show(getActivity().getApplicationContext(), R.string.no_poi_search); } else { mSearchViewHelper.showSuggestTips(); if (mPoiOverlay != null) { mPoiOverlay.removeFromMap(); mPoiOverlay = null; } PoiOverlay poiOverlay = new PoiOverlay(aMap, poiItems); poiOverlay.addToMap(); poiOverlay.zoomToSpan(); mPoiOverlay = poiOverlay; mSearchMapsPresenter.showPoiFloatWindow(poiItems.get(0)); mPoiItem = poiItems.get(0); } }
Example #6
Source File: PoiListAdapter.java From TraceByAmap with MIT License | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); convertView = View.inflate(ctx, R.layout.listview_item, null); holder.poititle = (TextView) convertView .findViewById(R.id.poititle); holder.subpois = (GridView) convertView.findViewById(R.id.listview_item_gridview); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } PoiItem item = list.get(position); holder.poititle.setText(item.getTitle()); if (item.getSubPois().size() > 0) { List<SubPoiItem> subPoiItems = item.getSubPois(); SubPoiAdapter subpoiAdapter=new SubPoiAdapter(ctx, subPoiItems); holder.subpois.setAdapter(subpoiAdapter); } return convertView; }
Example #7
Source File: PoiOverlay.java From BmapLite with Apache License 2.0 | 5 votes |
/** * 返回第index的poi的信息。 * @param index 第几个poi。 * @return poi的信息。poi对象详见搜索服务模块的基础核心包(com.amap.api.services.core)中的类 <strong><a href="../../../../../../Search/com/amap/api/services/core/PoiItem.html" title="com.amap.api.services.core中的类">PoiItem</a></strong>。 * @since V2.1.0 */ public PoiItem getPoiItem(int index) { if (index < 0 || index >= mPois.size()) { return null; } return mPois.get(index); }
Example #8
Source File: AMapLiteActivity.java From XposedRimetHelper with GNU General Public License v2.0 | 5 votes |
private List<LocationSearchSuggestions> searchResultData2SearchSuggestion(List<PoiItem> data) { List<LocationSearchSuggestions> result = new ArrayList<>(); for (PoiItem datum : data) { result.add(new LocationSearchSuggestions(datum.getTitle(), datum.getCityName() + datum.getAdName() + datum.getSnippet(), new LatLng(datum.getLatLonPoint().getLatitude(), datum.getLatLonPoint().getLongitude()))); } return result; }
Example #9
Source File: PoiOverlay.java From BmapLite with GNU General Public License v3.0 | 5 votes |
/** * 返回第index的poi的信息。 * @param index 第几个poi。 * @return poi的信息。poi对象详见搜索服务模块的基础核心包(com.amap.api.services.core)中的类 <strong><a href="../../../../../../Search/com/amap/api/services/core/PoiItem.html" title="com.amap.api.services.core中的类">PoiItem</a></strong>。 * @since V2.1.0 */ public PoiItem getPoiItem(int index) { if (index < 0 || index >= mPois.size()) { return null; } return mPois.get(index); }
Example #10
Source File: PoiOverlay.java From TraceByAmap with MIT License | 5 votes |
/** * 返回第index的poi的信息。 * @param index 第几个poi。 * @return poi的信息。poi对象详见搜索服务模块的基础核心包(com.amap.api.services.core)中的类 <strong><a href="../../../../../../Search/com/amap/api/services/core/PoiItem.html" title="com.amap.api.services.core中的类">PoiItem</a></strong>。 * @since V2.1.0 */ public PoiItem getPoiItem(int index) { if (index < 0 || index >= mPois.size()) { return null; } return mPois.get(index); }
Example #11
Source File: LocationActivity.java From xmpp with Apache License 2.0 | 5 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder view = null; if (convertView == null) { convertView = LayoutInflater.from(LocationActivity.this).inflate(R.layout.location_listview_item, null); view = new ViewHolder(); view.text = (TextView) convertView.findViewById(R.id.item_text); view.text1 = (TextView) convertView .findViewById(R.id.item_text1); view.sure = (Button) convertView.findViewById(R.id.sure); convertView.setTag(view); } else { view = (ViewHolder) convertView.getTag(); } final PoiItem po = list.get(position); view.text.setText(po.toString()); view.text1.setText(po.getProvinceName()+po.getCityName()+po.getSnippet()); view.sure.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(); i.putExtra("location", po.getProvinceName() +po.getCityName()+po.getSnippet()+po.toString()); setResult(99, i); finish(); } }); return convertView; }
Example #12
Source File: ShareActivity.java From TraceByAmap with MIT License | 5 votes |
/** * POI转短串分享 */ private void sharePOI(String title, String snippet) { addPOIMarker(title, snippet); PoiItem item = new PoiItem(null, POI_POINT, title, snippet); showProgressDialog(); mShareSearch.searchPoiShareUrlAsyn(item); }
Example #13
Source File: PoiAroundSearchActivity.java From TraceByAmap with MIT License | 5 votes |
/** * 返回第index的poi的信息。 * @param index 第几个poi。 * @return poi的信息。poi对象详见搜索服务模块的基础核心包(com.amap.api.services.core)中的类 <strong><a href="../../../../../../Search/com/amap/api/services/core/PoiItem.html" title="com.amap.api.services.core中的类">PoiItem</a></strong>。 * @since V2.1.0 */ public PoiItem getPoiItem(int index) { if (index < 0 || index >= mPois.size()) { return null; } return mPois.get(index); }
Example #14
Source File: PoiAroundSearchActivity.java From TraceByAmap with MIT License | 5 votes |
/** * 添加Marker到地图中。 * @since V2.1.0 */ public void addToMap() { if(mPois != null) { int size = mPois.size(); for (int i = 0; i < size; i++) { Marker marker = mamap.addMarker(getMarkerOptions(i)); PoiItem item = mPois.get(i); marker.setObject(item); mPoiMarks.add(marker); } } }
Example #15
Source File: FindMapAroundAty.java From myapplication with Apache License 2.0 | 5 votes |
/** * 添加Marker到地图中。 * * @since V2.1.0 */ public void addToMap() { for (int i = 0; i < mPois.size(); i++) { Marker marker = mamap.addMarker(getMarkerOptions(i)); PoiItem item = mPois.get(i); marker.setObject(item); mPoiMarks.add(marker); } }
Example #16
Source File: PoiAroundSearchActivity.java From TraceByAmap with MIT License | 5 votes |
@Override public boolean onMarkerClick(Marker marker) { if (marker.getObject() != null) { whetherToShowDetailInfo(true); try { PoiItem mCurrentPoi = (PoiItem) marker.getObject(); if (mlastMarker == null) { mlastMarker = marker; } else { // 将之前被点击的marker置为原来的状态 resetlastmarker(); mlastMarker = marker; } detailMarker = marker; detailMarker.setIcon(BitmapDescriptorFactory .fromBitmap(BitmapFactory.decodeResource( getResources(), R.drawable.poi_marker_pressed))); setPoiItemDisplayContent(mCurrentPoi); } catch (Exception e) { // TODO: handle exception } }else { whetherToShowDetailInfo(false); resetlastmarker(); } return true; }
Example #17
Source File: PoiIDSearchActivity.java From TraceByAmap with MIT License | 5 votes |
private void setPoiItemDisplayContent(final PoiItem mCurrentPoi) { if (mCurrentPoi != null) { mPoiName.setText(mCurrentPoi.getTitle()); mPoiAddress.setText(mCurrentPoi.getSnippet()); mPoiInfo.setText("营业时间:" + mCurrentPoi.getPoiExtension().getOpentime() + " 评分:" + mCurrentPoi.getPoiExtension().getmRating()); } }
Example #18
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 #19
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 #20
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 #21
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 #22
Source File: SearchMapsInteractorImpl.java From Maps with GNU General Public License v2.0 | 5 votes |
@Override public void onPoiSearched(PoiResult result, int rCode) { if (rCode == 0) { if (result != null && result.getQuery() != null) {// 搜索poi的结果 if (result.getQuery().equals(query)) {// 是否是同一条 // 取得搜索到的poiitems有多少页 List<PoiItem> poiItems = result.getPois();// 取得第一页的poiitem数据,页数从数字0开始 List<SuggestionCity> suggestionCities = result .getSearchSuggestionCitys();// 当搜索不到poiitem数据时,会返回含有搜索关键字的城市信息 if (mOnPoiSearchFinishedListener != null){ mOnPoiSearchFinishedListener.onPoiSearchFinished(poiItems); } } } else { ToastUtil.show(mContext, R.string.no_result); } } else if (rCode == 27) { ToastUtil.show(mContext, R.string.error_network); } else if (rCode == 32) { ToastUtil.show(mContext, R.string.error_key); } else { ToastUtil.show(mContext, mContext.getString(R.string.error_other) + rCode); } }
Example #23
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 #24
Source File: MapActivity.java From xposed-rimet with Apache License 2.0 | 5 votes |
@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 #25
Source File: SearchResultAdapter.java From xposed-rimet with Apache License 2.0 | 5 votes |
@Override public void onBind(int position, int viewType) { PoiItem poiItem = getItem(position); tvTitle.setText(poiItem.getTitle()); tvSubTitle.setText(poiItemToString(poiItem)); ViewUtil.setVisibility(ivCheck, position == selectedPosition ? View.VISIBLE : View.INVISIBLE); ViewUtil.setVisibility(tvSubTitle, (position == 0 && poiItem.getPoiId().equals("regeo") ? View.GONE : View.VISIBLE)); }
Example #26
Source File: SearchMapsPresenter.java From Maps with GNU General Public License v2.0 | 4 votes |
@Override public void onPoiSearchFinished(List<PoiItem> poiItems) { mSearchMapsView.hideSearchProgress(); mSearchMapsView.showSearchResult(poiItems); }
Example #27
Source File: SearchMapsPresenter.java From Maps with GNU General Public License v2.0 | 4 votes |
public void showPoiFloatWindow(PoiItem poiItem) { mSearchMapsView.showPoiFloatWindow(poiItem); }
Example #28
Source File: FindMapAroundAty.java From myapplication with Apache License 2.0 | 4 votes |
public MyPoiOverlay(AMap amap, List<PoiItem> pois) { mamap = amap; mPois = pois; }
Example #29
Source File: LocationActivity.java From xmpp with Apache License 2.0 | 4 votes |
public void setList(List<PoiItem> lists){ list=lists; notifyDataSetChanged(); }
Example #30
Source File: MapsFragment.java From Maps with GNU General Public License v2.0 | 4 votes |
@Override public void showPoiFloatWindow(PoiItem poiItem) { mSearchFloatWindow.setVisibility(View.VISIBLE); PoiItem item = poiItem; if (DEBUG){ Log.d("showPoiFloatWindow adCode -" , poiItem.getAdCode()); Log.d("showPoiFloatWindow adName -" , poiItem.getAdName()); Log.d("showPoiFloatWindow CityCOde -" , poiItem.getCityCode()); Log.d("showPoiFloatWindow cityName -" , poiItem.getCityName()); Log.d("showPoiFloatWindow direction -" , poiItem.getDirection()); Log.d("showPoiFloatWindow email -" , poiItem.getEmail()); Log.d("showPoiFloatWindow poid -" , poiItem.getPoiId()); Log.d("showPoiFloatWindow postCode -" , poiItem.getPostcode()); Log.d("showPoiFloatWindow provinceCode -" , poiItem.getProvinceCode()); Log.d("showPoiFloatWindow provincename -" , poiItem.getProvinceName()); Log.d("showPoiFloatWindow snippet -" , poiItem.getSnippet()); Log.d("showPoiFloatWindow tel -" , poiItem.getTel()); Log.d("showPoiFloatWindow title -" , poiItem.getTitle()); Log.d("showPoiFloatWindow typedes -" , poiItem.getTypeDes()); Log.d("showPoiFloatWindow website -" , poiItem.getWebsite()); Log.d("showPoiFloatWindow distance -" , poiItem.getDistance() + ""); } mSearchPoiTitle.setText(poiItem.getTitle()); String sum = ""; if (!TextUtils.isEmpty(poiItem.getProvinceName())){ sum += poiItem.getProvinceName(); } if (!TextUtils.isEmpty(poiItem.getCityName())){ sum += "-" + poiItem.getCityName(); } if (!TextUtils.isEmpty(poiItem.getAdName())){ sum += "-" + poiItem.getAdName(); } if (!TextUtils.isEmpty(poiItem.getSnippet())){ sum += "-" + poiItem.getSnippet(); } mSearchPoiSummary.setText(sum); mSearchPoiTel.setText(poiItem.getTel()); mLineBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AMapNavi aMapNavi = AMapNavi.getInstance(getActivity().getApplicationContext()); ArrayList<NaviLatLng> start = new ArrayList<>(); start.add(new NaviLatLng(mMapsModule.getMyLocation().getLatitude(), mMapsModule.getMyLocation().getLongitude())); ArrayList<NaviLatLng> end = new ArrayList<>(); end.add(new NaviLatLng(mPoiItem.getLatLonPoint().getLatitude(), mPoiItem.getLatLonPoint().getLongitude())); aMapNavi.calculateDriveRoute(end, null, AMapNavi.DrivingDefault); Intent intent = new Intent(getActivity(), NaviRouteActivity.class); intent.putParcelableArrayListExtra(NaviRouteActivity.NAVI_ENDS, end); intent.putParcelableArrayListExtra(NaviRouteActivity.NAVI_START, start); getActivity().startActivity(intent); } }); // mNaviBtn.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // Intent intent = new Intent(getActivity(), NaviEmulatorActivity.class); // getActivity().startActivity(intent); // } // }); }