zoukankan      html  css  js  c++  java
  • 百度地图二(我的位置和覆盖物)


    在上篇中的mainActitvity中加入

    private boolean isFirstLocate = true;
    //        地图显示位置
    mMapView = (MapView) findViewById(R.id.map_view);
    mBaiduMap = mMapView.getMap();
    // 开启显示我的位置
    mBaiduMap.setMyLocationEnabled(true);
        private void navigateTo(BDLocation location){

    LatLng point = new LatLng(location.getLatitude()+0.12,location.getLongitude()+0.12);
    // 显示所在位置
    if (isFirstLocate){
    LatLng ll = new LatLng(location.getLatitude(),location.getLongitude());
    MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(ll);
    mBaiduMap.animateMapStatus(update);
    update = MapStatusUpdateFactory.zoomTo(16f);
    mBaiduMap.animateMapStatus(update);
    isFirstLocate = false;
    }
    // 显示我的位置标识
    MyLocationData.Builder locationBuilder = new MyLocationData.Builder();
    locationBuilder.latitude(location.getLatitude());
    locationBuilder.longitude(location.getLongitude());
    MyLocationData locationData = locationBuilder.build();
    mBaiduMap.setMyLocationData(locationData);

    // 覆盖物的编写
    // //构建Marker图标
    // BitmapDescriptor bitmap = BitmapDescriptorFactory
    // .fromResource(R.drawable.apple);
    // OverlayOptions options = new MarkerOptions()
    // .position(point)// 设置marker的位置
    // .icon(bitmap)// 设置marker的图标
    // .zIndex(9)// 設置marker的所在層級
    // .draggable(true);// 设置手势拖拽
    // // 在地图上添加marker,并显示
    // mBaiduMap.addOverlay(options);
    }
    if (bdLocation.getLocType()==BDLocation.TypeGpsLocation){
    currentPostion.append("GPS");
    navigateTo(bdLocation);
    }else if (bdLocation.getLocType()==BDLocation.TypeNetWorkLocation){
    currentPostion.append("网络");
    navigateTo(bdLocation);
    }
  • 相关阅读:
    集合——iterator迭代器
    集合——顶层collection接口(单列集合)
    集合——集合框架
    构造方法
    接口作为方法的参数或返回值——List接口
    接口作为成员变量——实现类和匿名内部类和匿名对象
    距离和相似度度量
    Kmeans算法与KNN算法的区别
    linux命令
    MapReduce初级案例
  • 原文地址:https://www.cnblogs.com/tflike/p/9453284.html
Copyright © 2011-2022 走看看