自2018年10月18日起,高德开发者论坛除车机板块外,其他板块将停止发帖与维护,如您有使用问题请 提交工单 联系我们,感谢您的理解。

查看: 360|回复: 0
打印 上一主题 下一主题

[使用疑问] 在持续定位的过程中,希望拖动地图后不移动镜头回原点。

[复制链接]
最佳答案
0 

1

主题

1

帖子

13

积分

新手上路

Rank: 1

积分
13
跳转到指定楼层
楼主
发表于 2018-9-11 16:59:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
发表帖子
API/SDK版本号: n
产品: 定位
手机型号: android
使用接口:
代码用的是官方示例中心的:定位图标指示方向 ,https://lbs.amap.com/dev/demo/location-rotation-effect#Android在持续定位的过程中,移动地图后镜头会被拉回原点,以定位图标为地图中心点。
希望拖动后不移动镜头。
定位类型:aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);

代码部分:
private void setUpMap() {
            aMap.setLocationSource(this);// 设置定位监听
             aMap.getUiSettings().setMyLocationButtonEnabled(true);// 设置默认定位按钮是否显示
             aMap.setMyLocationEnabled(true);// 设置为true表示显示定位层并可触发定位,false表示隐藏定位层并不可触发定位,默认是false
             // 设置定位的类型为定位模式 ,可以由定位、跟随或地图根据面向方向旋转几种
             aMap.setMyLocationType(AMap.LOCATION_TYPE_LOCATE);             
        }




public void activate(OnLocationChangedListener listener) {
                 mListener = listener;
                if (mlocationClient == null) {
                    mlocationClient = new AMapLocationClient(this);
                    mLocationOption = new AMapLocationClientOption();
                    //设置定位监听
                    mlocationClient.setLocationListener(this);
                    //设置为高精度定位模式
                    mLocationOption.setLocationMode(AMapLocationMode.Hight_Accuracy);
                    //设置定位参数
                    mlocationClient.setLocationOption(mLocationOption);
                    mlocationClient.startLocation();
                }
               
        }




public void onLocationChanged(AMapLocation amapLocation) {               
                 if (mListener != null && amapLocation != null) {                                            
                    if (amapLocation != null&& amapLocation.getErrorCode() == 0) {
                        mLocationErrText.setVisibility(View.GONE);
                        LatLng location = new LatLng(amapLocation.getLatitude(), amapLocation.getLongitude());
                        if (!mFirstFix) {
                            mFirstFix = true;
                            addCircle(location, amapLocation.getAccuracy());//添加定位精度圆
                            addMarker(location);//添加定位图标
                            mSensorHelper.setCurrentMarker(mLocMarker);//定位图标旋转
                            aMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location,18));                            
                        } else {
                            mCircle.setCenter(location);
                            mCircle.setRadius(amapLocation.getAccuracy());
                            mLocMarker.setPosition(location);
                            aMap.moveCamera(CameraUpdateFactory.changeLatLng(location));
                        }
                    } else {
                        String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
                        Log.e("AmapErr", errText);
                        mLocationErrText.setVisibility(View.VISIBLE);
                        mLocationErrText.setText(errText);
                    }
                }

        }

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|小黑屋|高德开发者论坛

Copyright ©2014 高德开发者论坛.All Rights Reserved |京ICP证070711号

意见反馈 常见问题 服务条款 联系我们
快速回复 返回顶部 返回列表