background

In fact, the program ape to develop a demo background, all! A!!! The sample!

Say what for social progress, in order to challenge themselves, all! Is!!! A blind! Pull! Egg!

Is nothing more than a background, the product manager requested this feature!!

Nonsense novel, first GIF for respect!

function

Nothing to say, use the latest version of wechat, open “position” – “send position”, lovely, feel a look, 99.99% similarity is not a dream

Or as usual:

  • positioning
  • Location data map logo and list display
  • Move maps to get the latest location information and display it
  • Provides the keyword search function
  • One-click send to get specific address information latitude and longitude and so on
  • ! @ # $%………………… && (* *)

steps

preparation

Go to amap development Center, register an account, apply for a key, download the JAR package! @ # $%…… & * ()

(By the way, make fun of The documents of Gaode really let people egg! Pain!)

GPS positioning

  • Obtain AMapLocation data using Gaud positioning
  • Move the map to the location data page using dynamic silky slide display
  • Draw the Marker identified by GPS
  • Use PoiSearch to retrieve and display the information of nearby landmarks in RecycleView

Moving map Canvas

  • Add the OnCameraChangeListener listener to the bound AMap
  • After the movement, a wave of Marker pattern animation is performed
  • Use GeocodeSearch to encode longitude and latitude inverse addresses into PoiItem text information
  • Display the PoiItem in RecycleView

It doesn’t look too hard

code

Direct code, have comments, steady!

Location home page code

package com.weixin.location;

import android.animation.ObjectAnimator;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationClientOption;
import com.amap.api.location.AMapLocationListener;
import com.amap.api.maps2d.AMap;
import com.amap.api.maps2d.CameraUpdateFactory;
import com.amap.api.maps2d.MapView;
import com.amap.api.maps2d.UiSettings;
import com.amap.api.maps2d.model.BitmapDescriptorFactory;
import com.amap.api.maps2d.model.CameraPosition;
import com.amap.api.maps2d.model.LatLng;
import com.amap.api.maps2d.model.Marker;
import com.amap.api.maps2d.model.MarkerOptions;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.core.PoiItem;
import com.amap.api.services.geocoder.GeocodeResult;
import com.amap.api.services.geocoder.GeocodeSearch;
import com.amap.api.services.geocoder.RegeocodeQuery;
import com.amap.api.services.geocoder.RegeocodeResult;
import com.amap.api.services.poisearch.PoiResult;
import com.amap.api.services.poisearch.PoiSearch;
import com.google.gson.Gson;
import com.weixin.location.adapter.AddressAdapter;
import com.weixin.location.utils.DataConversionUtils;
import com.weixin.location.utils.DatasKey;
import com.weixin.location.utils.OnItemClickLisenter;
import com.weixin.location.utils.SPUtils;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private MapView mMapView;
    private ImageView mIvBack;
    private ImageView mIvSearch;
    private ImageView mIvLocation;
    private ImageView mIvCenterLocation;
    private Button mBtSend;
    private RecyclerView mRecyclerView;
    private AddressAdapter mAddressAdapter;
    private List<PoiItem> mList;
    private PoiItem userSelectPoiItem;

    private AMap mAMap;
    private Marker mMarker, mLocationGpsMarker, mSelectByListMarker;
    private UiSettings mUiSettings;
    private PoiSearch mPoiSearch;
    private PoiSearch.Query mQuery;
    private boolean isSearchData = false; // Whether to search for address data private int searchAllPageNum; Private int searchNowPageNum; private int searchNowPageNum; private int searchNowPageNum; // Number of current POI search pages privatefloat zoom = 14;//地图缩放级别

    private AMapLocationClient locationClient = null;
    private AMapLocationClientOption locationOption = new AMapLocationClientOption();
    private AMapLocation location;
    private AMapLocationListener mAMapLocationListener;

    private onPoiSearchLintener mOnPoiSearchListener;
    private View.OnClickListener mOnClickListener;
    private GeocodeSearch.OnGeocodeSearchListener mOnGeocodeSearchListener;

    private Gson gson;

    private ObjectAnimator mTransAnimator;//地图中心标志动态

    private static final int SEARCHREQUESTCODE = 1001;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initDatas(savedInstanceState);
        initListener();
        startLocation();
    }

    @Override
    public void onResume() {
        super.onResume();
        mMapView.onResume();
    }

    @Override
    public void onPause() {
        super.onPause();
        mMapView.onPause();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mMapView.onSaveInstanceState(outState);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(null ! = data && SEARCHREQUESTCODE == requestCode) { try { userSelectPoiItem = (PoiItem) data.getParcelableExtra(DatasKey.SEARCH_INFO);if(null ! = userSelectPoiItem) { isSearchData =false;
                    doSearchQuery(true."", location.getCity(), userSelectPoiItem.getLatLonPoint());
                    moveMapCamera(userSelectPoiItem.getLatLonPoint().getLatitude(), userSelectPoiItem.getLatLonPoint().getLongitude());
//                    refleshMark(userSelectPoiItem.getLatLonPoint().getLatitude(), userSelectPoiItem.getLatLonPoint().getLongitude());
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        stopLocation();
        mMapView.onDestroy();
        if(null ! = mPoiSearch) { mPoiSearch = null; }if(null ! = gson) { gson = null; }if(null ! = locationClient) { locationClient.onDestroy(); } } private voidinitView() {
        mMapView = (MapView) findViewById(R.id.map);
        mIvBack = (ImageView) findViewById(R.id.iv_back);
        mIvSearch = (ImageView) findViewById(R.id.iv_search);
        mIvLocation = (ImageView) findViewById(R.id.iv_location);
        mIvCenterLocation = (ImageView) findViewById(R.id.iv_center_location);
        mBtSend = (Button) findViewById(R.id.bt_send);
        mRecyclerView = (RecyclerView) findViewById(R.id.recyclerview);

    }

    private void initListener() {/ / monitor map screen mobile mAMap setOnCameraChangeListener (new AMap.OnCameraChangeListener() {
            @Override
            public void onCameraChangeFinish(CameraPosition cameraPosition) {
                if(null ! = location && null ! = cameraPosition && isSearchData) { mIvLocation.setImageResource(R.mipmap.location_gps_black); zoom = cameraPosition.zoom;if(null ! = mSelectByListMarker) { mSelectByListMarker.setVisible(false);
                    }
                    getAddressInfoByLatLong(cameraPosition.target.latitude, cameraPosition.target.longitude);
                    startTransAnimator();
//                    doSearchQuery(true."", location.getCity(), new LatLonPoint(cameraPosition.target.latitude, cameraPosition.target.longitude));
                }
                if(! isSearchData) { isSearchData =true; } } @Override public void onCameraChange(CameraPosition cameraPosition) { } }); / / set touch maps listener mAMap. SetOnMapClickListener (new AMap.OnMapClickListener() {
            @Override
            public void onMapClick(LatLng latLng) {
                isSearchData = true; }}); //Poi search listener mOnPoiSearchListener = new onPoiSearchLintener(); // mOnGeocodeSearchListener = new GeocodeSearch.OnGeocodeSearchListener() {
            @Override
            public void onRegeocodeSearched(RegeocodeResult regeocodeResult, int i) {
                if (i == 1000) {
                    if(regeocodeResult ! = null) { userSelectPoiItem = DataConversionUtils.changeToPoiItem(regeocodeResult);if(null ! = mList) { mList.clear(); } mList.addAll(regeocodeResult.getRegeocodeAddress().getPois());if(null ! = userSelectPoiItem) { mList.add(0, userSelectPoiItem); } mAddressAdapter.setList(mList); mRecyclerView.smoothScrollToPosition(0); } } } @Override public void onGeocodeSearched(GeocodeResult geocodeResult, int i) { } }; // mAMapLocationListener = newAMapLocationListener() {
            @Override
            public void onLocationChanged(AMapLocation loc) {
                try {
                    if(null ! = loc) { stopLocation();if(Loc.geterrorCode () == 0) {// amapLocation can be parsed. location = loc; SPUtils.putString(MainActivity.this, DatasKey.LOCATION_INFO, gson.toJson(location));doWhenLocationSucess();
                        } else{// When locating a failure, you can determine the cause of the failure by ErrCode (error code). ErrInfo is an error message. For details, see the error code table. Log.e("AmapError"."location Error, ErrCode:"
                                    + loc.getErrorCode() + ", errInfo:"+ loc.getErrorInfo()); } } } catch (Exception ex) { ex.printStackTrace(); }}}; / / recycleview list listener mAddressAdapter. SetOnItemClickLisenter (newOnItemClickLisenter() {
            @Override
            public void onItemClick(int position) {
                try {
                    isSearchData = false; mIvLocation.setImageResource(R.mipmap.location_gps_black); moveMapCamera(mList.get(position).getLatLonPoint().getLatitude(), mList.get(position).getLatLonPoint().getLongitude()); refleshSelectByListMark(mList.get(position).getLatLonPoint().getLatitude(), mList.get(position).getLatLonPoint().getLongitude()); } catch (Exception ex) { ex.printStackTrace(); }}}); // mOnClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                switch (view.getId()) {
                    case R.id.iv_back:
                        finish();
                        break;
                    case R.id.iv_search:
//                        Toast.makeText(MainActivity.this, "Search", Toast.LENGTH_SHORT).show();
                        startActivityForResult(new Intent(MainActivity.this, SearchActivity.class), SEARCHREQUESTCODE);
                        break;
                    case R.id.iv_location:
//                        Toast.makeText(MainActivity.this, "Positioning", Toast.LENGTH_SHORT).show();
                        mIvLocation.setImageResource(R.mipmap.location_gps_green);
                        if(null ! = mSelectByListMarker) { mSelectByListMarker.setVisible(false);
                        }
                        if (null == location) {
                            startLocation();
                        } else {
                            doWhenLocationSucess();
                        }
                        break;
                    case R.id.bt_send:
                        if(null ! = mList && 0 < mList.size() && null ! = mAddressAdapter) { int position = mAddressAdapter.getSelectPositon();if (position < 0) {
                                position = 0;
                            } else if (position > mList.size()) {
                                position = mList.size();
                            }
                            PoiItem poiItem = mList.get(position);
                            Toast.makeText(MainActivity.this, "Send:" + poiItem.getTitle() + "" + poiItem.getSnippet() + "" + "Latitude:" + poiItem.getLatLonPoint().getLatitude() + "" + "Longitude:" + poiItem.getLatLonPoint().getLongitude(), Toast.LENGTH_SHORT).show();
                        }
                        break; }}}; mIvBack.setOnClickListener(mOnClickListener); mIvSearch.setOnClickListener(mOnClickListener); mIvLocation.setOnClickListener(mOnClickListener); mBtSend.setOnClickListener(mOnClickListener); } private void initDatas(Bundle savedInstanceState) { mMapView.onCreate(savedInstanceState); // This method must be overridden mAMap = mmapview.getmap (); mUiSettings = mAMap.getUiSettings(); mUiSettings.setZoomControlsEnabled(false); / / whether show the map zoom button mUiSettings setMyLocationButtonEnabled (false); / / display the default location button mUiSettings. SetScaleControlsEnabled (true); / / display zoom level mAMap. SetMyLocationEnabled (false); MList = new ArrayList<>(); mAddressAdapter = new AddressAdapter(this, mList); mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); mRecyclerView.setAdapter(mAddressAdapter); gson = new Gson(); mTransAnimator = ObjectAnimator.ofFloat(mIvCenterLocation,"translationY", 0f, -80f, 0f); mTransAnimator.setDuration(800); // mTransAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); } /** * initializes positioning */ private voidinitLocation() {
        if(null = = locationClient) {/ / initializes the client locationClient = new AMapLocationClient (enclosing getApplicationContext ()); / / set the position parameter locationClient. SetLocationOption (getDefaultOption ()); / / set positioning monitoring locationClient setLocationListener (mAMapLocationListener); } /** * The default positioning parameter */ private AMapLocationClientOptiongetDefaultOption() { AMapLocationClientOption mOption = new AMapLocationClientOption(); mOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); // Optional, set the location mode, the options are high precision, device only, network only. Default to high precision mode moption.setgpsFirst (false); // This parameter is optional. It takes effect only in high-precision mode. Moption. setHttpTimeOut(30000) is disabled by default. // Optional, set the network request timeout period. The default value is 30 seconds. Invalid in device-only mode moption.setInterval (2000); // Optional, set the positioning interval. Default is 2 seconds moption.setNeedAddress (true); // Optional, set whether to return the inverse geographic address information. The default istrue
        mOption.setOnceLocation(false); // This parameter is optional. The default isfalse
        mOption.setOnceLocationLatest(false); // Optional, set whether to wait for wifi refresh. The default value is falsetrue, will automatically into a single location for positioning. Don't use the AMapLocationClientOption setLocationProtocol (AMapLocationClientOption. AMapLocationProtocol. HTTP); // Optional, set the network request protocol. The value can be HTTP or HTTPS. Default is HTTP moption.setSensorenable (false); // Optional, set whether to use the sensor. The default isfalse
        mOption.setWifiScan(true); // Optional, set whether to enable WIFI scanning. The default istrueIf it is set tofalseMoption.setmockenable () moption.setMockenable (true); // If you want the location to be simulated, please passsetMockEnable(true); The allowed position simulation () method is enabledreturnmOption; } /** * start positioning */ public voidstartLocation() { initLocation(); / / set the position parameter locationClient. SetLocationOption (locationOption); / / start positioning locationClient startLocation (); } /** * stop positioning */ private voidstopLocation() {
        if(null ! = locationClient) { locationClient.stopLocation(); }} /** * What to do when positioning is successful */ private voiddoWhenLocationSucess() {
        isSearchData = false;
        userSelectPoiItem = DataConversionUtils.changeToPoiItem(location);
        doSearchQuery(true."", location.getCity(), new LatLonPoint(location.getLatitude(), location.getLongitude())); moveMapCamera(location.getLatitude(), location.getLongitude()); refleshLocationMark(location.getLatitude(), location.getLongitude()); } /** * move animation */ private voidstartTransAnimator() {
        if(null ! = mTransAnimator && ! mTransAnimator.isRunning()) { mTransAnimator.start(); }} /** * Move the map image to the longitude (moveCamera has no animation effect) ** @param latitude * @param longitude */ private void moveMapCamera(double)  latitude, double longitude) {if(null ! = mAMap) { mAMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), zoom)); }} /** * Refresh map tag location ** @param longitude */ private void refleshMark(double latitude, double longitude) {if (mMarker == null) {
            mMarker = mAMap.addMarker(new MarkerOptions()
                    .position(new LatLng(latitude, longitude))
                    .icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory
                            .decodeResource(getResources(), android.R.color.transparent)))
                    .draggable(true)); } mMarker.setPosition(new LatLng(latitude, longitude)); mAMap.invalidate(); } /** * Refresh map tag GPS longitude ** @param longitude */ private void refleshLocationMark(double latitude, double longitude) {if (mLocationGpsMarker == null) {
            mLocationGpsMarker = mAMap.addMarker(new MarkerOptions()
                    .position(new LatLng(latitude, longitude))
                    .icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory
                            .decodeResource(getResources(), R.mipmap.location_blue)))
                    .draggable(true)); } mLocationGpsMarker.setPosition(new LatLng(latitude, longitude)); mAMap.invalidate(); } /** * Refresh the map marker selected location ** @param longitude */ private void refleshSelectByListMark(double latitude, double longitude) {if(mSelectByListMarker == null) { mSelectByListMarker = mAMap.addMarker(new MarkerOptions() .position(new LatLng(latitude,  longitude)) .icon(BitmapDescriptorFactory.fromBitmap(BitmapFactory .decodeResource(getResources(), R.mipmap.location_red))) .draggable(true));
        }
        mSelectByListMarker.setPosition(new LatLng(latitude, longitude));
        if(! mSelectByListMarker.isVisible()) { mSelectByListMarker.setVisible(true); } mAMap.invalidate(); } /** * start POI search ** @param isReflsh whether to refresh data * @param keyWord * @param city * @param lpTemp */ protected voiddoSearchQuery(boolean isReflsh, String keyWord, String city, LatLonPoint lpTemp) {
        mQuery = new PoiSearch.Query(keyWord, "", city); // The first argument represents the search string, the second argument represents the POI search type, and the third argument represents the POI search area (empty string represents the country) mquery.setPagesize (30); // Set the maximum number of POiItems returned per pageif (isReflsh) {
            searchNowPageNum = 0;
        } else {
            searchNowPageNum++;
        }
        if (searchNowPageNum > searchAllPageNum) {
            return; } mQuery.setPageNum(searchNowPageNum); MPoiSearch = new PoiSearch(this, mQuery); mOnPoiSearchListener.IsReflsh(isReflsh); mPoiSearch.setOnPoiSearchListener(mOnPoiSearchListener);if(lpTemp ! = null) { mPoiSearch.setBound(new PoiSearch.SearchBound(lpTemp, 10000,true)); // The center of the range ----- radius, in meters ----- whether to sort by distance} mpoisearch.searchPoiasyn (); } /** * get the current address details by latitude and longitude, * * @param longitude */ private void getAddressInfoByLatLong(double latitude, double longitude) { GeocodeSearch geocodeSearch = new GeocodeSearch(this); /* point - The geographic coordinate point to reverse geocoding. Radius - Search scope. The default value is 1000. The value ranges from 1 to 3000 meters. LatLonType - Input parameter coordinate type. Contains GPS coordinates and High German coordinates. Can refer to RegeocodeQuery. SetLatLonType (String) * / RegeocodeQuery query = new RegeocodeQuery (new LatLonPoint (latitude, longitude), 3000, GeocodeSearch.AMAP); geocodeSearch.getFromLocationAsyn(query); geocodeSearch.setOnGeocodeSearchListener(mOnGeocodeSearchListener); } // Rewrite the Poi search listener, extensible pull-up load data, The drop-down refresh class onPoiSearchLintener implements PoiSearch. OnPoiSearchListener {private Boolean isReflsh; Public void IsReflsh(Boolean IsReflsh) {this. IsReflsh = IsReflsh; } @Override public void onPoiSearched(PoiResult result, int i) {if (i == 1000) {
                if(result ! = null && result.getQuery() ! = null) {searchAllPageNum = result.getPagecount ();if(result.getQuery().equals(mQuery)) {// Whether it is the sameif(isReflsh && null ! = mList) { mList.clear();if(null ! = userSelectPoiItem) { mList.add(0, userSelectPoiItem); } } mList.addAll(result.getPois()); // Get the poiitem data from the first page, starting with the number 0if(null ! = mAddressAdapter) { mAddressAdapter.setList(mList); mRecyclerView.smoothScrollToPosition(0); } } } } } @Override public void onPoiItemSearched(PoiItem poiItem, int i) { } } }Copy the code

Search page code

package com.weixin.location;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;

import com.amap.api.location.AMapLocation;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.core.PoiItem;
import com.amap.api.services.poisearch.PoiResult;
import com.amap.api.services.poisearch.PoiSearch;
import com.google.gson.Gson;
import com.weixin.location.adapter.SearchAddressAdapter;
import com.weixin.location.utils.DatasKey;
import com.weixin.location.utils.OnItemClickLisenter;
import com.weixin.location.utils.SPUtils;

import java.util.ArrayList;
import java.util.List;

public class SearchActivity extends AppCompatActivity {

    private ImageView mIvBack;
    private EditText mEtSearch;
    private RecyclerView mRecyclerView;
    private List<PoiItem> mList;
    private SearchAddressAdapter mSearchAddressAdapter;

    private PoiSearch mPoiSearch;
    private PoiSearch.Query mQuery;
    private PoiSearch.OnPoiSearchListener mOnPoiSearchListener;

    private View.OnClickListener mOnClickListener;
    private OnItemClickLisenter mOnItemClickLisenter;

    private Gson gson;
    public AMapLocation location;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);
        initView();
        initDatas();
        initListener();
    }

    @Override
    protected void onResume() {
        super.onResume();
        if(null == location) { String s = SPUtils.getString(this, DatasKey.LOCATION_INFO); // Get the saved location informationif(! TextUtils.isEmpty(s)) { try { location = gson.fromJson(s, AMapLocation.class); } catch (Exception ex) { ex.printStackTrace(); } } } } @Override public voidonBackPressed() {
        super.onBackPressed();
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if(null ! = mPoiSearch) { mPoiSearch = null; } } private voidinitView() {
        mIvBack = (ImageView) findViewById(R.id.iv_back);
        mEtSearch = (EditText) findViewById(R.id.et_search);
        mRecyclerView = (RecyclerView) findViewById(R.id.recyclerview);
    }

    private void initDatas() {
        mList = new ArrayList<>();
        mSearchAddressAdapter = new SearchAddressAdapter(this, mList);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.setAdapter(mSearchAddressAdapter);

        gson = new Gson();
    }

    private void initListener() {

        mOnClickListener = new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                switch (view.getId()) {
                    case R.id.iv_back:
                        finish();
                        break; }}}; mIvBack.setOnClickListener(mOnClickListener); mEtSearch.addTextChangedListener(newTextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                if(null ! = editable) {if(0 == editable. Length ()) {// Clear the search record without input mlist.clear (); mSearchAddressAdapter.setList(mList,"");
                    } else {
                        if(null ! = location) {doSearchQuery(editable.toString(), location.getCity(), new LatLonPoint(location.getLatitude(), location.getLongitude()));
                        } else {
                            doSearchQuery(editable.toString(), "", null); }}}}}); mOnItemClickLisenter = newOnItemClickLisenter() {
            @Override
            public void onItemClick(int position) {
                PoiItem poiItem = mList.get(position);
                if(null ! Intent Intent = new Intent(); intent.putExtra(DatasKey.SEARCH_INFO, poiItem);setResult(RESULT_OK, intent); finish(); }}}; mSearchAddressAdapter.setOnItemClickLisenter(mOnItemClickLisenter); mOnPoiSearchListener = new PoiSearch.OnPoiSearchListener() {
            @Override
            public void onPoiSearched(PoiResult result, int i) {
                if (i == 1000) {
                    if(result ! = null && result.getQuery() ! = null) {// The result of searching for poIif(result.getQuery().equals(mQuery)) {// Whether it is the sameif(null ! = mList) { mList.clear(); } mList.addAll(result.getPois()); // Get the poiitem data from the first page, starting with the number 0if(null ! = mSearchAddressAdapter) { mSearchAddressAdapter.setList(mList, mEtSearch.getText().toString().trim()); mRecyclerView.smoothScrollToPosition(0); } } } } } @Override public void onPoiItemSearched(PoiItem poiItem, int i) { } }; } /** * start the POI search */ protected voiddoSearchQuery(String keyWord, String city, LatLonPoint lpTemp) {
        mQuery = new PoiSearch.Query(keyWord, "", city); // The first argument represents the search string, the second argument represents the POI search type, and the third argument represents the POI search area (empty string represents the country) mquery.setPagesize (20); // Set the maximum number of poiItem returns per page. Mquery.setpagenum (0); MPoiSearch = new PoiSearch(this, mQuery); mPoiSearch.setOnPoiSearchListener(mOnPoiSearchListener);if(lpTemp ! = null) { mPoiSearch.setBound(new PoiSearch.SearchBound(lpTemp, 10000,true)); // The center of the range ----- radius, in meters ----- whether to sort by distance} mpoisearch.searchPoiasyn (); // async search}}Copy the code

The end of the

For more details, please head over to my Github for masturbation

Github.com/xiaofuchen/…

It is a virtue of the Chinese people to give Stars freely

thank you