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);
    }
  • 相关阅读:
    获取指定<文字行数>的<高度>是多少 TextKit
    JS 与 OC 交互
    PHP-note
    MySQL函数
    freeSWITCH之多平台测试通信
    freeSWITCH之安装
    PHP面向对象
    MySQL Optimization 优化原理
    理解常量指针与指针常量?
    InterView之PHP(2)
  • 原文地址:https://www.cnblogs.com/tflike/p/9453284.html
Copyright © 2011-2022 走看看