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);
    }
  • 相关阅读:
    qt的.pro配置总结
    【GOJ 1489】Monster Hunter
    CPU 杂谈
    【CF 1061C|GOJ 3505】Multiplicity
    【CF 1039D|GOJ 3502】You Are Given a Tree
    我跳过的坑
    【CF 1101D|GOJ 3501】GCD Counting
    【HDU 5269|GOJ 739】xor的最低位
    beta阶段组间的140字互评
    【第七周】【新蜂站会】3
  • 原文地址:https://www.cnblogs.com/tflike/p/9453284.html
Copyright © 2011-2022 走看看