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);
             }
         });
        }
      }
  • 相关阅读:
    SQL Server 2005 中的同义词
    SQL SERVER 2005中同义词实例
    聚集索引和非聚集索引(整理)
    linux kernel中timer的使用
    linux命令: patch
    win7(64位)php5.5-Apache2.4-mysql5.6环境安装
    tasklet和工作队列
    linux串口编程(c)
    Notepad++中Windows,Unix,Mac三种格式
    centos7/redhat7 将网卡名字改成eth样式的方法
  • 原文地址:https://www.cnblogs.com/xiaohaigege666/p/12266566.html
Copyright © 2011-2022 走看看