Merge remote-tracking branch 'origin/feature/v1.0.0' into feature/v1.0.0
# Conflicts: # modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoModulePaths.java
This commit is contained in:
@@ -10,6 +10,7 @@ import android.view.View;
|
||||
import com.amap.api.maps.AMap;
|
||||
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.Marker;
|
||||
import com.amap.api.maps.model.MyLocationStyle;
|
||||
@@ -37,7 +38,8 @@ import com.mogo.utils.logger.Logger;
|
||||
* <p>
|
||||
* 代理高德导航地图
|
||||
*/
|
||||
public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
||||
public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
IMogoMapUIController,
|
||||
AMap.OnMarkerClickListener,
|
||||
AMap.OnMapLoadedListener,
|
||||
AMap.OnMapTouchListener,
|
||||
@@ -45,7 +47,8 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
||||
AMap.OnMapClickListener,
|
||||
AMap.OnPolylineClickListener,
|
||||
AMapNaviViewListener,
|
||||
AMapMessageListener {
|
||||
AMapMessageListener,
|
||||
AMap.OnCameraChangeListener {
|
||||
|
||||
private static final String TAG = "AMapNaviViewWrapper";
|
||||
|
||||
@@ -136,9 +139,13 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
||||
mMapView.setOnMapTouchListener( this );
|
||||
mMapView.setOnPolylineClickListener( this );
|
||||
mMapView.setAMapNaviViewListener( this );
|
||||
if ( mMapView.getMap() != null ) {
|
||||
mMapView.getMap().setOnPOIClickListener( this );
|
||||
mMapView.getMap().setOnMapClickListener( this );
|
||||
mMapView.setOnCameraChangeListener( this );
|
||||
|
||||
final AMap aMap = mMapView.getMap();
|
||||
if ( aMap != null ) {
|
||||
aMap.setOnPOIClickListener( this );
|
||||
aMap.setOnMapClickListener( this );
|
||||
aMap.setOnCameraChangeListener( this );
|
||||
}
|
||||
AMapMessageManager.getInstance().registerAMapMessageListener( this );
|
||||
}
|
||||
@@ -425,6 +432,11 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
||||
return getMap().getScalePerPixel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZoomLevel() {
|
||||
return getMap().getZoomLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNaviStarted() {
|
||||
if ( checkAMapView() ) {
|
||||
@@ -443,4 +455,35 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
|
||||
public void onNaviInfoUpdat( NaviInfo naviInfo ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChange( CameraPosition cameraPosition ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraChangeFinish( CameraPosition cameraPosition ) {
|
||||
if ( cameraPosition != null ) {
|
||||
MogoMapListenerHandler.getInstance().onMapChanged( ObjectUtils.fromAMap( cameraPosition.target ), cameraPosition.zoom, cameraPosition.tilt, cameraPosition.bearing );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getCameraNorthEastPosition() {
|
||||
try {
|
||||
return ObjectUtils.fromAMap( mMapView.getMap().getProjection().getVisibleRegion().latLngBounds.northeast );
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getCameraSouthWestPosition() {
|
||||
try {
|
||||
return ObjectUtils.fromAMap( mMapView.getMap().getProjection().getVisibleRegion().latLngBounds.southwest );
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoUiSettings;
|
||||
import com.mogo.map.impl.amap.marker.AMapInfoWindowAdapter;
|
||||
import com.mogo.map.impl.amap.marker.AMapMarkerWrapper;
|
||||
import com.mogo.map.impl.amap.uicontroller.AMapUIController;
|
||||
import com.mogo.map.impl.amap.utils.ObjectUtils;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
@@ -43,6 +44,7 @@ public class AMapWrapper implements IMogoMap {
|
||||
mUIcontroller = controller;
|
||||
// 设置实现自定义 info window
|
||||
mAMap.setInfoWindowAdapter( new AMapInfoWindowAdapter() );
|
||||
AMapUIController.getInstance().initClient( mUIcontroller );
|
||||
}
|
||||
|
||||
public static AMap getAMap() {
|
||||
@@ -205,6 +207,18 @@ public class AMapWrapper implements IMogoMap {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZoomLevel() {
|
||||
if ( checkAMap() ) {
|
||||
try {
|
||||
return mAMap.getCameraPosition().zoom;
|
||||
} catch ( Exception e ) {
|
||||
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private boolean checkAMap() {
|
||||
if ( mAMap == null ) {
|
||||
Logger.e( TAG, "高德map实例为空,请检查" );
|
||||
|
||||
@@ -21,11 +21,6 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
private IMogoMapUIController mClient;
|
||||
|
||||
private AMapUIController() {
|
||||
try {
|
||||
mClient = MogoMap.getInstance().getMogoMap().getUIController();
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, "获取UI控制实例失败", e );
|
||||
}
|
||||
}
|
||||
|
||||
public static AMapUIController getInstance() {
|
||||
@@ -39,6 +34,10 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void initClient( IMogoMapUIController client ) {
|
||||
this.mClient = client;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
@@ -74,7 +73,7 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
@Override
|
||||
public void moveToCenter( MogoLatLng latLng ) {
|
||||
if ( mClient != null ) {
|
||||
mClient.moveToCenter(latLng);
|
||||
mClient.moveToCenter( latLng );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,4 +105,28 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZoomLevel() {
|
||||
if ( mClient != null ) {
|
||||
return mClient.getZoomLevel();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getCameraNorthEastPosition() {
|
||||
if ( mClient != null ) {
|
||||
return mClient.getCameraNorthEastPosition();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getCameraSouthWestPosition() {
|
||||
if ( mClient != null ) {
|
||||
return mClient.getCameraSouthWestPosition();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,5 +114,17 @@ public interface IMogoMap {
|
||||
*/
|
||||
float getScalePerPixel();
|
||||
|
||||
void changeZoom(float zoom);
|
||||
/**
|
||||
* 改变地图缩放级别
|
||||
*
|
||||
* @param zoom
|
||||
*/
|
||||
void changeZoom( float zoom );
|
||||
|
||||
/**
|
||||
* 获取缩放比例
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
float getZoomLevel();
|
||||
}
|
||||
|
||||
@@ -54,4 +54,12 @@ public class MogoLatLng implements Parcelable {
|
||||
return new MogoLatLng[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MogoLatLng{" +
|
||||
"lat=" + lat +
|
||||
", lng=" + lng +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.mogo.map.listener;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
import com.mogo.map.navi.IMogoNaviListener;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
|
||||
/**
|
||||
@@ -54,4 +54,12 @@ public interface IMogoMapListener {
|
||||
* @param ui
|
||||
*/
|
||||
void onMapModeChanged( EnumMapUI ui );
|
||||
|
||||
/**
|
||||
* @param latLng 中点的经纬度
|
||||
* @param zoom 缩放大小
|
||||
* @param tilt 倾斜度
|
||||
* @param bearing 旋转角度
|
||||
*/
|
||||
void onMapChanged( MogoLatLng latLng, float zoom, float tilt, float bearing );
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.map.listener;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
import com.mogo.map.navi.MogoNaviInfo;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
@@ -103,4 +104,13 @@ public class MogoMapListenerHandler implements IMogoMapListener, IMogoMapListene
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapChanged( MogoLatLng location, float zoom, float tilt, float bearing ) {
|
||||
if ( mDelegateListener != null ) {
|
||||
synchronized ( mDelegateListener ) {
|
||||
mDelegateListener.onMapChanged( location, zoom, tilt, bearing );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,4 +66,25 @@ public interface IMogoMapUIController {
|
||||
* @return 当前缩放级别下,地图上1像素点对应的长度,单位米
|
||||
*/
|
||||
float getScalePerPixel();
|
||||
|
||||
/**
|
||||
* 获取缩放比例
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
float getZoomLevel();
|
||||
|
||||
/**
|
||||
* 获取视图东北角坐标
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
MogoLatLng getCameraNorthEastPosition();
|
||||
|
||||
/**
|
||||
* 获取视图西南角坐标
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
MogoLatLng getCameraSouthWestPosition();
|
||||
}
|
||||
|
||||
@@ -98,4 +98,28 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZoomLevel() {
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.getZoomLevel();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getCameraNorthEastPosition() {
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.getCameraNorthEastPosition();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getCameraSouthWestPosition() {
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.getCameraSouthWestPosition();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user