sinat_36882167 2019-03-15 18:53
浏览 925

百度地图sdk 关于poiResult poiInfo 的问题,搜索出的poi点 type为空。

我做的毕设是关于android的公交查询。然后搜索站点的时候,使用关键字,
返回的所有兴趣点 type 不是枚举常量中的任意一个 而是为空。原因是什么??
代码如下:

public class ExpActivity extends AppCompatActivity {

Button exp_btn;
EditText exp_edit;
ListView exp_list;
public int totalpages=0;
public BusLineSearch busLineSearch;
public PoiSearch poiSearch;
public PoiDetailSearchOption poiDetailSearchOption;
public String busLindId;
public String edit;
public BusLineSearchOption option;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.activity_exp);
    exp_btn=(Button)findViewById(R.id.exp_btn);
    exp_edit=(EditText)findViewById(R.id.exp_edit);
    exp_list=(ListView)findViewById(R.id.exp_list);
    poiSearch=PoiSearch.newInstance();
    poiSearch.setOnGetPoiSearchResultListener(poiListener);
  //  busLineSearch=BusLineSearch.newInstance();
  //  busLineSearch.setOnGetBusLineSearchResultListener(listener);
    ButtonClick();
}
public  void ButtonClick(){
    exp_btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
           edit=exp_edit.getText().toString();
           poiSearch.searchInCity((new PoiCitySearchOption().city("厦门").keyword(edit)));  //城市范围内搜索 关键字, 但搜索返回的结果 地点好像没有带有类型。

        }
    });
}
OnGetPoiSearchResultListener poiListener =new OnGetPoiSearchResultListener() {
    @Override
    public void onGetPoiResult(PoiResult poiResult) {
        List<String>data=new ArrayList<String>();
        if (poiResult==null || poiResult.error== SearchResult.ERRORNO.RESULT_NOT_FOUND)
        {
            Toast.makeText(ExpActivity.this, "未找到结果", Toast.LENGTH_SHORT).show();
            return;
        }
        if (poiResult.error==SearchResult.ERRORNO.NO_ERROR){

            for (int i=0;i<poiResult.getAllPoi().size();i++){
                PoiInfo poiInfo=poiResult.getAllPoi().get(i);
                data.add(poiInfo.name);
                if (poiInfo.type==PoiInfo.POITYPE.BUS_STATION){
                    Toast.makeText(ExpActivity.this,"搜索到公交线路了!!", Toast.LENGTH_LONG).show();
                    busLindId=poiInfo.uid;
                }
                if (poiInfo.type==null){
                    Toast.makeText(ExpActivity.this,"为何没有类型",Toast.LENGTH_LONG).show();  //执行程序时 显示的是这一提示。
                }
            }
            }
            exp_list.setAdapter(new ArrayAdapter<String>(ExpActivity.this,android.R.layout.simple_list_item_1,data));


    }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3
    • ¥15 牛顿斯科特系数表表示
    • ¥15 arduino 步进电机
    • ¥20 程序进入HardFault_Handler
    • ¥15 关于#python#的问题:自动化测试