opt: main page, add polyline api, add back to launcher logic; bugfix: map resume when back to mainactivity
This commit is contained in:
@@ -2,6 +2,8 @@ package com.mogo.map;
|
||||
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -127,4 +129,12 @@ public interface IMogoMap {
|
||||
* @return
|
||||
*/
|
||||
float getZoomLevel();
|
||||
|
||||
/**
|
||||
* 添加线段
|
||||
*
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
IMogoPolyline addPolyline( MogoPolylineOptions options );
|
||||
}
|
||||
|
||||
@@ -54,63 +54,49 @@ public class MogoMapListenerHandler implements IMogoMapListener, IMogoMapListene
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
if ( mDelegateListener != null ) {
|
||||
synchronized ( mDelegateListener ) {
|
||||
mDelegateListener.onMapLoaded();
|
||||
}
|
||||
mDelegateListener.onMapLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch( MotionEvent motionEvent ) {
|
||||
if ( mDelegateListener != null ) {
|
||||
synchronized ( mDelegateListener ) {
|
||||
mDelegateListener.onTouch( motionEvent );
|
||||
}
|
||||
mDelegateListener.onTouch( motionEvent );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPOIClick( MogoPoi poi ) {
|
||||
if ( mDelegateListener != null ) {
|
||||
synchronized ( mDelegateListener ) {
|
||||
mDelegateListener.onPOIClick( poi );
|
||||
}
|
||||
mDelegateListener.onPOIClick( poi );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick( MogoLatLng latLng ) {
|
||||
if ( mDelegateListener != null ) {
|
||||
synchronized ( mDelegateListener ) {
|
||||
mDelegateListener.onMapClick( latLng );
|
||||
}
|
||||
mDelegateListener.onMapClick( latLng );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLockMap( boolean isLock ) {
|
||||
if ( mDelegateListener != null ) {
|
||||
synchronized ( mDelegateListener ) {
|
||||
mDelegateListener.onLockMap( isLock );
|
||||
}
|
||||
mDelegateListener.onLockMap( isLock );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapModeChanged( EnumMapUI ui ) {
|
||||
if ( mDelegateListener != null ) {
|
||||
synchronized ( mDelegateListener ) {
|
||||
mDelegateListener.onMapModeChanged( ui );
|
||||
}
|
||||
mDelegateListener.onMapModeChanged( ui );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapChanged( MogoLatLng location, float zoom, float tilt, float bearing ) {
|
||||
if ( mDelegateListener != null ) {
|
||||
synchronized ( mDelegateListener ) {
|
||||
mDelegateListener.onMapChanged( location, zoom, tilt, bearing );
|
||||
}
|
||||
mDelegateListener.onMapChanged( location, zoom, tilt, bearing );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mogo.map.overlay;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 覆盖物
|
||||
*/
|
||||
public interface IMogoOverlayManager {
|
||||
|
||||
/**
|
||||
* 绘制线段
|
||||
*
|
||||
* @param options
|
||||
* @return
|
||||
*/
|
||||
IMogoPolyline addPolyline( MogoPolylineOptions options );
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.mogo.map.overlay;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
|
||||
import com.mogo.map.IDestroyable;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 线段
|
||||
*/
|
||||
public interface IMogoPolyline extends IDestroyable {
|
||||
|
||||
|
||||
/**
|
||||
* 是否已经销毁
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isDestroyed();
|
||||
|
||||
/**
|
||||
* 移除
|
||||
*/
|
||||
void remove();
|
||||
|
||||
/**
|
||||
* 获取ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* 设置绘制点数据
|
||||
*
|
||||
* @param lonLats
|
||||
*/
|
||||
void setPoints( List< MogoLatLng > lonLats );
|
||||
|
||||
/**
|
||||
* 获取点
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List< MogoLatLng > getPoints();
|
||||
|
||||
/**
|
||||
* 测地线
|
||||
*
|
||||
* @param draw
|
||||
*/
|
||||
void setGeodesic( boolean draw );
|
||||
|
||||
/**
|
||||
* 是否设置了测地线
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isGeodesic();
|
||||
|
||||
/**
|
||||
* 虚线
|
||||
*
|
||||
* @param dottedLine
|
||||
*/
|
||||
void setDottedLine( boolean dottedLine );
|
||||
|
||||
/**
|
||||
* 是否是虚线
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isDottedLine();
|
||||
|
||||
/**
|
||||
* 设置线宽
|
||||
*
|
||||
* @param width
|
||||
*/
|
||||
void setWidth( float width );
|
||||
|
||||
/**
|
||||
* 获取线宽
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
float getWidth();
|
||||
|
||||
/**
|
||||
* 设置线条颜色
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
void setColor( @ColorInt int color );
|
||||
|
||||
/**
|
||||
* 获取线条颜色
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ColorInt
|
||||
int getColor();
|
||||
|
||||
/**
|
||||
* 设置Z轴
|
||||
*/
|
||||
void setZIndex( float zIndex );
|
||||
|
||||
/**
|
||||
* 获取Z轴
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
float getZIndex();
|
||||
|
||||
/**
|
||||
* 设置显示/隐藏
|
||||
*/
|
||||
void setVisible( boolean visible );
|
||||
|
||||
/**
|
||||
* 是否可见
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isVisible();
|
||||
|
||||
/**
|
||||
* 设置透明度
|
||||
*
|
||||
* @param transparency
|
||||
*/
|
||||
void setTransparency( float transparency );
|
||||
|
||||
/**
|
||||
* 设置配置项
|
||||
*/
|
||||
void setOption( MogoPolylineOptions option );
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
package com.mogo.map.overlay;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import androidx.annotation.ColorInt;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-03-10
|
||||
* <p>
|
||||
* 线段属性
|
||||
*/
|
||||
public class MogoPolylineOptions {
|
||||
|
||||
private List< MogoLatLng > mPoints;
|
||||
private float mWidth = 10.0F;
|
||||
private int mColor = Color.BLACK;
|
||||
private float mZIndex = 0.0F;
|
||||
private boolean mIsVisible = true;
|
||||
private boolean mIsGeodesic = false;
|
||||
private boolean mIsDottedLine = false;
|
||||
private boolean mIsGradient = false;
|
||||
private float mTransparency = 1.0F;
|
||||
private boolean mIsAboveMaskLayer = false;
|
||||
private boolean mIsPointsUpdated = false;
|
||||
|
||||
public MogoPolylineOptions() {
|
||||
this.mPoints = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置顶点
|
||||
*
|
||||
* @param points
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions points( List< MogoLatLng > points ) {
|
||||
this.mPoints.clear();
|
||||
this.mPoints.addAll( points );
|
||||
this.mIsPointsUpdated = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加顶点到集合最后
|
||||
*
|
||||
* @param points
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions add( MogoLatLng... points ) {
|
||||
if ( points != null ) {
|
||||
this.mPoints.addAll( Arrays.asList( points ) );
|
||||
this.mIsPointsUpdated = true;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions add( double lon, double lat ) {
|
||||
this.mPoints.add( new MogoLatLng( lat, lon ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoPolylineOptions add( MogoLocation location ) {
|
||||
if ( location != null ) {
|
||||
this.mPoints.add( new MogoLatLng( location.getLatitude(), location.getLongitude() ) );
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置线宽
|
||||
*/
|
||||
public MogoPolylineOptions width( float width ) {
|
||||
this.mWidth = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置线的颜色
|
||||
*
|
||||
* @param color
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions color( @ColorInt int color ) {
|
||||
this.mColor = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置Z轴的值
|
||||
*
|
||||
* @param zIndex
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions zIndex( float zIndex ) {
|
||||
this.mZIndex = zIndex;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否可见
|
||||
*
|
||||
* @param isVisible
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions visible( boolean isVisible ) {
|
||||
this.mIsVisible = isVisible;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否绘制测地线
|
||||
*
|
||||
* @param isGeodesic
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions geodesic( boolean isGeodesic ) {
|
||||
this.mIsGeodesic = isGeodesic;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是虚线
|
||||
*
|
||||
* @param isDottedLine
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions dottedLine( boolean isDottedLine ) {
|
||||
this.mIsDottedLine = isDottedLine;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否使用渐变色
|
||||
*
|
||||
* @param isGradient
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions useGradient( boolean isGradient ) {
|
||||
this.mIsGradient = isGradient;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置透明度
|
||||
*
|
||||
* @param transparency
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions transparency( float transparency ) {
|
||||
this.mTransparency = transparency;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isAboveMaskLayer
|
||||
* @return
|
||||
*/
|
||||
public MogoPolylineOptions aboveMaskLayer( boolean isAboveMaskLayer ) {
|
||||
this.mIsAboveMaskLayer = isAboveMaskLayer;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List< MogoLatLng > getPoints() {
|
||||
return mPoints;
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return mColor;
|
||||
}
|
||||
|
||||
public float getZIndex() {
|
||||
return mZIndex;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return mIsVisible;
|
||||
}
|
||||
|
||||
public boolean isGeodesic() {
|
||||
return mIsGeodesic;
|
||||
}
|
||||
|
||||
public boolean isDottedLine() {
|
||||
return mIsDottedLine;
|
||||
}
|
||||
|
||||
public boolean isGradient() {
|
||||
return mIsGradient;
|
||||
}
|
||||
|
||||
public float getTransparency() {
|
||||
return mTransparency;
|
||||
}
|
||||
|
||||
public boolean isAboveMaskLayer() {
|
||||
return mIsAboveMaskLayer;
|
||||
}
|
||||
|
||||
public boolean isPointsUpdated() {
|
||||
return mIsPointsUpdated;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user