升级自研地图sdk版本
添加自动切换地图样式逻辑(顺义区域)
This commit is contained in:
@@ -67,8 +67,8 @@ dependencies {
|
||||
implementation project(':foudations:mogo-commons')
|
||||
}
|
||||
|
||||
// implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.4.5'
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.4.5-log-1'
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.4.6'
|
||||
// implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.4.5-log-1'
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
|
||||
@@ -62,7 +62,8 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
OnMapClickListener,
|
||||
OnMapTouchListener,
|
||||
OnMarkClickListener,
|
||||
OnMapStyleListener {
|
||||
OnMapStyleListener,
|
||||
MapStyleController.IMapStyleAutoChangedListener {
|
||||
|
||||
private static final String TAG = "AMapViewWrapper";
|
||||
private final MapAutoView mMapView;
|
||||
@@ -684,6 +685,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
}
|
||||
|
||||
NaviClient.getInstance( getContext() ).syncCarLocation( sysLocation );
|
||||
MapStyleController.getInstance().onLocationChanged( location, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -797,4 +799,21 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
public void testGpsData() {
|
||||
GpsTester.getInstance().testGpsData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStyleAutoChanged( boolean isVrMode ) {
|
||||
if ( isVrMode ) {
|
||||
if ( mCurrentUI != EnumMapUI.Type_VR ) {
|
||||
changeZoom( 20 );
|
||||
changeMapMode( EnumMapUI.Type_VR );
|
||||
Logger.d( TAG, "自动切换为vr模式" );
|
||||
}
|
||||
} else {
|
||||
if ( mCurrentUI == EnumMapUI.Type_VR ) {
|
||||
changeZoom( 16 );
|
||||
changeMapMode( EnumMapUI.Type_Night );
|
||||
Logger.d( TAG, "自动切换为2D模式" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.mogo.map.impl.custom;
|
||||
|
||||
|
||||
import com.zhidaoauto.map.sdk.open.location.MogoLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/12/25
|
||||
*
|
||||
* 地图样式控制
|
||||
*/
|
||||
class MapStyleController {
|
||||
|
||||
|
||||
private static volatile MapStyleController sInstance;
|
||||
|
||||
private boolean mIsInVrMode = false;
|
||||
|
||||
private List< VrAreaFilter > mVrAreaFilters = new ArrayList<>();
|
||||
|
||||
private MapStyleController() {
|
||||
mVrAreaFilters.add( new ShunYiArea() );
|
||||
}
|
||||
|
||||
public static MapStyleController getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( MapStyleController.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new MapStyleController();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void onLocationChanged( MogoLocation location, IMapStyleAutoChangedListener listener ) {
|
||||
if ( location == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isInVrMode = false;
|
||||
for ( VrAreaFilter vrAreaFilter : mVrAreaFilters ) {
|
||||
if ( vrAreaFilter == null ) {
|
||||
continue;
|
||||
}
|
||||
isInVrMode |= vrAreaFilter.isVrArea( location );
|
||||
if ( isInVrMode ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( isInVrMode ) {
|
||||
if ( !mIsInVrMode ) {
|
||||
// 第一次进入 vr 区域,自动变为 vr 模式
|
||||
mIsInVrMode = true;
|
||||
if ( listener != null ) {
|
||||
listener.onStyleAutoChanged( true );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( mIsInVrMode ) {
|
||||
// 驶出 vr 区域,自动变为 2d 模式
|
||||
mIsInVrMode = false;
|
||||
if ( listener != null ) {
|
||||
listener.onStyleAutoChanged( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMapStyleAutoChangedListener {
|
||||
void onStyleAutoChanged( boolean isVrMode );
|
||||
}
|
||||
|
||||
public interface VrAreaFilter {
|
||||
boolean isVrArea( MogoLocation location );
|
||||
}
|
||||
|
||||
public static class ShunYiArea implements VrAreaFilter {
|
||||
|
||||
// 顺义一期高精地图范围(目前圈定了一个矩形区域,认为都是高精地图区域)
|
||||
private final double leftBottomLat = 40.18728;
|
||||
private final double leftBottomLon = 116.71194;
|
||||
private final double rightTopLat = 40.20671;
|
||||
private final double rightTopLon = 116.74804;
|
||||
|
||||
@Override
|
||||
public boolean isVrArea( MogoLocation location ) {
|
||||
if ( location == null ) {
|
||||
return false;
|
||||
}
|
||||
return location.getLat() > leftBottomLat && location.getLon() > leftBottomLon
|
||||
&& location.getLat() < rightTopLat && location.getLon() < rightTopLon;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user