Java 类com.baidu.mapapi.map.MyLocationData 实例源码

项目:SmartButler    文件:LocationActivity.java   
private void moveToMe(BDLocation location)
{
    MapStatusUpdate mapUpdate=MapStatusUpdateFactory.zoomTo(18);
    baiduMap.setMapStatus(mapUpdate);
    //开始移动
    MapStatusUpdate mapLatlng=MapStatusUpdateFactory.newLatLng(new LatLng(location.getLatitude(),location.getLongitude()));
    baiduMap.setMapStatus(mapLatlng);
    //显示我的位置
    MyLocationData.Builder locationBuilder=new MyLocationData.Builder();
    locationBuilder.latitude(location.getLatitude());
    locationBuilder.longitude(location.getLongitude());
    MyLocationData locationData=locationBuilder.build();
    baiduMap.setMyLocationData(locationData);
    //显示用户所在地附近
    Toast.makeText(this,"您当前在"+location.getAddrStr()+"附近",Toast.LENGTH_SHORT).show();
}
项目:MaterialLearning    文件:BaiduMapActivity.java   
public void navigateTo(BDLocation location){
    if(isFirstLocate){
        LatLng latLng=new LatLng(location.getLatitude(),location.getLongitude());
        showToast("定位到当前位置已执行");

        MapStatusUpdate    update=MapStatusUpdateFactory.zoomTo(8f);
        baiduMap.animateMapStatus(update);
        update= MapStatusUpdateFactory.newLatLng(latLng);
        baiduMap.animateMapStatus(update);

       isFirstLocate=false;
    }
    MyLocationData.Builder locationBuilder=new MyLocationData.Builder();
    locationBuilder.latitude(location.getLatitude());
    locationBuilder.longitude(location.getLongitude());
    baiduMap.setMyLocationData(locationBuilder.build());

}
项目:wzyx-android-user    文件:BaiduMapActivity.java   
@Override
public void onReceiveLocation(BDLocation bdLocation) {
    mLastLocationData=bdLocation;
    MyLocationData myLocationData=new MyLocationData.Builder()
            .accuracy(bdLocation.getRadius())
            .latitude(bdLocation.getLatitude())
            .longitude(bdLocation.getLongitude())
            .build();
    mBaiduMap.setMyLocationData(myLocationData);
    MapStatusUpdate msu1 = MapStatusUpdateFactory.zoomTo(15.0f);
    mBaiduMap.setMapStatus(msu1);

    if(isFirstIn){
        LatLng ll=new LatLng(bdLocation.getLatitude(),bdLocation.getLongitude());
        MapStatusUpdate msu=MapStatusUpdateFactory.newLatLng(ll);
        mBaiduMap.setMapStatus(msu);
        isFirstIn=false;
    }
}
项目:GCSApp    文件:LocationDemo.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null) {
        return;
    }
    mCurrentLat = location.getLatitude();
    mCurrentLon = location.getLongitude();
    mCurrentAccracy = location.getRadius();
    locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
            // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(mCurrentDirection).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);
    if (isFirstLoc) {
        isFirstLoc = false;
        LatLng ll = new LatLng(location.getLatitude(),
                location.getLongitude());
        MapStatus.Builder builder = new MapStatus.Builder();
        builder.target(ll).zoom(18.0f);
        mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
    }
}
项目:Mobike    文件:MainActivity.java   
/**
 * des:地图跳到指定位置
 *
 * @param location
 */
private void navigateTo(BDLocation location) {
    if (isFirstLocation) {
        LatLng ll = new LatLng(location.getLatitude(), location.getLongitude());
        MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(ll);
        baiduMap.animateMapStatus(update);
        update = MapStatusUpdateFactory.zoomTo(18f);
        baiduMap.animateMapStatus(update);
        isFirstLocation = false;
    }
    MyLocationData.Builder builder = new MyLocationData.Builder();
    builder.latitude(location.getLatitude());
    builder.longitude(location.getLongitude());
    MyLocationData data = builder.build();
    baiduMap.setMyLocationData(data);
}
项目:MapLocation    文件:MainActivity.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null) {
        return;
    }
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
            // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);
    if (isFirstLoc) {
        isFirstLoc = false;
        LatLng ll = new LatLng(location.getLatitude(),
                location.getLongitude());
        applicate=(Myapplication)getApplication();
        applicate.setLon(location.getLongitude());
        applicate.setLat(location.getLatitude());
        MapStatus.Builder builder = new MapStatus.Builder();
        builder.target(ll).zoom(18.0f);
        mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
    }
}
项目:Tower-develop    文件:BaiduMapFragment.java   
private void updateBDMapStatus(BDLocation location) {
    final BaiduMap map = getBaiduMap();
    final BaiduMapPrefFragment provider = (BaiduMapPrefFragment)(getProvider().getMapProviderPreferences());
    final Context context = getActivity().getApplicationContext();

    int mapType = provider.getMapType(context);
    map.setMapType(mapType);

    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
            .latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    map.setMyLocationData(locData);

    LatLng ll = new LatLng(location.getLatitude(), location.getLongitude());
    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
    map.animateMapStatus(u);
}
项目:MyApp    文件:fragment1.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mapView == null) {
        return;
    }
    tvLocation.setText(location.getAddrStr());
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
            // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);
    if (isFirstLoc) {
        isFirstLoc = false;
        LatLng ll = new LatLng(location.getLatitude(),
                location.getLongitude());
        MapStatus.Builder builder = new MapStatus.Builder();
        builder.target(ll).zoom(18.0f);
        mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
    }
}
项目:droidplanner-master    文件:BaiduMapFragment.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null)
        return;
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
                    // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    getBaiduMap().setMyLocationData(locData);

    LatLong latlong = DroneHelper.BDLocationToCoord(locData);
    if (mPanMode.get() == AutoPanMode.USER) {
        updateCamera(latlong, (int) getBaiduMap().getMapStatus().zoom);
    }

    if (mLocationListener != null) {
        Location loc = new Location(new Coord2D(latlong.getLatitude(),latlong.getLongitude()),locData.direction,locData.speed,locData.satellitesNum>3);
        mLocationListener.onLocationChanged(loc);
    }


}
项目:nongfei-missionplane    文件:BaiduMapFragment.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null)
        return;
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
                    // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    getBaiduMap().setMyLocationData(locData);

    LatLong latlong = DroneHelper.BDLocationToCoord(locData);
    if (mPanMode.get() == AutoPanMode.USER) {
        updateCamera(latlong, (int) getBaiduMap().getMapStatus().zoom);
    }

    if (mLocationListener != null) {
        Location loc = new Location(new Coord2D(latlong.getLatitude(),latlong.getLongitude()),locData.direction,locData.speed,locData.satellitesNum>3);
        mLocationListener.onLocationChanged(loc);
    }


}
项目:Mooc-map    文件:RoutePlan.java   
@Override
public void onReceiveLocation(BDLocation location) {
    MyLocationData data2 = new MyLocationData.Builder()
            .accuracy(location.getRadius())//精度
            .latitude(location.getLatitude())//纬度
            .longitude(location.getLongitude()).build();//经度
    mBaidumap.setMyLocationData(data2);
    //第三个参数设置自定义图标
    MyLocationConfiguration config =
            new MyLocationConfiguration(null, true, null);
    mBaidumap.setMyLocationConfigeration(config);
    //更新经纬度
    mLatitude = location.getLatitude();
    mLongtitude = location.getLongitude();
    if (isFirstIn) {
        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng);
        mBaidumap.animateMapStatus(msu);
        isFirstIn = false;
    }
}
项目:Mooc-map    文件:MyLocationListener.java   
@Override
public void onReceiveLocation(BDLocation location) {
    MyLocationData data = new MyLocationData.Builder()
            .direction(100)//方向
            .accuracy(location.getRadius())//精度
            .latitude(location.getLatitude())//纬度
            .longitude(location.getLongitude()).build();//经度
    mBaiduMap.setMyLocationData(data);
    MyLocationConfiguration config =
            new MyLocationConfiguration(null, true, null);
    mBaiduMap.setMyLocationConfigeration(config);
    //更新经纬度
    mLatitude = location.getLatitude();
    mLongtitude = location.getLongitude();
    if (isFirstIn) {
        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng);
        mBaiduMap.animateMapStatus(msu);
        isFirstIn = false;
    }
}
项目:Mooc-map    文件:MainActivity.java   
@Override
public void onReceiveLocation(BDLocation location) {
    MyLocationData data = new MyLocationData.Builder()
            .direction(mCurrentX)//更新当前方向
            .accuracy(400.0f)//精度
            .latitude(location.getLatitude())//纬度
            .longitude(location.getLongitude()).build();//经度
    mBaiduMap.setMyLocationData(data);
    //可在第三个参数设置自定义图标
    MyLocationConfiguration config =
            new MyLocationConfiguration(mLocationMode, true, null);
    mBaiduMap.setMyLocationConfigeration(config);
    //更新经纬度
    mLatitude = location.getLatitude();
    mLongtitude = location.getLongitude();
    mCity = location.getCity();
    if (isFirstIn) {
        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng);
        mBaiduMap.animateMapStatus(msu);
        isFirstIn = false;
        Toast.makeText(context, location.getAddrStr(), Toast.LENGTH_SHORT).show();
    }
}
项目:Mooc-map    文件:BusLineSearch.java   
@Override
public void onReceiveLocation(BDLocation location) {
    MyLocationData data = new MyLocationData.Builder()
            .accuracy(location.getRadius())//精度
            .latitude(location.getLatitude())//纬度
            .longitude(location.getLongitude()).build();//经度
    mBaiduMap.setMyLocationData(data);
    //可在第三个参数设置自定义图标
    MyLocationConfiguration config =
            new MyLocationConfiguration(null, true, null);
    mBaiduMap.setMyLocationConfigeration(config);
    //更新经纬度
    mLatitude = location.getLatitude();
    mLongtitude = location.getLongitude();
    if (isFirstIn) {
        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng);
        mBaiduMap.animateMapStatus(msu);
        isFirstIn = false;
    }
}
项目:PiBoat    文件:SmallBaiduMap.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null)
        return;
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
                    // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);
    if (isFirstLoc) {
        isFirstLoc = false;
        LatLng ll = new LatLng(location.getLatitude(),
                location.getLongitude());
        MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
        mBaiduMap.animateMapStatus(u);
    }
}
项目:BMap    文件:LocationDemo.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null)
        return;
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
            // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);
    if (isFirstLoc) {
        isFirstLoc = false;
        LatLng ll = new LatLng(location.getLatitude(),
                location.getLongitude());
        MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
        mBaiduMap.animateMapStatus(u);
    }
}
项目:BMap    文件:MainActivity.java   
@Override
        public void onReceiveLocation(BDLocation location) {
            // map view 销毁后不在处理新接收的位置
            if (location == null || mMapView == null)
                return;
            MyLocationData locData = new MyLocationData.Builder()
                    .accuracy(location.getRadius())
                            // 此处设置开发者获取到的方向信息,顺时针0-360
                    .direction(100).latitude(location.getLatitude())
                    .longitude(location.getLongitude()).build();
            mBaiduMap.setMyLocationData(locData);
            if (isFirstLoc) {
                isFirstLoc = false;
                LatLng ll = new LatLng(location.getLatitude(),
                        location.getLongitude());
                MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
                mBaiduMap.animateMapStatus(u);
//                StringBuffer U = new StringBuffer(256);
//                U.append(location.getLatitude());
//                U.append(location.getLongitude());
            }
        }
项目:FrontOne    文件:MapFragment.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view ��ٺ��ڴ����½��յ�λ��
    if (location == null || mMapView == null)
        return;
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
            // �˴����ÿ����߻�ȡ���ķ�����Ϣ��˳ʱ��0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);
    if(isFirstLoc){
        isFirstLoc = false;
        LatLng ll = new LatLng(location.getLatitude(),
                location.getLongitude());
        MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
        mBaiduMap.animateMapStatus(u);
    }
}
项目:Gprs_droidplanner    文件:BaiduMapFragment.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null)
        return;
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
                    // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    getBaiduMap().setMyLocationData(locData);

    LatLong latlong = DroneHelper.BDLocationToCoord(locData);
    if (mPanMode.get() == AutoPanMode.USER) {
        updateCamera(latlong, (int) getBaiduMap().getMapStatus().zoom);
    }

    if (mLocationListener != null) {
        Location loc = new Location(new Coord2D(latlong.getLatitude(),latlong.getLongitude()),locData.direction,locData.speed,locData.satellitesNum>3);
        mLocationListener.onLocationChanged(loc);
    }


}
项目:eDao    文件:MapActivity.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null)
        return;
    curMapCenterLatLng = mBaiduMap.getMapStatus().target;
    mCurrentLantitude = location.getLatitude();
    mCurrentLongitude = location.getLongitude();
    curCity = location.getCity();
    textView_curCity.setText(curCity);
    MyLocationData locData = new MyLocationData.Builder().accuracy(location.getRadius())
            // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(mCurrentLantitude).longitude(mCurrentLongitude).build();
    // 设置定位数据
    mBaiduMap.setMyLocationData(locData);
    if (isFirstLoc) {
        isFirstLoc = false;
        LatLng ll = new LatLng(mCurrentLantitude, mCurrentLongitude);
        MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
        mBaiduMap.animateMapStatus(u);
        getData();
    }

}
项目:crabapple    文件:StepRelateFragment.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null)
        return;
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
            // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);
    if (isFirstLoc) {
        isFirstLoc = false;
        lat = location.getLatitude();
        lng = location.getLongitude();
        LatLng ll = new LatLng(lat, lng);
        MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
        mBaiduMap.animateMapStatus(u);
    }
}
项目:GitHub    文件:MainActivity.java   
@Override
public void onReceiveLocation(BDLocation bdLocation) {
    // map view 销毁后不在处理新接收的位置
    if (bdLocation == null || mMapView == null) {
        return;
    }
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(bdLocation.getRadius())
            .direction(mCurrentX)//设定图标方向     // 此处设置开发者获取到的方向信息,顺时针0-360
            .latitude(bdLocation.getLatitude())
            .longitude(bdLocation.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);
    currentLatitude = bdLocation.getLatitude();
    currentLongitude = bdLocation.getLongitude();
    current_addr.setText(bdLocation.getAddrStr());
    currentLL = new LatLng(bdLocation.getLatitude(),
            bdLocation.getLongitude());
    LocationManager.getInstance().setCurrentLL(currentLL);
    LocationManager.getInstance().setAddress(bdLocation.getAddrStr());
    startNodeStr = PlanNode.withLocation(currentLL);
    //option.setScanSpan(5000),每隔5000ms这个方法就会调用一次,而有些我们只想调用一次,所以要判断一下isFirstLoc
    if (isFirstLoc) {
        isFirstLoc = false;
        LatLng ll = new LatLng(bdLocation.getLatitude(),
                bdLocation.getLongitude());
        MapStatus.Builder builder = new MapStatus.Builder();
        //地图缩放比设置为18
        builder.target(ll).zoom(18.0f);
        mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
        changeLatitude = bdLocation.getLatitude();
        changeLongitude = bdLocation.getLongitude();
        if (!isServiceLive) {
            addOverLayout(currentLatitude, currentLongitude);
        }
    }
}
项目:AndroidBookTest    文件:MainActivity.java   
private void navigateTo(BDLocation location){
    if (isFirstLocate){
        LatLng ll=new LatLng(location.getLatitude(),location.getLongitude());
        MapStatusUpdate mapStatus=MapStatusUpdateFactory.newLatLngZoom(ll,16f);
        baiduMap.setMapStatus(mapStatus);
        isFirstLocate=false;
    }
    MyLocationData.Builder locationBuilder=new MyLocationData.Builder();
    locationBuilder.latitude(location.getLatitude());
    locationBuilder.longitude(location.getLongitude());
    MyLocationData locationData=locationBuilder.build();
    baiduMap.setMyLocationData(locationData);
}
项目:ywApplication    文件:BdLocationActivity.java   
@Override
public void onReceiveLocation(BDLocation location) {
    MyLocationData data = new MyLocationData.Builder()// 经度
            .accuracy(location.getRadius())//
            .latitude(location.getLatitude())//
            .longitude(location.getLongitude())//
            .build();

    //设置我的定位
    mbaiduMap.setMyLocationData(data);

    //取出经纬度
    mLatitude = location.getLatitude();
    mLongitude = location.getLongitude();

    //是否是第一次定位
    if (isFirstIn) {
        LatLng latLng = new LatLng(location.getLatitude(),
                location.getLongitude());

        // 设置经纬度
        MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng);

        mbaiduMap.animateMapStatus(msu);

        isFirstIn = false;
    }

    Toast.makeText(
            context,
            "定位成功:纬度" + location.getLatitude() + "经度:"
                    + location.getLongitude() + "地址是:"
                    + location.getAddrStr() + "城市是:" + location.getCity(), Toast.LENGTH_SHORT).show();

}
项目:MapDemo    文件:MainActivity.java   
@Override
public void onReceiveLocation(BDLocation location) {
    MyLocationData data = new MyLocationData.Builder()//
            .direction(mCurrentX)//
            .accuracy(location.getRadius())//
            .latitude(location.getLatitude())//
            .longitude(location.getLongitude())//
            .build();
    mbaiduMap.setMyLocationData(data);

    // 设置自定义图标
    MyLocationConfiguration config = new MyLocationConfiguration(
            locationmode, true, mIconLocation);
    mbaiduMap.setMyLocationConfigeration(config);

    // 获取经度、纬度
    mLongitude = location.getLongitude();
    mLatitude = location.getLatitude();
    // 当前的位置为开始位置。
    mStartLocation = new LatLng(location.getLatitude(),
            location.getLongitude());

    if (isFirstIn) {
        LatLng latLng = new LatLng(location.getLatitude(),
                location.getLongitude());
        MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng);
        mbaiduMap.animateMapStatus(msu);
        isFirstIn = false;
        Toast.makeText(context, location.getAddrStr(),
                Toast.LENGTH_LONG).show();
    }

}
项目:GCSApp    文件:LocationDemo.java   
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
    double x = sensorEvent.values[SensorManager.DATA_X];
    if (Math.abs(x - lastX) > 1.0) {
        mCurrentDirection = (int) x;
        locData = new MyLocationData.Builder()
                .accuracy(mCurrentAccracy)
                // 此处设置开发者获取到的方向信息,顺时针0-360
                .direction(mCurrentDirection).latitude(mCurrentLat)
                .longitude(mCurrentLon).build();
        mBaiduMap.setMyLocationData(locData);
    }
    lastX = x;

}
项目:Mobike    文件:MainActivity.java   
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQS_LOCATION:
            if (RESULT_OK == resultCode) {
                PoiObject info = (PoiObject) data.getSerializableExtra("PoiObject");
                Logger.d(info);
                LatLng latLng = new LatLng(Double.parseDouble(info.lattitude),
                        Double.parseDouble(info.longitude));
                isNeedCurrentlocation = false;
                MyLocationData.Builder builder = new MyLocationData.Builder();
                builder.latitude(latLng.latitude);
                builder.longitude(latLng.longitude);
                MyLocationData build = builder.build();
                baiduMap.setMyLocationData(build);
                //                    MapStatusUpdate msu = MapStatusUpdateFactory.newLatLng(latLng);
                //                    baiduMap.setMapStatus(msu);
                if (routeOverlay != null)
                    routeOverlay.removeFromMap();
                addOverLayout(latLng.latitude, latLng.longitude);
            }
            break;
        case REQS_UNLOCK:
            if (RESULT_OK == resultCode) {
                ToastUtils.show(MainActivity.this, data.getStringExtra("result"));
                beginService();
            }

            break;
    }
}
项目:Mobike    文件:MainActivity.java   
@Override
public void onReceiveLocation(BDLocation bdLocation) {
    if (bdLocation == null || baiduMap == null) {
        return;
    }
    mBDLocation = bdLocation;
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(bdLocation.getRadius())
            .direction(mCurrentX)//设定图标方向     // 此处设置开发者获取到的方向信息,顺时针0-360
            .latitude(bdLocation.getLatitude())
            .longitude(bdLocation.getLongitude()).build();
    if (isNeedCurrentlocation)
        baiduMap.setMyLocationData(locData);
    currentLatitude = bdLocation.getLatitude();
    currentLongitude = bdLocation.getLongitude();
    mTvLocationInfo.setText(bdLocation.getAddrStr());
    currentLL = new LatLng(bdLocation.getLatitude(),
            bdLocation.getLongitude());
    MyLocationManager.getInstance().setCurrentLL(currentLL);
    MyLocationManager.getInstance().setAddress(bdLocation.getAddrStr());
    startNodeStr = PlanNode.withLocation(currentLL);
    //option.setScanSpan(5000),每隔5000ms这个方法就会调用一次,而有些我们只想调用一次,所以要判断一下isFirstLoc
    if (isFirstLocation) {
        isFirstLocation = false;
        LatLng ll = new LatLng(bdLocation.getLatitude(),
                bdLocation.getLongitude());
        MapStatus.Builder builder = new MapStatus.Builder();
        //地图缩放比设置为18
        builder.target(ll).zoom(18.0f);
        baiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
        changeLatitude = bdLocation.getLatitude();
        changeLongitude = bdLocation.getLongitude();
        if (!isServiceLive) {
            addOverLayout(currentLatitude, currentLongitude);
        }
    }
}
项目:LBSTest    文件:MainActivity.java   
private void navigateTo(BDLocation location){
    if (isFirstLocate){
        LatLng ll = new LatLng(location.getLatitude(),location.getLongitude());
        MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(ll);
        baiduMap.animateMapStatus(update);
        update = MapStatusUpdateFactory.zoomTo(16f);
        baiduMap.animateMapStatus(update);
        isFirstLocate = false;
    }
    MyLocationData.Builder locationBuilder = new MyLocationData.Builder();
    locationBuilder.latitude(location.getLatitude());
    locationBuilder.longitude(location.getLongitude());
    MyLocationData locationData = locationBuilder.build();
    baiduMap.setMyLocationData(locationData);
}
项目:camera    文件:MainActivity.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    Log.d("wang","onReceiveLocation successfully");
    if (location == null || mMapView == null) {
        return;
    }
    Log.d("wang","onReceiveLocation location is null");
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
                    // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);
    //mMapView.refreshDrawableState();
    if(latArray.size() != 0) {
        float[] distance = new float[1];
        for(int i = 0; i < latArray.size();i++) {
            LatLng loc = latArray.get(i);
            Location.distanceBetween(loc.latitude, loc.longitude, location.getLatitude(), location.getLongitude(), distance);
            Log.d("wang","distance is " + distance[0]);
            if(distance[0] <= 2000.0){
                toast("2000 distance is bigger " + Math.round(distance[0]));
                tts.speak("距离标记位置" + i + "还有" + Math.round(distance[0]) + "米", TextToSpeech.QUEUE_ADD, null);
            } else {
                //toast("200 distance is smaller " + distance[0]);
            }
        }
    }
    if (isFirstLoc) {
        isFirstLoc = false;
        LatLng ll = new LatLng(location.getLatitude(),
                location.getLongitude());
        MapStatus.Builder builder = new MapStatus.Builder();
        builder.target(ll).zoom(18.0f);
        mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
    }
}
项目:HelloAndroid    文件:BaiduMapUsageActivity.java   
private void navigateTo(BDLocation bdLocation) {
    if (mIsFirstLocate) {
        LatLng ll = new LatLng(bdLocation.getLatitude(), bdLocation.getLongitude());
        MapStatusUpdate mapStatusUpdate = MapStatusUpdateFactory.newLatLng(ll);
        mBaiduMap.animateMapStatus(mapStatusUpdate);
        mapStatusUpdate = MapStatusUpdateFactory.zoomTo(16.5f);
        mBaiduMap.animateMapStatus(mapStatusUpdate);
        mIsFirstLocate = false;     //防止多次调用animateMapStatus方法
    }
    MyLocationData.Builder myLocationDataBuilder = new MyLocationData.Builder();
    myLocationDataBuilder.latitude(bdLocation.getLatitude());
    myLocationDataBuilder.longitude(bdLocation.getLongitude());
    MyLocationData myLocationData = myLocationDataBuilder.build();
    mBaiduMap.setMyLocationData(myLocationData);
}
项目:MapForTour    文件:MapFragment.java   
public void setBaiduMapLocationData(MyLocationData locData) {
    baiduMap.setMyLocationData(locData);
    if (isFirstLocate) {
        MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(application.getLatLng(), application.getMaxZoomLevel() - 2);
        baiduMap.animateMapStatus(u);//动画移动摄像头
        isFirstLocate = false;
    }
    Log.d("lml", "MapFragment - 设置一次位置");
}
项目:enjoychat    文件:LocationActivity.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view ���ٺ��ٴ����½��յ�λ��
    if (location == null || mMapView == null)
        return;

    if (lastLocation != null) {
        if (lastLocation.getLatitude() == location.getLatitude()
                && lastLocation.getLongitude() == location.getLongitude()) {
            BmobLog.i("��ȡ������ͬ");// �����������ȡ���ĵ���λ����������ͬ�ģ����ٶ�λ
            mLocClient.stop();
            return;
        }
    }
    lastLocation = location;

    BmobLog.i("lontitude = " + location.getLongitude() + ",latitude = "
            + location.getLatitude() + ",��ַ = "
            + lastLocation.getAddrStr());

    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
            // �˴����ÿ����߻�ȡ���ķ�����Ϣ��˳ʱ��0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);
    LatLng ll = new LatLng(location.getLatitude(),location.getLongitude());
    String address = location.getAddrStr();
    if (address != null && !address.equals("")) {
        lastLocation.setAddrStr(address);
    } else {
        // ��Geo����
        mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(ll));
    }
    // ��ʾ�ڵ�ͼ��
    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
    mBaiduMap.animateMapStatus(u);
    //���ð�ť�ɵ��
    mHeaderLayout.getRightImageButton().setEnabled(true);
}
项目:droidplanner-master    文件:BaiduMapFragment.java   
@Override
public void zoomToFitMyLocation(final List<LatLong> coords) {
    MyLocationData locationData = getBaiduMap().getLocationData();
    if (locationData != null) {
        final List<LatLong> updatedCoords = new ArrayList<LatLong>(coords);
        updatedCoords.add(DroneHelper.BDLocationToCoord(locationData));
        zoomToFit(updatedCoords);
    } else {
        zoomToFit(coords);
    }
}
项目:droidplanner-master    文件:BaiduMapFragment.java   
@Override
public void goToMyLocation() {
   // if (!mGApiClientMgr.addTask(mGoToMyLocationTask)) {
    //    Log.e(TAG, "Unable to add google api client task.");
    MyLocationData locationData = getBaiduMap().getLocationData();
    if(locationData != null)
        updateCamera(DroneHelper.BDLocationToCoord(locationData), GO_TO_MY_LOCATION_ZOOM);


}
项目:FindYou    文件:RoutePlan.java   
@Override
public void onReceiveLocation(BDLocation location) {
    netWork.fun(location.getLatitude(),location.getLongitude(),this);
    Log.e("x:",Double.toString(location.getLatitude()));
    nowLocation=location;

    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null) {
        return;
    }
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
            // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();

    mBaidumap.setMyLocationData(locData);
    Boolean isFirstLoc=true;
    if (isFirstLoc) {
        isFirstLoc = false;
        LatLng ll = new LatLng(location.getLatitude(),
                location.getLongitude());
        MapStatus.Builder builder = new MapStatus.Builder();
        //TODO
        if (follow)
        builder.target(ll).zoom(21.0f);
        mBaidumap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));
    }
}
项目:nongfei-missionplane    文件:BaiduMapFragment.java   
@Override
public void zoomToFitMyLocation(final List<LatLong> coords) {
    MyLocationData locationData = getBaiduMap().getLocationData();
    if (locationData != null) {
        final List<LatLong> updatedCoords = new ArrayList<LatLong>(coords);
        updatedCoords.add(DroneHelper.BDLocationToCoord(locationData));
        zoomToFit(updatedCoords);
    } else {
        zoomToFit(coords);
    }
}
项目:nongfei-missionplane    文件:BaiduMapFragment.java   
@Override
public void goToMyLocation() {
   // if (!mGApiClientMgr.addTask(mGoToMyLocationTask)) {
    //    Log.e(TAG, "Unable to add google api client task.");
    MyLocationData locationData = getBaiduMap().getLocationData();
    if(locationData != null)
        updateCamera(DroneHelper.BDLocationToCoord(locationData), GO_TO_MY_LOCATION_ZOOM);


}
项目:EasyTracker    文件:TrackFragment.java   
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null)
        return;
    Log.d("TAG", "code:" + location.getLocType());
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
            // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);

    if (isFirstLoc) {
        RequestQueue requestQueue = Volley.newRequestQueue(viewMap
                .getContext());
        ApiHttpClient.getStringByGet(viewMap.getContext(),
                requestQueue, Urls.SENDING_LOCATION,
                new VolleyStringCallback() {
                    @Override
                    public void onSuccess(String result) {
                        mBaiduMap.clear();
                        String[] st = result.split(";");
                        Log.d("11111", "aaaaaaaaa" + result);
                        ll_end = new LatLng(Double.parseDouble(st[0]),
                                Double.parseDouble(st[1]));
                        OverlayOptions ooA = new MarkerOptions()
                                .position(ll_end).icon(bdA).zIndex(9)
                                .draggable(true);
                        mMarkerA = (Marker) (mBaiduMap.addOverlay(ooA));
                    }
                });
        isFirstLoc = false;
        ll_end = new LatLng(location.getLatitude(),
                location.getLongitude());
        MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll_end);
        mBaiduMap.animateMapStatus(u);
    }
}
项目:Conquer    文件:LocationActivity.java   
@Override
public void onReceiveLocation(BDLocation location) {
    // map view 销毁后不在处理新接收的位置
    if (location == null || mMapView == null) return;

    if (lastLocation != null) {
        if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) {
            BmobLog.i("获取坐标相同");// 若两次请求获取到的地理位置坐标是相同的,则不再定位
            mLocClient.stop();
            return;
        }
    }
    lastLocation = location;

    BmobLog.i("lontitude = " + location.getLongitude() + ",latitude = " + location.getLatitude() + ",地址 = "
            + lastLocation.getAddrStr());

    MyLocationData locData = new MyLocationData.Builder().accuracy(location.getRadius())
    // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(location.getLatitude()).longitude(location.getLongitude()).build();
    mBaiduMap.setMyLocationData(locData);
    LatLng ll = new LatLng(location.getLatitude(), location.getLongitude());
    String address = location.getAddrStr();
    if (address != null && !address.equals("")) {
        lastLocation.setAddrStr(address);
    } else {
        // 反Geo搜索
        mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(ll));
    }
    // 显示在地图上
    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
    mBaiduMap.animateMapStatus(u);
    // 设置按钮可点击
    // mHeaderLayout.getRightImageButton().setEnabled(true);
}