This commit is contained in:
wangcongtao
2020-01-05 16:24:07 +08:00
parent a0aa63b89b
commit 323376dcec
77 changed files with 2518 additions and 567 deletions

View File

@@ -38,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,
@@ -138,10 +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.getMap().setOnCameraChangeListener( 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 );
}
@@ -428,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() ) {
@@ -449,7 +458,6 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
@Override
public void onCameraChange( CameraPosition cameraPosition ) {
}
@Override
@@ -458,4 +466,24 @@ public class AMapNaviViewWrapper implements IMogoMapView, IMogoMapUIController,
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;
}
}

View File

@@ -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实例为空请检查" );

View File

@@ -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;
}
}