zoukankan      html  css  js  c++  java
  • 石家庄停车位在线预约平台05

    安卓定位:具体位置显示

    由于只看经纬度我们无法一下子知道自己的具体位置,所以引入具体位置显示。只需要修改MainActivity.java即可。
    修改部分:
    (1)、先是调用了setIsNeedAddress传入true,表示我们需要获取当前具体的位置

    private void initLocation() {
            LocationClientOption option = new LocationClientOption();
            option.setScanSpan(5000);
           // option.setLocationMode(LocationClientOption.LocationMode.Device_Sensors);
            option.setIsNeedAddress(true);
            mLocationClient.setLocOption(option);
        }

    (2)、调用getProvince、getCity等函数获得具体的位置信息。

    public class MyLocationListener implements BDLocationListener {
         @Override
         public void onReceiveLocation(final BDLocation location) {
            runOnUiThread(new Runnable() {
             @Override
             public void run() {
                currentPosition = new StringBuilder();
                currentPosition.append("纬度:").append(location.getLatitude()).append("
    ");
                currentPosition.append("经度:").append(location.getLongitude()).append("
    ");
                currentPosition.append("国家:").append(location.getCountry()).append("
    ");
                currentPosition.append("省:").append(location.getProvince()).append("
    ");
                currentPosition.append("市:").append(location.getCity()).append("
    ");
                currentPosition.append("区:").append(location.getDistrict()).append("
    ");
                currentPosition.append("街道:").append(location.getStreet()).append("
    ");
                currentPosition.append("定位方式:");
                if (location.getLocType() == BDLocation.TypeGpsLocation) {
                    currentPosition.append("GPS");
                } else if (location.getLocType() == BDLocation.TypeNetWorkLocation) {
                    currentPosition.append("网络");
                }
                positionText.setText(currentPosition);
             }
         });
        }
      }
  • 相关阅读:
    二叉搜索查找排序树
    多项式运算
    赫夫曼编码及应用
    利用python画出动态高优先权优先调度
    利用python画出SJF调度图
    支持向量机
    fisher线性分类器
    Codeforces Round #520 (Div. 2)
    Codeforces Round #510 (Div. 2)
    Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
  • 原文地址:https://www.cnblogs.com/xiaohaigege666/p/12266566.html
Copyright © 2011-2022 走看看