add showBounds interface

This commit is contained in:
wangcongtao
2020-03-02 15:43:52 +08:00
parent 0be962f94f
commit 61fcda00ae
7 changed files with 78 additions and 27 deletions

View File

@@ -4,6 +4,7 @@ import android.content.Context;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.MotionEvent;
@@ -15,6 +16,8 @@ import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.CameraPosition;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.LatLngBounds;
import com.amap.api.maps.model.LatLngBoundsCreator;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MyLocationStyle;
import com.amap.api.maps.model.Poi;
@@ -42,6 +45,8 @@ import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.utils.WindowUtils;
import com.mogo.utils.logger.Logger;
import java.util.List;
import retrofit2.http.HEAD;
/**
@@ -465,10 +470,10 @@ public class AMapNaviViewWrapper implements IMogoMapView,
}
@Override
public void setLockZoom(int var1) {
public void setLockZoom( int var1 ) {
if ( checkAMapView() ) {
Logger.d( TAG, "锁定锁车比例尺" );
mMapView.setLockZoom(var1);
mMapView.setLockZoom( var1 );
}
}
@@ -624,14 +629,14 @@ public class AMapNaviViewWrapper implements IMogoMapView,
/**
* 模拟点击事件,达到锁车->普通事件
*/
private void mockTouchEvent(){
private void mockTouchEvent() {
long downTime = SystemClock.uptimeMillis();
long eventTime = SystemClock.uptimeMillis() + 100;
int metaState = 0;
MotionEvent motionEvent = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, 0, 0, metaState);
mMapView.dispatchTouchEvent(motionEvent);
MotionEvent upEvent = MotionEvent.obtain(downTime + 100, eventTime + 100, MotionEvent.ACTION_UP, 0,0, metaState);
mMapView.dispatchTouchEvent(upEvent);
MotionEvent motionEvent = MotionEvent.obtain( downTime, eventTime, MotionEvent.ACTION_DOWN, 0, 0, metaState );
mMapView.dispatchTouchEvent( motionEvent );
MotionEvent upEvent = MotionEvent.obtain( downTime + 100, eventTime + 100, MotionEvent.ACTION_UP, 0, 0, metaState );
mMapView.dispatchTouchEvent( upEvent );
}
@Override
@@ -643,4 +648,26 @@ public class AMapNaviViewWrapper implements IMogoMapView,
}
}
}
@Override
public void showBounds( List< MogoLatLng > lonLats, Rect bound ) {
if ( checkAMapView() ) {
if ( lonLats == null ) {
return;
}
try {
LatLngBounds.Builder builder = new LatLngBounds.Builder();
for ( MogoLatLng lonLat : lonLats ) {
builder.include( ObjectUtils.fromMogo2( lonLat ) );
}
if ( bound == null ) {
bound = new Rect();
}
LatLngBounds latLngBounds = builder.build();
mMapView.getMap().moveCamera( CameraUpdateFactory.newLatLngBoundsRect( latLngBounds, bound.left, bound.right, bound.top, bound.bottom ) );
} catch ( Exception e ) {
Logger.e( TAG, e, "error." );
}
}
}
}

View File

@@ -1,6 +1,7 @@
package com.mogo.map.impl.amap.uicontroller;
import android.graphics.Point;
import android.graphics.Rect;
import android.view.animation.Interpolator;
import com.mogo.map.MogoLatLng;
@@ -10,6 +11,8 @@ import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.map.uicontroller.IMogoMapUIController;
import com.mogo.utils.logger.Logger;
import java.util.List;
/**
* @author congtaowang
* @since 2019-12-26
@@ -184,4 +187,11 @@ public class AMapUIController implements IMogoMapUIController {
mClient.setRenderFps( fps );
}
}
@Override
public void showBounds( List< MogoLatLng > lonLats, Rect bound ) {
if ( mClient != null ) {
mClient.showBounds( lonLats, bound );
}
}
}