• Android LBS 百度地图(参考: 《第一行代码》第2版(郭霖)11.3.2 确定自己位置的经纬度:准确数字信息)


    昨天自己琢磨了几个小时,左冲右突,实验没成功。http://www.cnblogs.com/hbuwyg/p/7062285.html

    计划按照郭老师的《第一行代码》教程再试一次。

    前面的测试虽然没有成功,但积累了不少知识,看书轻松许多~


    Android 2.3.3 / Windows 10 / AS自带jdk


    11.2 申请API key 

    11.3 使用百度定位

    11.3.1 准备LBS SDK(书上写的很细节,提醒到位,的确是入门者的好书)


    11.3.2 确定自己位置的经纬度

    例题中百度地图函数有更新,需增加代码。 Ref:https://zhidao.baidu.com/question/366087251460718692.html 

    更新太快,书出来,好多东西已经变了,必须参考最新代码,还好网络强大。Ref:http://blog.csdn.net/fkq_2016/article/details/72818356?locationNum=13&fps=1

    一定要用流行书,网上一起学习的人多,能互相帮助。

    public class MylocationListener implements BDLocationListener{
            @Override
            public  void onReceiveLocation(BDLocation location){
                final StringBuilder currentPosition = new StringBuilder();
                currentPosition.append("Altitude:").append(location.getAltitude()).append("
    ");
                Log.d("map Altitude",location.getAltitude()+"");
                currentPosition.append("Longitude:").append(location.getLongitude()).append("
    ");
                Log.d("map Longitude",location.getLongitude()+"");
                currentPosition.append("Locate Mode:");
                if(location.getLocType() == BDLocation.TypeGpsLocation){
                    currentPosition.append("GPS");
                    Log.d("map GPS","GPS");
                }else  if (location.getLocType() == BDLocation.TypeNetWorkLocation){
                    currentPosition.append("NET");
                    Log.d("map NET","NET");
                }else
                {
                    currentPosition.append("eMulator");
                }
                Log.d("map CurrentPosition",currentPosition.toString());
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        positionText.setText(currentPosition);
                    }
                });
                Log.d("map CurrentPosition","END");
            }
            @Override
            public void onConnectHotSpotMessage(String s, int i) {
    
            }
        }

     

  • 相关阅读:
    hdu 1174
    计算几何模板
    又是一年博客记
    hdu 1225 Football Score
    与逆序数有关的
    hdu 2844 Coins
    hdu 1171 Big Event in HDU
    UVA Exponentiation
    UVA Summation of Four Primes
    Linux:设置alias永久生效
  • 原文地址:https://www.cnblogs.com/hbuwyg/p/7068897.html
Copyright © 2020-2023  润新知