GithubHelp home page GithubHelp logo

android-place-search's Introduction

android-place-search

输入提示与poi关键字搜索示例

前述

使用方法##

###1:配置搭建AndroidSDK工程###

扫一扫安装##

Screenshot

示例效果##

  • 输入提示展示

Screenshot

  • POI搜索结果展示

Screenshot

核心类/接口

接口 说明 版本
PoiSearch searchPOIAsyn() 查询POI异步接口 V2.1.0
Inputtips requestInputtipsAsyn() 查询输入提示的异步接口 V2.0.2

核心难点

 - 输入字符变化时开启输入提示

    /**
   * 输入字符变化时触发
   *
   * @param newText
   * @return
   */
  @Override
  public boolean onQueryTextChange(String newText) {
      if (!AMapUtil.IsEmptyOrNullString(newText)) {
          InputtipsQuery inputquery = new InputtipsQuery(newText, Constants.DEFAULT_CITY);
          Inputtips inputTips = new Inputtips(InputTipsActivity.this.getApplicationContext(), inputquery);
          inputTips.setInputtipsListener(this);
          inputTips.requestInputtipsAsyn();
      } else {
          if (mIntipAdapter != null && mCurrentTipList != null) {
              mCurrentTipList.clear();
              mIntipAdapter.notifyDataSetChanged();
          }
      }
      return false;
  }

  - 输入提示获取tips或者搜索关键词处理逻辑

   /**
   * 输入提示activity选择结果后的处理逻辑
   *
   * @param requestCode
   * @param resultCode
   * @param data
   */

  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
      super.onActivityResult(requestCode, resultCode, data);
      if (resultCode == RESULT_CODE_INPUTTIPS && data
              != null) {
          mAMap.clear();
          Tip tip = data.getParcelableExtra(Constants.EXTRA_TIP);
          if (tip.getPoiID() == null || tip.getPoiID().equals("")) {
              doSearchQuery(tip.getName());
          } else {
              addTipMarker(tip);
          }
          mKeywordsTextView.setText(tip.getName());
          if(!tip.getName().equals("")){
              mCleanKeyWords.setVisibility(View.VISIBLE);
          }
      } else if (resultCode == RESULT_CODE_KEYWORDS && data != null) {
          mAMap.clear();
          String keywords = data.getStringExtra(Constants.KEY_WORDS_NAME);
          if(keywords != null && !keywords.equals("")){
              doSearchQuery(keywords);
          }
          mKeywordsTextView.setText(keywords);
          if(!keywords.equals("")){
              mCleanKeyWords.setVisibility(View.VISIBLE);
          }
      }
  }

android-place-search's People

Contributors

music1983 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.