当前位置: 首页>>代码示例>>Java>>正文


Java MyLocationData.Builder方法代码示例

本文整理汇总了Java中com.baidu.mapapi.map.MyLocationData.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java MyLocationData.Builder方法的具体用法?Java MyLocationData.Builder怎么用?Java MyLocationData.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.baidu.mapapi.map.MyLocationData的用法示例。


在下文中一共展示了MyLocationData.Builder方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: moveToMe

import com.baidu.mapapi.map.MyLocationData; //导入方法依赖的package包/类
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();
}
 
开发者ID:WindFromFarEast,项目名称:SmartButler,代码行数:17,代码来源:LocationActivity.java

示例2: navigateTo

import com.baidu.mapapi.map.MyLocationData; //导入方法依赖的package包/类
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());

}
 
开发者ID:MoonRiser,项目名称:MaterialLearning,代码行数:19,代码来源:BaiduMapActivity.java

示例3: navigateTo

import com.baidu.mapapi.map.MyLocationData; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:21,代码来源:MainActivity.java

示例4: navigateTo

import com.baidu.mapapi.map.MyLocationData; //导入方法依赖的package包/类
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);
}
 
开发者ID:Qinlong275,项目名称:AndroidBookTest,代码行数:14,代码来源:MainActivity.java

示例5: onActivityResult

import com.baidu.mapapi.map.MyLocationData; //导入方法依赖的package包/类
@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;
    }
}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:32,代码来源:MainActivity.java

示例6: navigateTo

import com.baidu.mapapi.map.MyLocationData; //导入方法依赖的package包/类
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);
}
 
开发者ID:wangyufei1006,项目名称:LBSTest,代码行数:16,代码来源:MainActivity.java

示例7: navigateTo

import com.baidu.mapapi.map.MyLocationData; //导入方法依赖的package包/类
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);
}
 
开发者ID:DysaniazzZ,项目名称:HelloAndroid,代码行数:16,代码来源:BaiduMapUsageActivity.java

示例8: onCreate

import com.baidu.mapapi.map.MyLocationData; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mLocationClient = new LocationClient(getApplicationContext());
    mLocationClient.registerLocationListener(new MyLocationListener());
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.activity_location);
    mapView = (MapView) findViewById(R.id.bmapView);
    baiduMap = mapView.getMap();
    baiduMap.setMyLocationEnabled(true);
    positionText = (TextView) findViewById(R.id.position_text_view);
    weather= (ezy.ui.view.RoundButton) findViewById(R.id.weather);
    position= (ezy.ui.view.RoundButton) findViewById(R.id.Position);
    handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            // 负责接收Handler消息,并执行UI更新
            // 判断消息的来源:通过消息的类型 what
            switch (msg.what) {
                case WHAT_NEWS:
                    positionText.setText(currentPosition);
                    SharedPreferences prefs=getSharedPreferences("location", Context.MODE_PRIVATE);
                    SharedPreferences.Editor editor=prefs.edit();
                    editor.putString("City",City);
                    editor.putString ("District",District);
                    editor.commit();
                    break;
                case WHAT_NEW:
                    if (isFirstLocate) {

                        LatLng ll = new LatLng(Latitude, Longitude);
                    MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(ll);
                    baiduMap.animateMapStatus(update);
                    update = MapStatusUpdateFactory.zoomTo(16f);
                    baiduMap.animateMapStatus(update);
                    }
                    MyLocationData.Builder locationBuilder = new MyLocationData.
                            Builder();
                    locationBuilder.latitude(Latitude);
                    locationBuilder.longitude(Longitude);
                    MyLocationData locationData = locationBuilder.build();
                    baiduMap.setMyLocationData(locationData);
            }

        }
    } ;
    List<String> permissionList = new ArrayList<>();
    if (ContextCompat.checkSelfPermission(LocationActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        permissionList.add(Manifest.permission.ACCESS_FINE_LOCATION);
    }
    if (ContextCompat.checkSelfPermission(LocationActivity.this, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
        permissionList.add(Manifest.permission.READ_PHONE_STATE);
    }
    if (ContextCompat.checkSelfPermission(LocationActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
        permissionList.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
    }
    if (!permissionList.isEmpty()) {
        String [] permissions = permissionList.toArray(new String[permissionList.size()]);
        ActivityCompat.requestPermissions(LocationActivity.this, permissions, 1);
    } else {
        requestLocation();
    }

}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:65,代码来源:LocationActivity.java

示例9: onReceiveLocation

import com.baidu.mapapi.map.MyLocationData; //导入方法依赖的package包/类
@Override
public void onReceiveLocation(BDLocation location) {
    if (LocationUtils.isLocationInvalid(location))
        return;

    long time = System.currentTimeMillis();
    double lng = location.getLongitude();
    double lat = location.getLatitude();
    LatLng latLng = new LatLng(lat, lng);
    float radius = location.getRadius();

    if (mIsInFront) {
        MyLocationData.Builder builder = new MyLocationData.Builder();
        builder.longitude(lng);
        builder.latitude(lat);
        builder.accuracy(radius);
        builder.direction(DirectionUtils.getDirection());
        MyLocationData myLocationData = builder.build();
        mMapView.getMap().setMyLocationData(myLocationData);

        if (mFollowMyLocation) {
            MapStatusUpdate update = MapStatusUpdateFactory.newLatLng(latLng);
            mMapView.getMap().animateMapStatus(update);
        }
    }

    if (radius > 0 && radius < 22) {
        if (mLocationIndex++ == 0) {
            mStartDialog.dismiss();
            mStartButton.setImageResource(R.drawable.ic_stop);

            mIsRecodingRoute = true;

            mRoute = new ArrayList<LatLng>();
            mRoute.add(latLng);
            mLastRouteSize = 1;

            mStartTime = time;
            mLastLocation = location;

            if (mIsInFront) {
                mMapView.getMap().clear();

                mBigDistanceView.setText("0.0 km");
                mSmallDistanceView.setText("0.0 km");
                mTimeSpanView.setText("0:00:00");
                mAverageSpeedView.setText("0.0 km/h");
                Toast.makeText(this, R.string.get_gps_location, Toast.LENGTH_SHORT).show();
            }
        } else {
            LatLng latLng1 = new LatLng(location.getLatitude(), location.getLongitude());
            LatLng latLng2 = new LatLng(mLastLocation.getLatitude(), mLastLocation.getLongitude());
            mTotalDistance += DistanceUtil.getDistance(latLng1, latLng2);

            if (lng != mLastLocation.getLongitude() || lat != mLastLocation.getLatitude()) {
                mRoute.add(latLng);
            }

            mLastLocation = location;

            if (mIsInFront) {
                if (mRoute.size() > mLastRouteSize) {
                    MapViewUtils.clearOverlays(mMapView);
                    MapViewUtils.addLineOverlay(mMapView, mRoute, 0);
                    mLastRouteSize = mRoute.size();
                }

                DecimalFormat formatter = new DecimalFormat("0.0");
                mBigDistanceView.setText(formatter.format(mTotalDistance / 1000) + " km");
                mSmallDistanceView.setText(formatter.format(mTotalDistance / 1000) + " km");
                mTimeSpanView.setText(StringFormatter.formatTime(time - mStartTime));
                double avrSpeed = mTotalDistance * 1000 / (time - mStartTime);
                mAverageSpeedView.setText(formatter.format(avrSpeed * 3600 / 1000) + " km/h");
            }
        }
    }

}
 
开发者ID:iWay7,项目名称:BikeHelper,代码行数:79,代码来源:MainActivity.java


注:本文中的com.baidu.mapapi.map.MyLocationData.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。