修改小地图样式
This commit is contained in:
@@ -4,8 +4,7 @@ import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
import android.widget.ImageView;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -14,16 +13,13 @@ import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.CameraUpdate;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.navi.AMapNaviView;
|
||||
import com.amap.api.navi.AMapNaviViewOptions;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.small.map.animation.DirectionRotateAnimation;
|
||||
import com.mogo.utils.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@@ -35,7 +31,6 @@ import java.io.IOException;
|
||||
public class SmallMapDirectionView extends RelativeLayout {
|
||||
private String styleFilePath = "/mnt/sdcard/amap/small_map_style.data";
|
||||
|
||||
private ImageView mIvMapBorder;
|
||||
private AMapNaviView mAMapNaviView;
|
||||
private DirectionRotateAnimation mRotateAnimation;
|
||||
private int lastAngle = 0;
|
||||
@@ -62,7 +57,6 @@ public class SmallMapDirectionView extends RelativeLayout {
|
||||
mRotateAnimation = new DirectionRotateAnimation(context, null);
|
||||
|
||||
AbsMogoApplication.getLayoutInflaterNoSkin().inflate(R.layout.module_small_map_view, this);
|
||||
mIvMapBorder = findViewById(R.id.ivMapBorder);
|
||||
mAMapNaviView = findViewById(R.id.aMapNaviView);
|
||||
mAMapNaviView.onCreate(null);
|
||||
|
||||
@@ -136,7 +130,7 @@ public class SmallMapDirectionView extends RelativeLayout {
|
||||
options.setNaviArrowVisible(false);
|
||||
// 通过路线是否自动置灰,仅支持驾车导航
|
||||
options.setAfterRouteAutoGray(false);
|
||||
//options.setZoom(((int) 9));
|
||||
options.setZoom(((int) 7));
|
||||
//options.setPointToCenter(0.7D, 0.5D);
|
||||
// 2D模式
|
||||
options.setTilt(0);
|
||||
@@ -151,21 +145,6 @@ public class SmallMapDirectionView extends RelativeLayout {
|
||||
CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
aMap.moveCamera(cameraUpdate);
|
||||
|
||||
aMap.setOnCameraChangeListener(new AMap.OnCameraChangeListener() {
|
||||
@Override
|
||||
public void onCameraChange(CameraPosition cameraPosition) {
|
||||
if (cameraPosition != null) {
|
||||
//Log.w("onCameraChange", "cameraPosition=" + cameraPosition.bearing);
|
||||
changeAngle((int) cameraPosition.bearing);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinish(CameraPosition cameraPosition) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
aMap.setOnMapLoadedListener(new AMap.OnMapLoadedListener() {
|
||||
|
||||
@Override
|
||||
@@ -229,46 +208,22 @@ public class SmallMapDirectionView extends RelativeLayout {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
mIvMapBorder.setOnClickListener( view -> {
|
||||
setOnClickListener(view -> {
|
||||
MogoApisHandler.getInstance().getApis()
|
||||
.getMapServiceApi()
|
||||
.getMapUIController()
|
||||
.changeMapMode(
|
||||
MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getAdasControllerApi()
|
||||
.getCurrentSkinMode()
|
||||
.getApis()
|
||||
.getAdasControllerApi()
|
||||
.getCurrentSkinMode()
|
||||
);
|
||||
} );
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改角度
|
||||
*
|
||||
* @param angle 角度 0 - 359度旋转,相对于自身中心位置
|
||||
*/
|
||||
public void changeAngle(int angle) {
|
||||
int tempAngle = 360 - angle;
|
||||
|
||||
if (tempAngle <= 180) {
|
||||
tempAngle = tempAngle;
|
||||
} else {
|
||||
tempAngle = -(360 - tempAngle);
|
||||
}
|
||||
|
||||
mRotateAnimation.setFromDegrees(lastAngle);
|
||||
mRotateAnimation.setToDegrees(tempAngle);
|
||||
|
||||
//设置线性插值,可以解决旋转一圈后卡顿问题
|
||||
mRotateAnimation.setInterpolator(new LinearInterpolator());
|
||||
//设置旋转一圈时间
|
||||
mRotateAnimation.setDuration(300);
|
||||
//控件动画结束时是否保持动画最后的状态
|
||||
mRotateAnimation.setFillAfter(true);
|
||||
mIvMapBorder.startAnimation(mRotateAnimation);
|
||||
// 刷新最后一次角度
|
||||
lastAngle = tempAngle;
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="@dimen/module_small_map_border_view_width"
|
||||
android:layout_height="@dimen/module_small_map_border_view_width"
|
||||
tools:parentTag="RelativeLayout"
|
||||
app:roundLayoutRadius="360dp">
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/dp_40"
|
||||
tools:parentTag="RelativeLayout">
|
||||
|
||||
|
||||
<View
|
||||
@@ -28,11 +28,4 @@
|
||||
|
||||
</com.mogo.module.common.view.RoundLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivMapBorder"
|
||||
android:layout_width="@dimen/module_small_map_border_view_width"
|
||||
android:layout_height="@dimen/module_small_map_border_view_width"
|
||||
android:layout_centerInParent="true"
|
||||
android:src="@drawable/module_small_map_view_border" />
|
||||
|
||||
</merge>
|
||||
@@ -8,8 +8,8 @@
|
||||
|
||||
<dimen name="module_small_map_view_width">250px</dimen>
|
||||
<dimen name="module_small_map_view_height">250px</dimen>
|
||||
<dimen name="module_small_map_view_x">1525px</dimen>
|
||||
<dimen name="module_small_map_view_y">695px</dimen>
|
||||
<dimen name="module_small_map_view_x">1620px</dimen>
|
||||
<dimen name="module_small_map_view_y">780px</dimen>
|
||||
|
||||
<dimen name="module_small_map_big_view_x">0px</dimen>
|
||||
<dimen name="module_small_map_big_view_y">0px</dimen>
|
||||
|
||||
Reference in New Issue
Block a user