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 彩灯控制电路,会的加我QQ1482956179
    • ¥200 相机拍直接转存到电脑上 立拍立穿无线局域网传
    • ¥15 (关键词-电路设计)
    • ¥15 如何解决MIPS计算是否溢出
    • ¥15 vue中我代理了iframe,iframe却走的是路由,没有显示该显示的网站,这个该如何处理
    • ¥15 操作系统相关算法中while();的含义
    • ¥15 CNVcaller安装后无法找到文件
    • ¥15 visual studio2022中文乱码无法解决
    • ¥15 关于华为5g模块mh5000-31接线问题
    • ¥15 keil L6007U报错