Ejemplo n.º 1
0
 public void onGetPoiResult(PoiResult result) {
   if (result == null || result.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {
     Toast.makeText(PoiSearchDemo.this, "未找到结果", Toast.LENGTH_LONG).show();
     return;
   }
   if (result.error == SearchResult.ERRORNO.NO_ERROR) {
     status = address_;
     poiResultAdapter2.setDate(result.getAllPoi());
     poi_lv.setAdapter(poiResultAdapter2);
     mBaiduMap.clear();
     PoiOverlay overlay = new MyPoiOverlay(mBaiduMap);
     mBaiduMap.setOnMarkerClickListener(overlay);
     overlay.setData(result);
     overlay.addToMap();
     overlay.zoomToSpan();
     Log.d("baidu_wjx", "find");
     return;
   }
   if (result.error == SearchResult.ERRORNO.AMBIGUOUS_KEYWORD) {
     status = city_;
     poiResultAdapter.setDate(result.getSuggestCityList());
     poi_lv.setAdapter(poiResultAdapter);
     // 当输入关键字在本市没有找到,但在其他城市找到时,返回包含该关键字信息的城市列表
     String strInfo = "在";
     for (CityInfo cityInfo : result.getSuggestCityList()) {
       strInfo += cityInfo.city;
       strInfo += ",";
     }
     strInfo += "找到结果";
     Toast.makeText(PoiSearchDemo.this, strInfo, Toast.LENGTH_LONG).show();
     Log.d("baidu_wjx", strInfo);
   }
 }
Ejemplo n.º 2
0
  public void onGetPoiResult(PoiResult result) {

    if (result == null || result.error == SearchResult.ERRORNO.RESULT_NOT_FOUND) {

      Toast.makeText(
              MainActivity.this,
              getResources().getString(R.string.notFoundResult),
              Toast.LENGTH_LONG)
          .show();
      return;
    }

    int first = 0;

    if (result.error == SearchResult.ERRORNO.NO_ERROR) {
      for (PoiInfo poi : result.getAllPoi()) {
        if (poi.type == PoiInfo.POITYPE.BUS_STATION) {
          // Log.i("Nearby poiresult",""+poi.name+"-"+poi.address);

          if (first == 0) {

            // 创建PoiOverlay
            overlay = new MyPoiOverlay(mBaiduMap);
            // 设置overlay可以处理标注点击事件
            mBaiduMap.setOnMarkerClickListener(overlay);
            // 设置PoiOverlay数据
            overlay.setData(result);
            // 添加PoiOverlay到地图中
            overlay.addToMap();
            overlay.zoomToSpan();

            first = 1;
          }

          HashMap<String, Object> map = new HashMap<String, Object>();
          map.put("name", poi.name);
          map.put("address", poi.address);
          // 计算距离当前位置的距离
          double distance =
              DistanceUtil.getDistance(OneBusApplication.CURRENT_LOCATION, poi.location);
          map.put("distance", (int) distance + "米");
          mStationList.add(map);

          // return;
        }
      }
    }
  }
Ejemplo n.º 3
0
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.i(TAG, "==onActivityResult1==" + requestCode);
    Log.i(TAG, "==onActivityResult2==" + resultCode);
    if (requestCode == 1) {
      if (resultCode == 2) {

        MainActivity.mMapView.getMap().clear();
        PoiOverlay overlay = new MyPoiOverlay(MainActivity.mMapView.getMap());
        MainActivity.mMapView.getMap().setOnMarkerClickListener(overlay);
        overlay.setData(GoMapApp.mPoiResult);
        overlay.addToMap();
        overlay.zoomToSpan();
      }
    }
  }