dev
This commit is contained in:
@@ -106,4 +106,13 @@ public interface IMogoMap {
|
||||
* 停止当前执行的改变地图状态的动画。
|
||||
*/
|
||||
void stopAnimation();
|
||||
|
||||
/**
|
||||
* 获取比例尺
|
||||
*
|
||||
* @return 当前缩放级别下,地图上1像素点对应的长度,单位米
|
||||
*/
|
||||
float getScalePerPixel();
|
||||
|
||||
void changeZoom(float zoom);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mogo.map.listener;
|
||||
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListenerRegister;
|
||||
import com.mogo.map.navi.IMogoNaviListenerRegister;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-29
|
||||
* <p>
|
||||
* 主模块需要注册监听的事件
|
||||
*/
|
||||
public interface IMogoHosListenerRegister extends IMogoNaviListenerRegister,
|
||||
IMogoMapListenerRegister,
|
||||
IMogoMarkerClickListenerRegister {
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.mogo.map.listener;
|
||||
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.mogo.map.listener;
|
||||
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.navi.MogoNaviListenerHandler;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-29
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MogoHosListenerRegister implements IMogoHosListenerRegister {
|
||||
|
||||
private static volatile MogoHosListenerRegister sInstance;
|
||||
|
||||
private MogoHosListenerRegister() {
|
||||
}
|
||||
|
||||
public static MogoHosListenerRegister getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( MogoHosListenerRegister.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new MogoHosListenerRegister();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerHostMapListener( IMogoMapListener listener ) {
|
||||
MogoMapListenerHandler.getInstance().registerHostMapListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterHostMapListener() {
|
||||
MogoMapListenerHandler.getInstance().unregisterHostMapListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerHostNaviListener( IMogoNaviListener listener ) {
|
||||
MogoNaviListenerHandler.getInstance().registerHostNaviListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterHostNaviListener() {
|
||||
MogoNaviListenerHandler.getInstance().unregisterHostNaviListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMarkerClickListener( IMogoMarkerClickListener listener ) {
|
||||
MogoMarkersHandler.getInstance().registerMarkerClickListener( listener );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterMarkerClickListener() {
|
||||
MogoMarkersHandler.getInstance().unregisterMarkerClickListener();
|
||||
}
|
||||
}
|
||||
@@ -40,4 +40,6 @@ public interface IMogoLocationClient {
|
||||
void removeLocationListener( IMogoLocationListener listener );
|
||||
|
||||
MogoLocation getLastKnowLocation();
|
||||
|
||||
void destroy();
|
||||
}
|
||||
|
||||
@@ -10,5 +10,11 @@ import android.view.View;
|
||||
*/
|
||||
public interface IMogoInfoWindowAdapter {
|
||||
|
||||
/**
|
||||
* 获取infowindow的布局
|
||||
*
|
||||
* @param marker
|
||||
* @return
|
||||
*/
|
||||
View getInfoWindow( IMogoMarker marker );
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.mogo.map.marker;
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -168,7 +167,38 @@ public interface IMogoMarker {
|
||||
*/
|
||||
void setInfoWindowAdapter( IMogoInfoWindowAdapter adapter );
|
||||
|
||||
/**
|
||||
* 自定义 infowindow 样式接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoInfoWindowAdapter getInfoWindowAdapter();
|
||||
|
||||
/**
|
||||
* 自定义marker样式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
void setMarkerIconView( IMogoMarkerIconViewCreator creator );
|
||||
|
||||
/**
|
||||
* 是否被销毁
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isDestroyed();
|
||||
|
||||
/**
|
||||
* 设置marker的归属模块
|
||||
*
|
||||
* @param mOwner
|
||||
*/
|
||||
void setOwner( String mOwner );
|
||||
|
||||
/**
|
||||
* 获取marker的归属模块
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getOwner();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
* <p>
|
||||
* 地图操作回调
|
||||
*/
|
||||
public interface IMogoMarkerClickListenerRegister {
|
||||
|
||||
/**
|
||||
* 注册marker回调,各业务模块不用关注
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
void registerMarkerClickListener( IMogoMarkerClickListener listener );
|
||||
|
||||
|
||||
/**
|
||||
* 注销marker回调,各业务模块不需要关注
|
||||
*/
|
||||
void unregisterMarkerClickListener();
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-29
|
||||
* <p>
|
||||
* 动态变换 marker 样式接口
|
||||
*/
|
||||
public interface IMogoMarkerIconViewCreator {
|
||||
|
||||
/**
|
||||
* 返回自定义marker样式
|
||||
*
|
||||
* @param marker marker 的数据
|
||||
* @return
|
||||
*/
|
||||
View createView( IMogoMarker marker );
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Observable;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -10,7 +12,7 @@ import java.util.ArrayList;
|
||||
* <p>
|
||||
* 地图marker
|
||||
*/
|
||||
public class MogoMarkerOptions {
|
||||
public class MogoMarkerOptions extends Observable {
|
||||
|
||||
private double latitude;
|
||||
private double longitude;
|
||||
@@ -41,7 +43,7 @@ public class MogoMarkerOptions {
|
||||
// Marker覆盖物锚点在水平范围的比例。
|
||||
private float u = 0.5f;
|
||||
// Marker覆盖物锚点垂直范围的比例。
|
||||
private float v = 0.5f;
|
||||
private float v = 1f;
|
||||
|
||||
// 设置Marker覆盖物是否可拖拽。
|
||||
private boolean draggable = false;
|
||||
@@ -53,6 +55,10 @@ public class MogoMarkerOptions {
|
||||
|
||||
// 设置Marker覆盖物 zIndex。
|
||||
private int zIndex = 0;
|
||||
// 自定义样式
|
||||
private View mIconView;
|
||||
// marker 归属模块
|
||||
private String mOwner;
|
||||
|
||||
public MogoMarkerOptions latitude( double latitude ) {
|
||||
this.latitude = latitude;
|
||||
@@ -74,6 +80,12 @@ public class MogoMarkerOptions {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优先使用icon作为marker资源
|
||||
*
|
||||
* @param icon
|
||||
* @return
|
||||
*/
|
||||
public MogoMarkerOptions icon( Bitmap icon ) {
|
||||
this.icon = icon;
|
||||
return this;
|
||||
@@ -144,6 +156,22 @@ public class MogoMarkerOptions {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义marker图层样式,优先使用 icon {@link #icon(Bitmap)}作为marker资源
|
||||
*
|
||||
* @param iconView
|
||||
* @return
|
||||
*/
|
||||
public MogoMarkerOptions icon( View iconView ) {
|
||||
this.mIconView = iconView;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MogoMarkerOptions owner( String owner ) {
|
||||
this.mOwner = owner;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
@@ -219,4 +247,12 @@ public class MogoMarkerOptions {
|
||||
public int getzIndex() {
|
||||
return zIndex;
|
||||
}
|
||||
|
||||
public View getIconView() {
|
||||
return mIconView;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return mOwner;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.listener.IMogoMapListenerRegister;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -12,9 +15,10 @@ import java.util.Map;
|
||||
* <p>
|
||||
* 管理地图上的所有marker
|
||||
*/
|
||||
public class MogoMarkersHandler {
|
||||
public class MogoMarkersHandler implements IMogoMarkerClickListener, IMogoMarkerClickListenerRegister {
|
||||
|
||||
private static volatile MogoMarkersHandler sInstance;
|
||||
private IMogoMarkerClickListener mDelegate;
|
||||
|
||||
public static MogoMarkersHandler getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
@@ -86,4 +90,22 @@ public class MogoMarkersHandler {
|
||||
}
|
||||
mServicesMarkers.get( tag ).addAll( markers );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMarkerClickListener( IMogoMarkerClickListener listener ) {
|
||||
mDelegate = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterMarkerClickListener() {
|
||||
mDelegate = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMarkerClicked( IMogoMarker marker ) {
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.onMarkerClicked( marker );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.map.uicontroller;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-26
|
||||
@@ -22,6 +24,13 @@ public interface IMogoMapUIController {
|
||||
*/
|
||||
void changeZoom( boolean zoomIn );
|
||||
|
||||
/**
|
||||
* 修改缩放级别
|
||||
*
|
||||
* @param zoom
|
||||
*/
|
||||
void changeZoom( float zoom );
|
||||
|
||||
/**
|
||||
* 切换2D/3D模式
|
||||
*
|
||||
@@ -32,7 +41,7 @@ public interface IMogoMapUIController {
|
||||
/**
|
||||
* 将地图移动至当前位置
|
||||
*/
|
||||
void moveToCurrentLocation();
|
||||
void moveToCenter( MogoLatLng latLng );
|
||||
|
||||
/**
|
||||
* 显示我的位置
|
||||
@@ -50,4 +59,11 @@ public interface IMogoMapUIController {
|
||||
* 预览全程
|
||||
*/
|
||||
void displayOverview();
|
||||
|
||||
/**
|
||||
* 获取比例尺数据
|
||||
*
|
||||
* @return 当前缩放级别下,地图上1像素点对应的长度,单位米
|
||||
*/
|
||||
float getScalePerPixel();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user