dev
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.mogo.map.impl.baidu;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith( AndroidJUnit4.class )
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
|
||||
assertEquals( "com.mogo.map.impl.baidu.test", appContext.getPackageName() );
|
||||
}
|
||||
}
|
||||
28
libraries/map-baidu/src/main/AndroidManifest.xml
Normal file
28
libraries/map-baidu/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,28 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.map.impl.baidu">
|
||||
<!-- 这个权限用于进行网络定位 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<!-- 这个权限用于访问GPS定位 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<!-- 访问网络,进行地图相关业务数据请求,包括地图数据,路线规划,POI检索等 -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<!-- 获取网络状态,根据网络状态切换进行数据请求网络转换 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<!-- 读取外置存储。如果开发者使用了so动态加载功能并且把so文件放在了外置存储区域,则需要申请该权限,否则不需要 -->
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<!-- 写外置存储。如果开发者使用了离线地图,并且数据写在外置存储区域,则需要申请该权限 -->
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<!-- 支持HTTPS-->
|
||||
<application android:networkSecurityConfig="@xml/network_security_config">
|
||||
<service
|
||||
android:name="com.baidu.location.f"
|
||||
android:enabled="true"
|
||||
android:process=":remote" />
|
||||
|
||||
<meta-data
|
||||
android:name="com.baidu.lbsapi.API_KEY"
|
||||
android:value="LSbj9s2Rewt0cciOjTZ2bVVz95MTpnH8" />
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mogo.map.impl.baidu;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.baidu.mapapi.SDKInitializer;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-26
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class BMap {
|
||||
|
||||
public static void init( Context context ) {
|
||||
SDKInitializer.initialize( context.getApplicationContext() );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.mogo.map.impl.baidu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.baidu.mapapi.SDKInitializer;
|
||||
import com.baidu.mapapi.map.MapView;
|
||||
import com.mogo.map.IMogoMapView;
|
||||
import com.mogo.map.MogoBaseMapView;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-25
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class BMapBaseMapView extends MogoBaseMapView {
|
||||
|
||||
public BMapBaseMapView( Context context ) {
|
||||
super( context );
|
||||
init( context );
|
||||
}
|
||||
|
||||
public BMapBaseMapView( Context context, @Nullable AttributeSet attrs ) {
|
||||
super( context, attrs );
|
||||
init( context );
|
||||
}
|
||||
|
||||
public BMapBaseMapView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
init( context );
|
||||
}
|
||||
|
||||
private void init( Context context ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IMogoMapView createMapView( Context context ) {
|
||||
return new BMapViewWrapper( new MapView( context ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.map.impl.baidu;
|
||||
|
||||
import com.baidu.mapapi.map.Marker;
|
||||
import com.mogo.map.impl.baidu.marker.BMapMarkerMap;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* marker 点击事件处理
|
||||
*/
|
||||
public class BMapMarkerClickHandler {
|
||||
|
||||
public boolean handleMarkerClicked( Marker marker ) {
|
||||
IMogoMarker iMogoMarker = BMapMarkerMap.get( marker );
|
||||
if ( iMogoMarker != null ) {
|
||||
IMogoMarkerClickListener listener = iMogoMarker.getOnMarkerClickListener();
|
||||
if ( listener != null ) {
|
||||
return listener.onMarkerClicked( iMogoMarker );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.mogo.map.impl.baidu;
|
||||
|
||||
import com.baidu.mapapi.map.UiSettings;
|
||||
import com.mogo.map.IMogoUiSettings;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
* <p>
|
||||
* 代理高德地图UiSettings
|
||||
*/
|
||||
public class BMapUiSettingsWrapper implements IMogoUiSettings {
|
||||
|
||||
private UiSettings mUiSettings;
|
||||
|
||||
public BMapUiSettingsWrapper( UiSettings mUiSettings ) {
|
||||
this.mUiSettings = mUiSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScaleControlsEnabled( boolean enabled ) {
|
||||
if ( mUiSettings != null ) {
|
||||
mUiSettings.setScrollGesturesEnabled( enabled );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZoomControlsEnabled( boolean enabled ) {
|
||||
if ( mUiSettings != null ) {
|
||||
mUiSettings.setZoomGesturesEnabled( enabled );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompassEnabled( boolean enabled ) {
|
||||
if ( mUiSettings != null ) {
|
||||
mUiSettings.setCompassEnabled( enabled );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMyLocationButtonEnabled( boolean enabled ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScrollGesturesEnabled( boolean enabled ) {
|
||||
if ( mUiSettings != null ) {
|
||||
mUiSettings.setScrollGesturesEnabled( enabled );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZoomGesturesEnabled( boolean enabled ) {
|
||||
if ( mUiSettings != null ) {
|
||||
mUiSettings.setZoomGesturesEnabled( enabled );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTiltGesturesEnabled( boolean enabled ) {
|
||||
if ( mUiSettings != null ) {
|
||||
mUiSettings.setOverlookingGesturesEnabled( enabled );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotateGesturesEnabled( boolean enabled ) {
|
||||
if ( mUiSettings != null ) {
|
||||
mUiSettings.setRotateGesturesEnabled( enabled );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAllGesturesEnabled( boolean enabled ) {
|
||||
if ( mUiSettings != null ) {
|
||||
mUiSettings.setAllGesturesEnabled( enabled );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIndoorSwitchEnabled( boolean enabled ) {
|
||||
// don't edit.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLogoEnable( boolean enabled ) {
|
||||
// don't edit.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.mogo.map.impl.baidu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.baidu.mapapi.map.BaiduMap;
|
||||
import com.baidu.mapapi.map.MapPoi;
|
||||
import com.baidu.mapapi.map.MapView;
|
||||
import com.baidu.mapapi.map.Marker;
|
||||
import com.baidu.mapapi.model.LatLng;
|
||||
import com.baidu.navisdk.adapter.BaiduNaviManagerFactory;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoMapView;
|
||||
import com.mogo.map.impl.baidu.utils.ObjectUtils;
|
||||
import com.mogo.map.listener.MogoMapListenerHandler;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
* <p>
|
||||
* 代理高德导航地图
|
||||
*/
|
||||
public class BMapViewWrapper implements IMogoMapView,
|
||||
BaiduMap.OnMarkerClickListener,
|
||||
BaiduMap.OnMapLoadedCallback,
|
||||
BaiduMap.OnMapTouchListener,
|
||||
BaiduMap.OnMapClickListener {
|
||||
|
||||
private final MapView mMapView;
|
||||
private IMogoMap mIMap;
|
||||
|
||||
private BMapMarkerClickHandler mMarkerClickHandler;
|
||||
|
||||
private static final String TAG = "AMapNaviViewWrapper";
|
||||
|
||||
public BMapViewWrapper( MapView mapView ) {
|
||||
this.mMapView = mapView;
|
||||
mMarkerClickHandler = new BMapMarkerClickHandler();
|
||||
BaiduMap map = mMapView.getMap();
|
||||
if ( map != null ) {
|
||||
map.setOnMarkerClickListener( this );
|
||||
map.setOnMapLoadedCallback( this );
|
||||
map.setOnMapClickListener( this );
|
||||
}
|
||||
}
|
||||
|
||||
private Context getContext() {
|
||||
return mMapView.getContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getMapView() {
|
||||
return mMapView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMap getMap() {
|
||||
if ( mMapView != null ) {
|
||||
if ( mIMap == null ) {
|
||||
mIMap = new BMapWrapper( mMapView.getMap() );
|
||||
}
|
||||
}
|
||||
return mIMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate( Bundle bundle ) {
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onCreate( getContext(), bundle );
|
||||
}
|
||||
if ( BaiduNaviManagerFactory.getRoutePlanManager().isRoutePlanOk() ) {
|
||||
BaiduNaviManagerFactory.getRouteResultManager().onCreate( getContext() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onResume();
|
||||
}
|
||||
if ( BaiduNaviManagerFactory.getRoutePlanManager().isRoutePlanOk() ) {
|
||||
BaiduNaviManagerFactory.getRouteResultManager().onResume();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onPause();
|
||||
}
|
||||
if ( BaiduNaviManagerFactory.getRoutePlanManager().isRoutePlanOk() ) {
|
||||
BaiduNaviManagerFactory.getRouteResultManager().onPause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onDestroy();
|
||||
}
|
||||
|
||||
if ( BaiduNaviManagerFactory.getRoutePlanManager().isRoutePlanOk() ) {
|
||||
BaiduNaviManagerFactory.getRouteResultManager().onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState( Bundle outState ) {
|
||||
if ( mMapView != null ) {
|
||||
mMapView.onSaveInstanceState( outState );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMarkerClick( Marker marker ) {
|
||||
return mMarkerClickHandler.handleMarkerClicked( marker );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
MogoMapListenerHandler.getInstance().onMapLoaded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch( MotionEvent motionEvent ) {
|
||||
MogoMapListenerHandler.getInstance().onTouch( motionEvent );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick( LatLng latLng ) {
|
||||
MogoMapListenerHandler.getInstance().onMapClick( ObjectUtils.fromBMap( latLng ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapPoiClick( MapPoi mapPoi ) {
|
||||
MogoMapListenerHandler.getInstance().onPOIClick( ObjectUtils.fromBMap( mapPoi ) );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.mogo.map.impl.baidu;
|
||||
|
||||
import com.baidu.mapapi.map.BaiduMap;
|
||||
import com.baidu.mapapi.map.Marker;
|
||||
import com.baidu.mapapi.map.MarkerOptions;
|
||||
import com.baidu.mapapi.map.Overlay;
|
||||
import com.baidu.mapapi.map.OverlayOptions;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoUiSettings;
|
||||
import com.mogo.map.impl.baidu.marker.BMapMarkerWrapper;
|
||||
import com.mogo.map.impl.baidu.utils.ObjectUtils;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.marker.MogoMarkersHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
* <p>
|
||||
* 代理高德AMap
|
||||
*/
|
||||
public class BMapWrapper implements IMogoMap {
|
||||
|
||||
private static final String TAG = "BMapWrapper";
|
||||
|
||||
private BaiduMap mBMap;
|
||||
private IMogoUiSettings mUiSettings;
|
||||
|
||||
public BMapWrapper( BaiduMap map ) {
|
||||
this.mBMap = map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoUiSettings getUiSettings() {
|
||||
if ( mUiSettings == null ) {
|
||||
mUiSettings = new BMapUiSettingsWrapper( mBMap.getUiSettings() );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarker addMarker( String tag, MogoMarkerOptions options ) {
|
||||
if ( !checkBMap() ) {
|
||||
return null;
|
||||
}
|
||||
MarkerOptions markerOptions = ObjectUtils.fromMogo( options );
|
||||
if ( markerOptions == null ) {
|
||||
Logger.e( TAG, "marker参数为空" );
|
||||
return null;
|
||||
}
|
||||
final IMogoMarker mogoMarker = new BMapMarkerWrapper( ( Marker ) mBMap.addOverlay( markerOptions ) );
|
||||
MogoMarkersHandler.getInstance().add( tag, mogoMarker );
|
||||
return mogoMarker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList< IMogoMarker > addMarkers( String tag, ArrayList< MogoMarkerOptions > options, boolean moveToCenter ) {
|
||||
if ( !checkBMap() ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( options == null || options.isEmpty() ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List< Overlay > markers = null;
|
||||
ArrayList< OverlayOptions > markerOptions = new ArrayList<>();
|
||||
ArrayList< IMogoMarker > mogoMarkers = new ArrayList<>();
|
||||
|
||||
for ( MogoMarkerOptions option : options ) {
|
||||
if ( option == null ) {
|
||||
continue;
|
||||
}
|
||||
MarkerOptions mo = ObjectUtils.fromMogo( option );
|
||||
if ( mo == null ) {
|
||||
continue;
|
||||
}
|
||||
markerOptions.add( mo );
|
||||
}
|
||||
if ( markerOptions.isEmpty() ) {
|
||||
return null;
|
||||
}
|
||||
markers = mBMap.addOverlays( markerOptions );
|
||||
if ( markers == null || markers.isEmpty() ) {
|
||||
return null;
|
||||
}
|
||||
for ( Overlay marker : markers ) {
|
||||
if ( marker instanceof Marker ) {
|
||||
mogoMarkers.add( new BMapMarkerWrapper( ( ( Marker ) marker ) ) );
|
||||
}
|
||||
}
|
||||
MogoMarkersHandler.getInstance().add( tag, mogoMarkers );
|
||||
return mogoMarkers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
if ( checkBMap() ) {
|
||||
mBMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear( boolean isKeepMyLocationOverlay ) {
|
||||
if ( checkBMap() ) {
|
||||
mBMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPointToCenter( int x, int y ) {
|
||||
if ( checkBMap() ) {
|
||||
Logger.w( TAG, "百度地图未实现该方法 - setPointToCenter" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTouchPoiEnable( boolean touchPoiEnable ) {
|
||||
if ( checkBMap() ) {
|
||||
Logger.w( TAG, "百度地图未实现该方法 - setTouchPoiEnable" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTrafficEnable( boolean enable ) {
|
||||
if ( checkBMap() ) {
|
||||
mBMap.setTrafficEnabled( enable );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showBuildings( boolean enabled ) {
|
||||
if ( checkBMap() ) {
|
||||
Logger.w( TAG, "百度地图未实现该方法 - showBuildings" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showIndoorMap( boolean enable ) {
|
||||
if ( checkBMap() ) {
|
||||
Logger.w( TAG, "百度地图未实现该方法 - showIndoorMap" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMapText( boolean enable ) {
|
||||
if ( checkBMap() ) {
|
||||
Logger.w( TAG, "百度地图未实现该方法 - showMapText" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopAnimation() {
|
||||
if ( checkBMap() ) {
|
||||
Logger.w( TAG, "百度地图未实现该方法 - stopAnimation" );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkBMap() {
|
||||
if ( mBMap == null ) {
|
||||
Logger.e( TAG, "百度map实例为空,请检查" );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package com.mogo.map.impl.baidu.location;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.baidu.location.BDAbstractLocationListener;
|
||||
import com.baidu.location.BDLocation;
|
||||
import com.baidu.location.LocationClient;
|
||||
import com.baidu.location.LocationClientOption;
|
||||
import com.mogo.map.impl.baidu.utils.ObjectUtils;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-19
|
||||
* <p>
|
||||
* 百度定位
|
||||
*/
|
||||
public class BLocationClient implements IMogoLocationClient {
|
||||
|
||||
private static final String TAG = "LocationClient";
|
||||
|
||||
private static volatile BLocationClient sInstance;
|
||||
private static Set< IMogoLocationListener > sListeners = new HashSet<>( 10 );
|
||||
private static MogoLocation sLastLocation = new MogoLocation();
|
||||
|
||||
private BLocationClient( Context context ) {
|
||||
mClient = new LocationClient( context );
|
||||
mClient.registerLocationListener( new InternalLocationListener() );
|
||||
sLastLocation = ObjectUtils.fromBMap( mClient.getLastKnownLocation() );
|
||||
}
|
||||
|
||||
public static BLocationClient getInstance( Context context ) {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( BLocationClient.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new BLocationClient( context );
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private LocationClient mClient;
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
start( 2_000L );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start( long interval ) {
|
||||
stop();
|
||||
LocationClientOption option = new LocationClientOption();
|
||||
option.setLocationMode( LocationClientOption.LocationMode.Hight_Accuracy );
|
||||
option.setIsNeedAddress( true );
|
||||
option.setScanSpan( ( ( int ) interval ) );
|
||||
if ( mClient != null ) {
|
||||
mClient.setLocOption( option );
|
||||
}
|
||||
mClient.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if ( mClient != null ) {
|
||||
mClient.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLocationListener( IMogoLocationListener listener ) {
|
||||
if ( listener != null ) {
|
||||
synchronized ( sListeners ) {
|
||||
sListeners.add( listener );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLocationListener( IMogoLocationListener listener ) {
|
||||
if ( listener != null ) {
|
||||
synchronized ( sListeners ) {
|
||||
sListeners.remove( listener );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLocation getLastKnowLocation() {
|
||||
return sLastLocation;
|
||||
}
|
||||
|
||||
private static class InternalLocationListener extends BDAbstractLocationListener {
|
||||
@Override
|
||||
public void onReceiveLocation( BDLocation bdLocation ) {
|
||||
if ( bdLocation == null ||
|
||||
bdLocation.getLatitude() == 0.0D ||
|
||||
bdLocation.getLongitude() == 0.0D ) {
|
||||
return;
|
||||
}
|
||||
Logger.d( TAG, bdLocation.toString() );
|
||||
sLastLocation = ObjectUtils.fromBMap( bdLocation );
|
||||
synchronized ( sListeners ) {
|
||||
Iterator< IMogoLocationListener > listenerIterator = sListeners.iterator();
|
||||
while ( listenerIterator.hasNext() ) {
|
||||
listenerIterator.next().onLocationChanged( sLastLocation.clone() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mogo.map.impl.baidu.marker;
|
||||
|
||||
import com.baidu.mapapi.map.Marker;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-25
|
||||
* <p>
|
||||
* 管理百度marker和mogoMarker的映射关系
|
||||
*/
|
||||
public class BMapMarkerMap {
|
||||
|
||||
private static Map< Marker, IMogoMarker > sMap = new HashMap<>();
|
||||
|
||||
public static void put( Marker marker, IMogoMarker mogoMarker ) {
|
||||
sMap.put( marker, mogoMarker );
|
||||
}
|
||||
|
||||
public static IMogoMarker get( Marker marker ) {
|
||||
return sMap.get( marker );
|
||||
}
|
||||
|
||||
public static IMogoMarker remove( Marker marker ) {
|
||||
return sMap.remove( marker );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
package com.mogo.map.impl.baidu.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
|
||||
import com.baidu.mapapi.map.BitmapDescriptor;
|
||||
import com.baidu.mapapi.map.BitmapDescriptorFactory;
|
||||
import com.baidu.mapapi.map.InfoWindow;
|
||||
import com.baidu.mapapi.map.Marker;
|
||||
import com.baidu.mapapi.model.LatLng;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.impl.baidu.utils.ObjectUtils;
|
||||
import com.mogo.map.marker.IMogoInfoWindowAdapter;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
* <p>
|
||||
* 高德marker
|
||||
*/
|
||||
public class BMapMarkerWrapper implements IMogoMarker {
|
||||
|
||||
private Marker mMarker;
|
||||
private Object mObject;
|
||||
private IMogoMarkerClickListener mMogoMarkerClickListener;
|
||||
private IMogoInfoWindowAdapter mMogoInfoWindowAdapter;
|
||||
|
||||
private boolean mIsDestroy = false;
|
||||
|
||||
public BMapMarkerWrapper( Marker marker ) {
|
||||
this.mMarker = marker;
|
||||
if ( marker != null ) {
|
||||
// 设置百度 marker 的object对象为 IMogoMarker 实例。!!!!
|
||||
BMapMarkerMap.put( marker, this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
BMapMarkerMap.remove( mMarker );
|
||||
if ( mMarker != null ) {
|
||||
mMarker.remove();
|
||||
mMarker = null;
|
||||
}
|
||||
mMogoInfoWindowAdapter = null;
|
||||
mMogoMarkerClickListener = null;
|
||||
mObject = null;
|
||||
mIsDestroy = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideInfoWindow() {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.hideInfoWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha( float alpha ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setAlpha( alpha );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnchor( float anchorU, float anchorV ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setAnchor( anchorU, anchorV );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDraggable( boolean paramBoolean ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setDraggable( paramBoolean );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIcon( Bitmap icon ) {
|
||||
if ( icon == null || icon.isRecycled() ) {
|
||||
return;
|
||||
}
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setIcon( BitmapDescriptorFactory.fromBitmap( icon ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIcons( ArrayList< Bitmap > icons ) {
|
||||
if ( icons == null || icons.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
ArrayList< BitmapDescriptor > descriptors = new ArrayList<>();
|
||||
for ( Bitmap icon : icons ) {
|
||||
if ( icon == null || icon.isRecycled() ) {
|
||||
continue;
|
||||
}
|
||||
descriptors.add( BitmapDescriptorFactory.fromBitmap( icon ) );
|
||||
}
|
||||
if ( descriptors.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setIcons( descriptors );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInfoWindowEnable( boolean enabled ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarkerOptions( MogoMarkerOptions opt ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject( Object object ) {
|
||||
mObject = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject() {
|
||||
return mObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPeriod( int period ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setPeriod( period );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition( double lat, double lng ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setPosition( new LatLng( lat, lng ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getPosition() {
|
||||
if ( mMarker != null ) {
|
||||
final LatLng latLng = mMarker.getPosition();
|
||||
return ObjectUtils.fromBMap( latLng );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotateAngle( float rotate ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setRotate( rotate );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSnippet( String snippet ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTitle( String title ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setTitle( title );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToTop() {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setToTop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible( boolean visible ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setVisible( visible );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZIndex( int zIndex ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setZIndex( zIndex );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showInfoWindow() {
|
||||
if ( mMarker != null ) {
|
||||
InfoWindow iw = mMarker.getInfoWindow();
|
||||
View infoWindowView = getInfoWindowAdapter().getInfoWindow( this );
|
||||
if ( iw == null ) {
|
||||
iw = new InfoWindow( infoWindowView, mMarker.getPosition(), 0 );
|
||||
mMarker.showInfoWindow( iw );
|
||||
} else {
|
||||
mMarker.updateInfoWindowView( infoWindowView );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnMarkerClickListener( IMogoMarkerClickListener listener ) {
|
||||
mMogoMarkerClickListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getOnMarkerClickListener() {
|
||||
return mMogoMarkerClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInfoWindowAdapter( IMogoInfoWindowAdapter adapter ) {
|
||||
mMogoInfoWindowAdapter = adapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoInfoWindowAdapter getInfoWindowAdapter() {
|
||||
return mMogoInfoWindowAdapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDestroyed() {
|
||||
return mIsDestroy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
package com.mogo.map.impl.baidu.navi;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.view.View;
|
||||
|
||||
import com.baidu.navisdk.adapter.IBNRouteGuideManager;
|
||||
import com.baidu.navisdk.adapter.IBNaviListener;
|
||||
import com.baidu.navisdk.adapter.IBNaviViewListener;
|
||||
import com.baidu.navisdk.adapter.IBaiduNaviManager;
|
||||
import com.baidu.navisdk.adapter.struct.BNHighwayInfo;
|
||||
import com.baidu.navisdk.adapter.struct.BNRoadCondition;
|
||||
import com.baidu.navisdk.adapter.struct.BNaviInfo;
|
||||
import com.baidu.navisdk.adapter.struct.BNaviLocation;
|
||||
import com.baidu.navisdk.ui.routeguide.model.RGLineItem;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-26
|
||||
* <p>
|
||||
* 百度导航监听: 导航初始化,专业导航,导航事件,导航视图事件
|
||||
*/
|
||||
public class BMapNaviListenerAdapter implements
|
||||
IBaiduNaviManager.INaviInitListener,
|
||||
IBNRouteGuideManager.OnNavigationListener,
|
||||
IBNaviListener,
|
||||
IBNaviViewListener {
|
||||
|
||||
private static final String TAG = "BMapNaviListenerAdapter";
|
||||
|
||||
// 导航初始化
|
||||
|
||||
/**
|
||||
* 授权校验结果
|
||||
*
|
||||
* @param status 0 表示成功,其他表示失败
|
||||
* @param msg 具体授权校验失败信息
|
||||
*/
|
||||
@Override
|
||||
public void onAuthResult( int status, String msg ) {
|
||||
if ( status != 0 ) {
|
||||
Logger.i( TAG, "key校验失败:" + msg );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 百度导航初始化开始
|
||||
*/
|
||||
@Override
|
||||
public void initStart() {
|
||||
Logger.i( TAG, "百度导航开始初始化" );
|
||||
}
|
||||
|
||||
/**
|
||||
* 百度导航初始化成功
|
||||
*/
|
||||
@Override
|
||||
public void initSuccess() {
|
||||
Logger.i( TAG, "百度导航初始化成功" );
|
||||
}
|
||||
|
||||
/**
|
||||
* 百度导航初始化失败
|
||||
*/
|
||||
@Override
|
||||
public void initFailed( int errorCode ) {
|
||||
Logger.i( TAG, "百度导航初始化失败:errorcode=" + errorCode );
|
||||
}
|
||||
// 导航初始化 - end
|
||||
|
||||
// 专业导航
|
||||
|
||||
@Override
|
||||
public void onNaviGuideEnd() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOtherAction( int i, int i1, int i2, Object o ) {
|
||||
|
||||
}
|
||||
|
||||
// 专业导航 - end
|
||||
|
||||
// 导航事件
|
||||
|
||||
/**
|
||||
* 当前路名更新
|
||||
*
|
||||
* @param name 当前道路名
|
||||
*/
|
||||
@Override
|
||||
public void onRoadNameUpdate( String name ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 距离目的地的剩余距离
|
||||
*
|
||||
* @param remainDistance 剩余距离,单位米
|
||||
* @param remainTime 剩余时间,单位秒
|
||||
*/
|
||||
@Override
|
||||
public void onRemainInfoUpdate( int remainDistance, int remainTime ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 诱导信息
|
||||
*
|
||||
* @param naviInfo 对应的诱导信息
|
||||
*/
|
||||
@Override
|
||||
public void onGuideInfoUpdate( BNaviInfo naviInfo ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 高速信息
|
||||
*
|
||||
* @param action SHOW: 展示 HIDE: 消隐 UPDATE: 更新信息
|
||||
* @param info 对应的高速信息
|
||||
*/
|
||||
@Override
|
||||
public void onHighWayInfoUpdate( IBNaviListener.Action action, BNHighwayInfo info ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 快速路出口信息
|
||||
*
|
||||
* @param action SHOW: 展示 HIDE: 消隐 UPDATE: 更新信息
|
||||
* @param name 快速路名称
|
||||
* @param dist 离快速路出口的距离
|
||||
* @param id 快速路ID
|
||||
*/
|
||||
@Override
|
||||
public void onFastExitWayInfoUpdate( IBNaviListener.Action action, String name, int dist, String id ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 放大图回调接口
|
||||
*
|
||||
* @param action 显示/刷新/隐藏动作
|
||||
* @param enlargeMap 放大图View
|
||||
* @param remainDistance 剩余距离
|
||||
* @param progress 路口的进度
|
||||
* @param roadName 下一个路名
|
||||
* @param turnIcon 转向标
|
||||
*/
|
||||
@Override
|
||||
public void onEnlargeMapUpdate( IBNaviListener.Action action, View enlargeMap, String remainDistance, int progress, String roadName, Bitmap turnIcon ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 日夜模式改变
|
||||
*
|
||||
* @param style DayNightMode.DAY: 白天 DayNightMode.NIGHT: 黑夜
|
||||
*/
|
||||
@Override
|
||||
public void onDayNightChanged( DayNightMode style ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 路况信息更新
|
||||
*
|
||||
* @param v 车行驶的进度 单位为浮点类型,0-1为0%-100%
|
||||
* @param items 路况信息
|
||||
*/
|
||||
@Override
|
||||
public void onRoadConditionInfoUpdate( double v, List< BNRoadCondition > items ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 主辅路、高架桥信息更新
|
||||
*
|
||||
* @param type {@link com.baidu.navisdk.adapter.BNaviCommonParams.BNMainSideBridge}
|
||||
*/
|
||||
@Override
|
||||
public void onMainSideBridgeUpdate( int type ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 车道线信息更新
|
||||
*
|
||||
* @param action Action.SHOW:显示 Action.HIDE:消隐
|
||||
* @param laneItems 车道线数据
|
||||
*/
|
||||
@Override
|
||||
public void onLaneInfoUpdate( IBNaviListener.Action action, List< RGLineItem > laneItems ) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 速度信息
|
||||
*
|
||||
* @param speed 车速 "--" 代表速度不可信,其他String返回值为数字 km/h
|
||||
* @param isOverSpeed 是否超速
|
||||
*/
|
||||
@Override
|
||||
public void onSpeedUpdate( String speed, boolean isOverSpeed ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 到达目的地后回调函数
|
||||
*/
|
||||
@Override
|
||||
public void onArriveDestination() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 驾车路径导航到达某个途经点的回调函数
|
||||
*/
|
||||
@Override
|
||||
public void onArrivedWayPoint( int index ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 位置变化
|
||||
*
|
||||
* @param bNaviLocation
|
||||
*/
|
||||
@Override
|
||||
public void onLocationChange( BNaviLocation bNaviLocation ) {
|
||||
|
||||
}
|
||||
|
||||
// 导航事件 — end
|
||||
|
||||
// 导航视图事件
|
||||
|
||||
/**
|
||||
* 诱导面板的点击事件
|
||||
*/
|
||||
@Override
|
||||
public void onMainInfoPanCLick() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 界面左上角转向操作的点击回调
|
||||
*/
|
||||
@Override
|
||||
public void onNaviTurnClick() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 全览按钮的点击回调
|
||||
*/
|
||||
@Override
|
||||
public void onFullViewButtonClick( boolean show ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 全览小窗口的点击
|
||||
*/
|
||||
@Override
|
||||
public void onFullViewWindowClick( boolean show ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航页面左下角退出按钮点击后的回调接口
|
||||
*/
|
||||
@Override
|
||||
public void onNaviBackClick() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 底部中间部分点击事件
|
||||
*/
|
||||
@Override
|
||||
public void onBottomBarClick( IBNaviViewListener.Action action ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 界面右下角功能设置按钮的回调接口
|
||||
*
|
||||
* @param isOpen 设置界面是否打开
|
||||
*/
|
||||
@Override
|
||||
public void onNaviSetting( boolean isOpen ) {
|
||||
|
||||
}
|
||||
|
||||
// 导航视图事件 - end
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
package com.mogo.map.impl.baidu.navi;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
import com.baidu.navisdk.adapter.BNRoutePlanNode;
|
||||
import com.baidu.navisdk.adapter.BaiduNaviManagerFactory;
|
||||
import com.baidu.navisdk.adapter.IBNRoutePlanManager;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.impl.baidu.location.BLocationClient;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
import com.mogo.map.navi.MogoNaviConfig;
|
||||
import com.mogo.utils.TipToast;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-25
|
||||
* <p>
|
||||
* 高德导航
|
||||
*/
|
||||
public class NaviClient implements IMogoNavi {
|
||||
|
||||
private static final String TAG = "NaviClient";
|
||||
private final Context mContext;
|
||||
|
||||
private NaviListenerAdapter mBMapNaviListener;
|
||||
|
||||
/**
|
||||
* 导航策略配置
|
||||
*/
|
||||
private MogoNaviConfig mMogoNaviConfig = new MogoNaviConfig();
|
||||
|
||||
private static volatile NaviClient sInstance;
|
||||
|
||||
private NaviClient( Context context ) {
|
||||
mContext = context;
|
||||
mBMapNaviListener = new NaviListenerAdapter();
|
||||
BaiduNaviManagerFactory.getBaiduNaviManager().init( context, "", "", mBMapNaviListener );
|
||||
}
|
||||
|
||||
public static NaviClient getInstance( Context context ) {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( NaviClient.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new NaviClient( context );
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void naviTo( MogoLatLng endPoint ) {
|
||||
naviTo( endPoint, mMogoNaviConfig );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void naviTo( MogoLatLng endPoint, MogoNaviConfig config ) {
|
||||
naviTo( endPoint, null, config );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints ) {
|
||||
naviTo( endPoint, wayPoints, mMogoNaviConfig );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void naviTo( MogoLatLng endPoint, List< MogoLatLng > wayPoints, MogoNaviConfig config ) {
|
||||
if ( !checkAMapNavi() ) {
|
||||
return;
|
||||
}
|
||||
Logger.i( TAG, "开始规划路径" );
|
||||
mMogoNaviConfig = config;
|
||||
if ( mMogoNaviConfig == null ) {
|
||||
mMogoNaviConfig = new MogoNaviConfig();
|
||||
}
|
||||
MogoLocation location = BLocationClient.getInstance( mContext ).getLastKnowLocation();
|
||||
if ( location == null ) {
|
||||
location = new MogoLocation();
|
||||
}
|
||||
List< BNRoutePlanNode > nodes = new ArrayList<>();
|
||||
BNRoutePlanNode sNode = getBNRoutePlanNode( location );
|
||||
if ( sNode == null ) {
|
||||
TipToast.shortTip( "起点错误,请开启定位功能" );
|
||||
return;
|
||||
}
|
||||
nodes.add( sNode );
|
||||
if ( wayPoints != null && !wayPoints.isEmpty() ) {
|
||||
for ( MogoLatLng wayPoint : wayPoints ) {
|
||||
if ( wayPoint == null ) {
|
||||
continue;
|
||||
}
|
||||
nodes.add( getBNRoutePlanNode( wayPoint ) );
|
||||
}
|
||||
}
|
||||
BNRoutePlanNode eNode = getBNRoutePlanNode( endPoint );
|
||||
if ( eNode == null ) {
|
||||
if ( sNode == null ) {
|
||||
TipToast.shortTip( "终点错误,请确认" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
nodes.add( eNode );
|
||||
Bundle extras = new Bundle();
|
||||
|
||||
int strategy = IBNRoutePlanManager.RoutePlanPreference.ROUTE_PLAN_PREFERENCE_DEFAULT;
|
||||
|
||||
BaiduNaviManagerFactory.getRoutePlanManager().routeplanToNavi( nodes, strategy, extras, new Handler( Looper.getMainLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
switch ( msg.what ) {
|
||||
case IBNRoutePlanManager.MSG_NAVI_ROUTE_PLAN_START:
|
||||
Logger.i( TAG, "算路开始" );
|
||||
break;
|
||||
case IBNRoutePlanManager.MSG_NAVI_ROUTE_PLAN_SUCCESS:
|
||||
Logger.i( TAG, "算路成功" );
|
||||
break;
|
||||
case IBNRoutePlanManager.MSG_NAVI_ROUTE_PLAN_FAILED:
|
||||
Logger.i( TAG, "算路失败" );
|
||||
break;
|
||||
case IBNRoutePlanManager.MSG_NAVI_ROUTE_PLAN_TO_NAVI:
|
||||
Logger.i( TAG, "算路成功准备进入导航" );
|
||||
BaiduNaviManagerFactory.getRouteResultManager().startNavi();
|
||||
break;
|
||||
default:
|
||||
// nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private BNRoutePlanNode getBNRoutePlanNode( MogoLatLng latLng ) {
|
||||
if ( latLng == null ) {
|
||||
return null;
|
||||
}
|
||||
return new BNRoutePlanNode.Builder()
|
||||
.latitude( latLng.lat )
|
||||
.longitude( latLng.lng )
|
||||
.coordinateType( BNRoutePlanNode.CoordinateType.GCJ02 )
|
||||
.build();
|
||||
}
|
||||
|
||||
private BNRoutePlanNode getBNRoutePlanNode( MogoLocation latLng ) {
|
||||
if ( latLng == null ) {
|
||||
return null;
|
||||
}
|
||||
return new BNRoutePlanNode.Builder()
|
||||
.latitude( latLng.getLatitude() )
|
||||
.longitude( latLng.getLongitude() )
|
||||
.coordinateType( BNRoutePlanNode.CoordinateType.GCJ02 )
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reCalculateRoute( MogoNaviConfig config ) {
|
||||
if ( !checkAMapNavi() ) {
|
||||
return;
|
||||
}
|
||||
mMogoNaviConfig = config;
|
||||
if ( mMogoNaviConfig == null ) {
|
||||
mMogoNaviConfig = new MogoNaviConfig();
|
||||
}
|
||||
// int strategy = mAMapNavi.strategyConvert( mMogoNaviConfig.isCongestion(), mMogoNaviConfig.isAvoidSpeed(), mMogoNaviConfig.isCost(), mMogoNaviConfig.isHighSpeed(), config.isMultipleRoute() );
|
||||
// mAMapNavi.reCalculateRoute( strategy );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopNavi() {
|
||||
BaiduNaviManagerFactory.getRouteGuideManager().forceQuitNaviWithoutDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNaviing() {
|
||||
if ( mBMapNaviListener != null ) {
|
||||
return mBMapNaviListener.isNaviing();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// -- end
|
||||
|
||||
private boolean checkAMapNavi() {
|
||||
// if ( mAMapNavi == null ) {
|
||||
//// throw new MogoMapException( new NullPointerException( "高德导航实例为空!!!" ) );
|
||||
// Logger.e( TAG, "高德导航实例为空!!!" );
|
||||
// return false;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isRealNavi() {
|
||||
if ( mMogoNaviConfig != null ) {
|
||||
return mMogoNaviConfig.isRealNavi();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mogo.map.impl.baidu.navi;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-26
|
||||
* <p>
|
||||
* 百度导航
|
||||
*/
|
||||
public class NaviListenerAdapter extends BMapNaviListenerAdapter {
|
||||
|
||||
private boolean isNaviing = false;
|
||||
|
||||
public void setNaviing( boolean naviing ) {
|
||||
isNaviing = naviing;
|
||||
}
|
||||
|
||||
public boolean isNaviing() {
|
||||
return isNaviing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArriveDestination() {
|
||||
isNaviing = true;
|
||||
super.onArriveDestination();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.mogo.map.impl.baidu.search;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.baidu.mapapi.search.geocode.GeoCodeOption;
|
||||
import com.baidu.mapapi.search.geocode.GeoCodeResult;
|
||||
import com.baidu.mapapi.search.geocode.GeoCoder;
|
||||
import com.baidu.mapapi.search.geocode.OnGetGeoCoderResultListener;
|
||||
import com.baidu.mapapi.search.geocode.ReverseGeoCodeOption;
|
||||
import com.baidu.mapapi.search.geocode.ReverseGeoCodeResult;
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
import com.mogo.map.impl.baidu.utils.ObjectUtils;
|
||||
import com.mogo.map.search.geo.IMogoGeoSearch;
|
||||
import com.mogo.map.search.geo.IMogoGeoSearchListener;
|
||||
import com.mogo.map.search.geo.MogoGeocodeAddress;
|
||||
import com.mogo.map.search.geo.MogoRegeocodeAddress;
|
||||
import com.mogo.map.search.geo.query.MogoGeocodeQuery;
|
||||
import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-19
|
||||
* <p>
|
||||
* 百度地理编码/逆地理编码
|
||||
*/
|
||||
public class GeocodeSearchClient implements IMogoGeoSearch, OnGetGeoCoderResultListener {
|
||||
|
||||
private GeoCoder mClient;
|
||||
private IMogoGeoSearchListener mListener;
|
||||
|
||||
public GeocodeSearchClient( Context context ) {
|
||||
mClient = GeoCoder.newInstance();
|
||||
mClient.setOnGetGeoCodeResultListener( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGeoSearchListener( IMogoGeoSearchListener listener ) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoRegeocodeAddress getFromLocation( MogoRegeocodeQuery query ) throws MogoMapException {
|
||||
throw new MogoMapException( "百度地图不支持同步获取逆地理位置编码" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public List< MogoGeocodeAddress > getFromLocationName( MogoGeocodeQuery query ) throws MogoMapException {
|
||||
throw new MogoMapException( "百度地图不支持同步获取地理位置编码" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFromLocationAsyn( MogoRegeocodeQuery query ) {
|
||||
if ( mClient != null ) {
|
||||
mClient.reverseGeoCode( new ReverseGeoCodeOption()
|
||||
.location( ObjectUtils.fromMogo2( query.getPoint() ) )
|
||||
.newVersion( 1 )
|
||||
.radius( query.getRadius() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFromLocationNameAsyn( MogoGeocodeQuery query ) {
|
||||
if ( mClient != null ) {
|
||||
mClient.geocode( new GeoCodeOption()
|
||||
.city( query.getCity() )
|
||||
.address( query.getLocationName() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetGeoCodeResult( GeoCodeResult geoCodeResult ) {
|
||||
if ( mListener != null ) {
|
||||
mListener.onGeocodeSearched( ObjectUtils.fromBMap( geoCodeResult ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetReverseGeoCodeResult( ReverseGeoCodeResult reverseGeoCodeResult ) {
|
||||
if ( mListener != null ) {
|
||||
mListener.onRegeocodeSearched( ObjectUtils.fromBMap( reverseGeoCodeResult ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
mClient = null;
|
||||
mListener = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.mogo.map.impl.baidu.search;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.baidu.mapapi.search.core.SearchResult;
|
||||
import com.baidu.mapapi.search.sug.OnGetSuggestionResultListener;
|
||||
import com.baidu.mapapi.search.sug.SuggestionResult;
|
||||
import com.baidu.mapapi.search.sug.SuggestionSearch;
|
||||
import com.baidu.mapapi.search.sug.SuggestionSearchOption;
|
||||
import com.mogo.map.impl.baidu.utils.ObjectUtils;
|
||||
import com.mogo.map.search.inputtips.IMogoInputtipsListener;
|
||||
import com.mogo.map.search.inputtips.IMogoInputtipsSearch;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-20
|
||||
* <p>
|
||||
* 百度地图 inputtips 搜索实现
|
||||
*/
|
||||
public class InputtipsSearch implements IMogoInputtipsSearch, OnGetSuggestionResultListener {
|
||||
|
||||
private static final String TAG = "InputtipsSearch";
|
||||
|
||||
private SuggestionSearch mClient;
|
||||
private SuggestionSearchOption mQuery;
|
||||
private IMogoInputtipsListener mListener;
|
||||
|
||||
public InputtipsSearch( Context context, MogoInputtipsQuery query ) {
|
||||
mQuery = ObjectUtils.fromMogo( query );
|
||||
mClient = SuggestionSearch.newInstance();
|
||||
mClient.setOnGetSuggestionResultListener( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuery( MogoInputtipsQuery query ) {
|
||||
this.mQuery = ObjectUtils.fromMogo( query );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInputtipsListener( IMogoInputtipsListener listener ) {
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestInputtipsAsyn() {
|
||||
if ( mClient != null ) {
|
||||
mClient.requestSuggestion( mQuery );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetSuggestionResult( SuggestionResult suggestionResult ) {
|
||||
if ( suggestionResult.error == SearchResult.ERRORNO.NO_ERROR ) {
|
||||
if ( mListener != null ) {
|
||||
mListener.onGetInputtips( getResult( suggestionResult.getAllSuggestions() ) );
|
||||
}
|
||||
} else {
|
||||
Logger.e( TAG, "errorcode = " + suggestionResult.error );
|
||||
}
|
||||
}
|
||||
|
||||
private List< MogoTip > getResult( List< SuggestionResult.SuggestionInfo > suggestionInfos ) {
|
||||
List< MogoTip > mogoTips = new ArrayList<>();
|
||||
if ( suggestionInfos != null ) {
|
||||
for ( SuggestionResult.SuggestionInfo tip : suggestionInfos ) {
|
||||
MogoTip mogoTip = ObjectUtils.fromBMap( tip );
|
||||
if ( mogoTip != null ) {
|
||||
mogoTips.add( mogoTip );
|
||||
}
|
||||
}
|
||||
}
|
||||
return mogoTips;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
if ( mClient != null ) {
|
||||
mClient.destroy();
|
||||
}
|
||||
mClient = null;
|
||||
mListener = null;
|
||||
mQuery = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.mogo.map.impl.baidu.search;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.baidu.mapapi.search.poi.OnGetPoiSearchResultListener;
|
||||
import com.baidu.mapapi.search.poi.PoiDetailResult;
|
||||
import com.baidu.mapapi.search.poi.PoiDetailSearchResult;
|
||||
import com.baidu.mapapi.search.poi.PoiIndoorResult;
|
||||
import com.baidu.mapapi.search.poi.PoiResult;
|
||||
import com.baidu.mapapi.search.poi.PoiSearch;
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
import com.mogo.map.search.geo.MogoPoiItem;
|
||||
import com.mogo.map.search.poisearch.IMogoPoiSearch;
|
||||
import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
|
||||
import com.mogo.map.search.poisearch.MogoPoiResult;
|
||||
import com.mogo.map.search.poisearch.MogoSearchBound;
|
||||
import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* 百度poi搜索
|
||||
* <p>
|
||||
*/
|
||||
public class PoiSearchClient implements IMogoPoiSearch, OnGetPoiSearchResultListener {
|
||||
|
||||
private static final String TAG = "PoiSearchClient";
|
||||
|
||||
private MogoPoiSearchQuery mQuery;
|
||||
private PoiSearch mClient;
|
||||
private IMogoPoiSearchListener mListener;
|
||||
private MogoSearchBound mBound;
|
||||
|
||||
public PoiSearchClient( Context context, MogoPoiSearchQuery query ) {
|
||||
mQuery = query;
|
||||
mClient = PoiSearch.newInstance();
|
||||
mClient.setOnGetPoiSearchResultListener( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPoiSearchListener( IMogoPoiSearchListener listener ) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void searchPOIAsyn() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoPoiResult searchPOI() throws MogoMapException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuery( MogoPoiSearchQuery query ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoPoiItem searchPOIId( String poiId ) throws MogoMapException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void searchPOIIdAsyn( String poiId ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBound( MogoSearchBound bound ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetPoiResult( PoiResult poiResult ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetPoiDetailResult( PoiDetailResult poiDetailResult ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetPoiDetailResult( PoiDetailSearchResult poiDetailSearchResult ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGetPoiIndoorResult( PoiIndoorResult poiIndoorResult ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
mQuery = null;
|
||||
mClient = null;
|
||||
mListener = null;
|
||||
mBound = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.mogo.map.impl.baidu.utils;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-10-04
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MapStyleUtils {
|
||||
|
||||
enum ColorEnum {
|
||||
route_overlay_line_normal( Color.parseColor( "#7AD9B4" ) ),
|
||||
route_overlay_line_unknown( Color.parseColor( "#3CD26E" ) ),
|
||||
route_overlay_line_slow( Color.parseColor( "#EFCC7A" ) ),
|
||||
route_overlay_line_very_traffic( Color.parseColor( "#E16262" ) ),
|
||||
route_overlay_line_traffic( Color.parseColor( "#E88181" ) ),
|
||||
transparent( Color.parseColor( "#00000000" ) ),
|
||||
light_gray( Color.parseColor( "#CDD8FF" ) );
|
||||
|
||||
private int color;
|
||||
|
||||
ColorEnum( int color ) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
// public static RouteOverlayOptions getRouteOverlayOptions() {
|
||||
// RouteOverlayOptions options = new RouteOverlayOptions();
|
||||
// // 设置导航线路的宽度
|
||||
// options.setLineWidth( 16 );
|
||||
// // 设置交通状况情况良好下的纹理位图
|
||||
// options.setSmoothTraffic( colorToBitmap( ColorEnum.route_overlay_line_normal.getColor() ) );
|
||||
// // 设置路线的图标
|
||||
// options.setNormalRoute( colorToBitmap( ColorEnum.route_overlay_line_normal.getColor() ) );
|
||||
// // 设置交通状况未知下的纹理位图
|
||||
// options.setUnknownTraffic( colorToBitmap( ColorEnum.route_overlay_line_unknown.getColor() ) );
|
||||
// // 设置交通状况迟缓下的纹理位图
|
||||
// options.setSlowTraffic( colorToBitmap( ColorEnum.route_overlay_line_slow.getColor() ) );
|
||||
// // 设置交通状况非常拥堵下的纹理位图
|
||||
// options.setVeryJamTraffic( colorToBitmap( ColorEnum.route_overlay_line_very_traffic.getColor() ) );
|
||||
// // 设置交通状况拥堵下的纹理位图
|
||||
// options.setJamTraffic( colorToBitmap( ColorEnum.route_overlay_line_traffic.getColor() ) );
|
||||
// // 设置浮于道路上的『小箭头』图标的纹理位图
|
||||
// options.setArrowOnTrafficRoute( colorToBitmap( ColorEnum.transparent.getColor() ) );
|
||||
// // 自定义走过路线纹理,默认走过路线置灰功能为关,需要在AMapNaviViewOptions.setAfterRouteAutoGray(boolean)打开,该方法才生效
|
||||
// options.setPassRoute( colorToBitmap( ColorEnum.light_gray.getColor() ) );
|
||||
// // 设置路线虚线纹理
|
||||
// options.setFairWayRes( colorToBitmap( ColorEnum.route_overlay_line_normal.getColor() ) );
|
||||
// return options;
|
||||
// }
|
||||
|
||||
public static Bitmap colorToBitmap( int color ) {
|
||||
Bitmap.Config config = Bitmap.Config.ARGB_8888;
|
||||
Bitmap bitmap = Bitmap.createBitmap( 1, 1, config );
|
||||
bitmap.eraseColor( color );
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,596 @@
|
||||
package com.mogo.map.impl.baidu.utils;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.baidu.location.BDLocation;
|
||||
import com.baidu.location.Poi;
|
||||
import com.baidu.mapapi.map.BitmapDescriptor;
|
||||
import com.baidu.mapapi.map.BitmapDescriptorFactory;
|
||||
import com.baidu.mapapi.map.MapPoi;
|
||||
import com.baidu.mapapi.map.MarkerOptions;
|
||||
import com.baidu.mapapi.model.LatLng;
|
||||
import com.baidu.mapapi.search.geocode.GeoCodeResult;
|
||||
import com.baidu.mapapi.search.geocode.ReverseGeoCodeResult;
|
||||
import com.baidu.mapapi.search.sug.SuggestionResult;
|
||||
import com.baidu.mapapi.search.sug.SuggestionSearchOption;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
import com.mogo.map.search.geo.MogoGeocodeAddress;
|
||||
import com.mogo.map.search.geo.MogoGeocodeResult;
|
||||
import com.mogo.map.search.geo.MogoRegeocodeAddress;
|
||||
import com.mogo.map.search.geo.MogoRegeocodeResult;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-18
|
||||
* <p>
|
||||
* 业务对象和实际对象转换
|
||||
*/
|
||||
public class ObjectUtils {
|
||||
|
||||
public static MarkerOptions fromMogo( MogoMarkerOptions opt ) {
|
||||
|
||||
if ( opt == null ) {
|
||||
return null;
|
||||
}
|
||||
ArrayList< BitmapDescriptor > descriptors = new ArrayList<>();
|
||||
final ArrayList< Bitmap > icons = opt.getIcons();
|
||||
if ( icons != null && !icons.isEmpty() ) {
|
||||
for ( Bitmap icon : icons ) {
|
||||
if ( icon == null || icon.isRecycled() ) {
|
||||
continue;
|
||||
}
|
||||
descriptors.add( BitmapDescriptorFactory.fromBitmap( icon ) );
|
||||
}
|
||||
}
|
||||
|
||||
return new MarkerOptions()
|
||||
.position( new LatLng( opt.getLatitude(), opt.getLongitude() ) )
|
||||
.title( opt.getTitle() )
|
||||
.icon( BitmapDescriptorFactory.fromBitmap( opt.getIcon() ) )
|
||||
.icons( descriptors )
|
||||
.clickable( true )
|
||||
.period( opt.getPeriod() )
|
||||
.rotate( opt.getRotate() )
|
||||
.flat( opt.isFlat() )
|
||||
.visible( opt.isVisible() )
|
||||
.alpha( opt.getAlpha() )
|
||||
.anchor( opt.getU(), opt.getV() )
|
||||
.draggable( opt.isDraggable() )
|
||||
.zIndex( opt.getzIndex() );
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
public static MogoLocation fromBMap( BDLocation bdLocation ) {
|
||||
if ( bdLocation == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoLocation location = new MogoLocation();
|
||||
location.setLocType( bdLocation.getLocType() );
|
||||
location.setSpeed( bdLocation.getSpeed() );
|
||||
location.setLatitude( bdLocation.getLatitude() );
|
||||
location.setLongitude( bdLocation.getLongitude() );
|
||||
location.setAltitude( bdLocation.getAltitude() );
|
||||
// location.setTime( bdLocation.getTime() );
|
||||
// location.setBearing( bdLocation.getBearing() );
|
||||
location.setAccuracy( bdLocation.getGpsAccuracyStatus() );
|
||||
location.setCityCode( bdLocation.getCityCode() );
|
||||
location.setCityName( bdLocation.getCity() );
|
||||
// location.setProvider( bdLocation.getProvider() );
|
||||
location.setAddress( bdLocation.getAddress().address );
|
||||
location.setDistrict( bdLocation.getDistrict() );
|
||||
location.setProvince( bdLocation.getProvince() );
|
||||
location.setAdCode( bdLocation.getAdCode() );
|
||||
// location.setLocationDetail( bdLocation.getLocationDetail() );
|
||||
// location.setPoiName( bdLocation.getPoiName() );
|
||||
// location.setAoiName( bdLocation.getAoiName() );
|
||||
// location.setErrCode( bdLocation.getErrorCode() );
|
||||
// location.setErrInfo( bdLocation.getErrorInfo() );
|
||||
location.setStreetNum( bdLocation.getStreetNumber() );
|
||||
location.setDescription( bdLocation.getLocationDescribe() );
|
||||
location.setBuildingId( bdLocation.getBuildingID() );
|
||||
location.setFloor( bdLocation.getFloor() );
|
||||
location.setGpsAccuracyStatus( bdLocation.getGpsAccuracyStatus() );
|
||||
location.setSatellite( bdLocation.getSatelliteNumber() );
|
||||
return location;
|
||||
}
|
||||
|
||||
//
|
||||
// public static LatLonPoint fromMogo( MogoLatLng latLng ) {
|
||||
// if ( latLng == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// return new LatLonPoint( latLng.lat, latLng.lng );
|
||||
// }
|
||||
//
|
||||
// public static NaviLatLng fromMogoAsNavi( MogoLatLng latLng ) {
|
||||
// if ( latLng == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// return new NaviLatLng( latLng.lat, latLng.lng );
|
||||
// }
|
||||
//
|
||||
public static LatLng fromMogo2( MogoLatLng latLng ) {
|
||||
if ( latLng == null ) {
|
||||
return null;
|
||||
}
|
||||
return new LatLng( latLng.lat, latLng.lng );
|
||||
}
|
||||
|
||||
//
|
||||
// public static MogoLatLng fromBMap( LatLonPoint point ) {
|
||||
// if ( point == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// return new MogoLatLng( point.getLatitude(), point.getLongitude() );
|
||||
// }
|
||||
//
|
||||
public static MogoLatLng fromBMap( LatLng point ) {
|
||||
if ( point == null ) {
|
||||
return null;
|
||||
}
|
||||
return new MogoLatLng( point.latitude, point.longitude );
|
||||
}
|
||||
|
||||
public static MogoPoi fromBMap( MapPoi poi ) {
|
||||
if ( poi == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoPoi mogoPoi = new MogoPoi();
|
||||
mogoPoi.setCoordinate( fromBMap( poi.getPosition() ) );
|
||||
mogoPoi.setName( poi.getName() );
|
||||
mogoPoi.setPoiId( poi.getUid() );
|
||||
return mogoPoi;
|
||||
}
|
||||
|
||||
//
|
||||
// public static GeocodeQuery fromMogo( MogoGeocodeQuery query ) {
|
||||
// if ( query == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// GeocodeQuery q = new GeocodeQuery( query.getLocationName(), query.getCity() );
|
||||
// return q;
|
||||
// }
|
||||
//
|
||||
// public static RegeocodeQuery fromMogo( MogoRegeocodeQuery query ) {
|
||||
// if ( query == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// RegeocodeQuery q = new RegeocodeQuery( fromMogo( query.getPoint() ), query.getRadius(), query.getLatlngType() );
|
||||
// return q;
|
||||
// }
|
||||
//
|
||||
// public static MogoAoiItem fromBMap( AoiItem amapItem ) {
|
||||
// if ( amapItem == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoAoiItem mogoAoiItem = new MogoAoiItem();
|
||||
// mogoAoiItem.setAdCode( amapItem.getAdCode() );
|
||||
// mogoAoiItem.setAoiArea( amapItem.getAoiArea() );
|
||||
// mogoAoiItem.setAoiCenterPoint( fromBMap( amapItem.getAoiCenterPoint() ) );
|
||||
// mogoAoiItem.setAoiId( amapItem.getAoiId() );
|
||||
// mogoAoiItem.setAoiName( amapItem.getAoiName() );
|
||||
// return mogoAoiItem;
|
||||
// }
|
||||
//
|
||||
// public static MogoBusinessArea fromBMap( BusinessArea amapItem ) {
|
||||
// if ( amapItem == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoBusinessArea mogoBusinessArea = new MogoBusinessArea();
|
||||
// mogoBusinessArea.setCenterPoint( fromBMap( amapItem.getCenterPoint() ) );
|
||||
// mogoBusinessArea.setName( amapItem.getName() );
|
||||
// return mogoBusinessArea;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static MogoCrossroad fromBMap( Crossroad amapItem ) {
|
||||
// if ( amapItem == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoCrossroad mogoCrossroad = new MogoCrossroad();
|
||||
// mogoCrossroad.setDirection( amapItem.getDirection() );
|
||||
// mogoCrossroad.setDistance( amapItem.getDistance() );
|
||||
// mogoCrossroad.setFirstRoadId( amapItem.getFirstRoadId() );
|
||||
// mogoCrossroad.setFirstRoadName( amapItem.getFirstRoadName() );
|
||||
// mogoCrossroad.setSecondRoadId( amapItem.getSecondRoadId() );
|
||||
// mogoCrossroad.setSecondRoadName( amapItem.getSecondRoadName() );
|
||||
// return mogoCrossroad;
|
||||
// }
|
||||
//
|
||||
// public static MogoGeocodeAddress fromBMap( GeocodeAddress address ) {
|
||||
// if ( address == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoGeocodeAddress mogoGeocodeAddress = new MogoGeocodeAddress();
|
||||
// mogoGeocodeAddress.setAdcode( address.getAdcode() );
|
||||
// mogoGeocodeAddress.setBuilding( address.getBuilding() );
|
||||
// mogoGeocodeAddress.setCity( address.getCity() );
|
||||
// mogoGeocodeAddress.setDistrict( address.getDistrict() );
|
||||
// mogoGeocodeAddress.setFormatAddress( address.getFormatAddress() );
|
||||
// mogoGeocodeAddress.setLatlng( fromBMap( address.getLatLonPoint() ) );
|
||||
// mogoGeocodeAddress.setLevel( address.getLevel() );
|
||||
// mogoGeocodeAddress.setNeighborhood( address.getNeighborhood() );
|
||||
// mogoGeocodeAddress.setProvince( address.getProvince() );
|
||||
// mogoGeocodeAddress.setTownship( address.getTownship() );
|
||||
// return mogoGeocodeAddress;
|
||||
// }
|
||||
|
||||
//
|
||||
public static MogoGeocodeResult fromBMap( GeoCodeResult result ) {
|
||||
if ( result == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoGeocodeResult mogoGeocodeResult = new MogoGeocodeResult();
|
||||
final List< MogoGeocodeAddress > addresses = new ArrayList<>();
|
||||
MogoGeocodeAddress mogoGeocodeAddress = new MogoGeocodeAddress();
|
||||
mogoGeocodeAddress.setLatlng( fromBMap( result.getLocation() ) );
|
||||
mogoGeocodeResult.setAddresses( addresses );
|
||||
return mogoGeocodeResult;
|
||||
}
|
||||
|
||||
//
|
||||
// public static MogoIndoorData fromBMap( IndoorData data ) {
|
||||
// if ( data == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoIndoorData mogoIndoorData = new MogoIndoorData();
|
||||
// mogoIndoorData.setFloor( data.getFloor() );
|
||||
// mogoIndoorData.setFloorName( data.getFloorName() );
|
||||
// mogoIndoorData.setPoiId( data.getPoiId() );
|
||||
// return mogoIndoorData;
|
||||
// }
|
||||
//
|
||||
// public static MogoPhoto fromBMap( Photo photo ) {
|
||||
// if ( photo == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoPhoto mogoPhoto = new MogoPhoto();
|
||||
// mogoPhoto.setTitle( photo.getTitle() );
|
||||
// mogoPhoto.setUrl( photo.getUrl() );
|
||||
// return mogoPhoto;
|
||||
// }
|
||||
//
|
||||
// public static MogoPoiItemExtension fromBMap( PoiItemExtension poiItemExtension ) {
|
||||
// if ( poiItemExtension == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoPoiItemExtension mogoPoiItemExtension = new MogoPoiItemExtension();
|
||||
// mogoPoiItemExtension.setOpentime( poiItemExtension.getOpentime() );
|
||||
// mogoPoiItemExtension.setRating( poiItemExtension.getmRating() );
|
||||
// return mogoPoiItemExtension;
|
||||
// }
|
||||
//
|
||||
// public static MogoRegeocodeRoad fromBMap( RegeocodeRoad regeocodeRoad ) {
|
||||
// if ( regeocodeRoad == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoRegeocodeRoad mogoRegeocodeRoad = new MogoRegeocodeRoad();
|
||||
// mogoRegeocodeRoad.setDirection( regeocodeRoad.getDirection() );
|
||||
// mogoRegeocodeRoad.setDistance( regeocodeRoad.getDistance() );
|
||||
// mogoRegeocodeRoad.setId( regeocodeRoad.getId() );
|
||||
// mogoRegeocodeRoad.setName( regeocodeRoad.getName() );
|
||||
// mogoRegeocodeRoad.setPoint( fromBMap( regeocodeRoad.getLatLngPoint() ) );
|
||||
// return mogoRegeocodeRoad;
|
||||
// }
|
||||
//
|
||||
// public static MogoStreetNumber fromBMap( StreetNumber streetNumber ) {
|
||||
// if ( streetNumber == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoStreetNumber mogoStreetNumber = new MogoStreetNumber();
|
||||
// mogoStreetNumber.setDirection( streetNumber.getDirection() );
|
||||
// mogoStreetNumber.setDistance( streetNumber.getDistance() );
|
||||
// mogoStreetNumber.setLatLonPoint( fromBMap( streetNumber.getLatLonPoint() ) );
|
||||
// mogoStreetNumber.setNumber( streetNumber.getNumber() );
|
||||
// mogoStreetNumber.setStreet( streetNumber.getStreet() );
|
||||
// return mogoStreetNumber;
|
||||
// }
|
||||
//
|
||||
// public static MogoSubPoiItem fromBMap( SubPoiItem subPoiItem ) {
|
||||
// if ( subPoiItem == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoSubPoiItem mogoSubPoiItem = new MogoSubPoiItem();
|
||||
// mogoSubPoiItem.setDistance( subPoiItem.getDistance() );
|
||||
// mogoSubPoiItem.setPoiId( subPoiItem.getPoiId() );
|
||||
// mogoSubPoiItem.setPoint( fromBMap( subPoiItem.getLatLonPoint() ) );
|
||||
// mogoSubPoiItem.setSnippet( subPoiItem.getSnippet() );
|
||||
// mogoSubPoiItem.setSubName( mogoSubPoiItem.getSubName() );
|
||||
// mogoSubPoiItem.setSubTypeDes( mogoSubPoiItem.getSubTypeDes() );
|
||||
// mogoSubPoiItem.setTitle( mogoSubPoiItem.getTitle() );
|
||||
// return mogoSubPoiItem;
|
||||
// }
|
||||
//
|
||||
// public static MogoPoiItem fromBMap( PoiItem poiItem ) {
|
||||
// if ( poiItem == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoPoiItem mogoPoiItem = new MogoPoiItem();
|
||||
// mogoPoiItem.setAdCode( poiItem.getAdCode() );
|
||||
// mogoPoiItem.setAdName( poiItem.getAdName() );
|
||||
// mogoPoiItem.setBusinessArea( poiItem.getBusinessArea() );
|
||||
// mogoPoiItem.setCityCode( poiItem.getCityCode() );
|
||||
// mogoPoiItem.setCityName( poiItem.getCityName() );
|
||||
// mogoPoiItem.setDirection( poiItem.getDirection() );
|
||||
// mogoPoiItem.setDistance( poiItem.getDistance() );
|
||||
// mogoPoiItem.setEmail( poiItem.getEmail() );
|
||||
// mogoPoiItem.setEnter( fromBMap( poiItem.getEnter() ) );
|
||||
// mogoPoiItem.setExit( fromBMap( poiItem.getExit() ) );
|
||||
// mogoPoiItem.setIndoorData( fromBMap( poiItem.getIndoorData() ) );
|
||||
// mogoPoiItem.setParkingType( poiItem.getParkingType() );
|
||||
// mogoPoiItem.setIndoorMap( poiItem.isIndoorMap() );
|
||||
// if ( poiItem.getPhotos() != null ) {
|
||||
// List< MogoPhoto > mogoPhotos = new ArrayList<>();
|
||||
// for ( Photo photo : poiItem.getPhotos() ) {
|
||||
// MogoPhoto mogoPhoto = fromBMap( photo );
|
||||
// if ( mogoPhoto != null ) {
|
||||
// mogoPhotos.add( mogoPhoto );
|
||||
// }
|
||||
// }
|
||||
// mogoPoiItem.setPhotos( mogoPhotos );
|
||||
// }
|
||||
// mogoPoiItem.setPoiExtension( fromBMap( poiItem.getPoiExtension() ) );
|
||||
// mogoPoiItem.setPoiId( poiItem.getPoiId() );
|
||||
// mogoPoiItem.setPoint( fromBMap( poiItem.getLatLonPoint() ) );
|
||||
// mogoPoiItem.setPostcode( poiItem.getPostcode() );
|
||||
// mogoPoiItem.setProvinceCode( poiItem.getProvinceCode() );
|
||||
// mogoPoiItem.setProvinceName( poiItem.getProvinceName() );
|
||||
// mogoPoiItem.setShopID( poiItem.getShopID() );
|
||||
// mogoPoiItem.setSnippet( poiItem.getSnippet() );
|
||||
// if ( poiItem.getSubPois() != null ) {
|
||||
// List< MogoSubPoiItem > mogoSubPoiItems = new ArrayList<>();
|
||||
// for ( SubPoiItem subPois : poiItem.getSubPois() ) {
|
||||
// MogoSubPoiItem mogoSubPoiItem = fromBMap( subPois );
|
||||
// if ( mogoPoiItem != null ) {
|
||||
// mogoSubPoiItems.add( mogoSubPoiItem );
|
||||
// }
|
||||
// }
|
||||
// mogoPoiItem.setSubPois( mogoSubPoiItems );
|
||||
// }
|
||||
// mogoPoiItem.setTel( poiItem.getTel() );
|
||||
// mogoPoiItem.setTypeCode( poiItem.getTypeCode() );
|
||||
// mogoPoiItem.setTitle( poiItem.getTitle() );
|
||||
// mogoPoiItem.setTypeDes( poiItem.getTypeDes() );
|
||||
// mogoPoiItem.setWebsite( poiItem.getWebsite() );
|
||||
// return mogoPoiItem;
|
||||
// }
|
||||
//
|
||||
// public static MogoRegeocodeAddress fromBMap( ReverseGeoCodeResult regeocodeAddress ) {
|
||||
// if ( regeocodeAddress == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoRegeocodeAddress mogoRegeocodeAddress = new MogoRegeocodeAddress();
|
||||
// mogoRegeocodeAddress.setAdCode( regeocodeAddress.getAdcode() + "" );
|
||||
// if ( regeocodeAddress.getAois() != null ) {
|
||||
// List< MogoAoiItem > items = new ArrayList<>();
|
||||
// for ( AoiItem aois : regeocodeAddress.getAois() ) {
|
||||
// final MogoAoiItem mogoAoiItem = fromBMap( aois );
|
||||
// if ( mogoAoiItem != null ) {
|
||||
// items.add( mogoAoiItem );
|
||||
// }
|
||||
// }
|
||||
// mogoRegeocodeAddress.setAois( items );
|
||||
// }
|
||||
//
|
||||
// mogoRegeocodeAddress.setBuilding( regeocodeAddress.getB );
|
||||
// if ( regeocodeAddress.getBusinessAreas() != null ) {
|
||||
// List< MogoBusinessArea > mogoBusinessAreas = new ArrayList<>();
|
||||
// for ( BusinessArea businessArea : regeocodeAddress.getBusinessAreas() ) {
|
||||
// MogoBusinessArea mogoBusinessArea = fromBMap( businessArea );
|
||||
// if ( mogoBusinessArea != null ) {
|
||||
// mogoBusinessAreas.add( mogoBusinessArea );
|
||||
// }
|
||||
// }
|
||||
// mogoRegeocodeAddress.setBusinessAreas( mogoBusinessAreas );
|
||||
// }
|
||||
//
|
||||
// mogoRegeocodeAddress.setCity( regeocodeAddress.getCity() );
|
||||
// mogoRegeocodeAddress.setCityCode( regeocodeAddress.getCityCode() );
|
||||
// mogoRegeocodeAddress.setCountry( regeocodeAddress.getCountry() );
|
||||
// if ( regeocodeAddress.getCrossroads() != null ) {
|
||||
// List< MogoCrossroad > mogoCrossroads = new ArrayList<>();
|
||||
// for ( Crossroad crossroad : regeocodeAddress.getCrossroads() ) {
|
||||
//
|
||||
// MogoCrossroad mogoCrossroad = fromBMap( crossroad );
|
||||
// if ( mogoCrossroad != null ) {
|
||||
// mogoCrossroads.add( mogoCrossroad );
|
||||
// }
|
||||
// }
|
||||
// mogoRegeocodeAddress.setCrossroads( mogoCrossroads );
|
||||
// }
|
||||
// mogoRegeocodeAddress.setDistrict( regeocodeAddress.getDistrict() );
|
||||
// mogoRegeocodeAddress.setFormatAddress( regeocodeAddress.getFormatAddress() );
|
||||
// mogoRegeocodeAddress.setNeighborhood( regeocodeAddress.getNeighborhood() );
|
||||
// if ( regeocodeAddress.getPois() != null ) {
|
||||
// List< MogoPoiItem > mogoPoiItems = new ArrayList<>();
|
||||
// for ( PoiItem pois : regeocodeAddress.getPois() ) {
|
||||
// MogoPoiItem mogoPoiItem = fromBMap( pois );
|
||||
// mogoPoiItems.add( mogoPoiItem );
|
||||
// }
|
||||
// mogoRegeocodeAddress.setPois( mogoPoiItems );
|
||||
// }
|
||||
// mogoRegeocodeAddress.setProvince( regeocodeAddress.getProvince() );
|
||||
// if ( regeocodeAddress.getRoads() != null ) {
|
||||
// List< MogoRegeocodeRoad > mogoRegeocodeRoads = new ArrayList<>();
|
||||
// for ( RegeocodeRoad road : regeocodeAddress.getRoads() ) {
|
||||
// MogoRegeocodeRoad mogoRegeocodeRoad = fromBMap( road );
|
||||
// if ( mogoRegeocodeRoad != null ) {
|
||||
// mogoRegeocodeRoads.add( mogoRegeocodeRoad );
|
||||
// }
|
||||
// }
|
||||
// mogoRegeocodeAddress.setRoads( mogoRegeocodeRoads );
|
||||
// }
|
||||
// mogoRegeocodeAddress.setStreetNumber( fromBMap( regeocodeAddress.getStreetNumber() ) );
|
||||
// mogoRegeocodeAddress.setTowncode( regeocodeAddress.getTowncode() );
|
||||
// mogoRegeocodeAddress.setTownship( regeocodeAddress.getTownship() );
|
||||
// return mogoRegeocodeAddress;
|
||||
// }
|
||||
|
||||
//
|
||||
public static MogoRegeocodeResult fromBMap( ReverseGeoCodeResult regeocodeResult ) {
|
||||
if ( regeocodeResult == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoRegeocodeResult mogoRegeocodeResult = new MogoRegeocodeResult();
|
||||
mogoRegeocodeResult.setRegeocodeAddress( null );
|
||||
return mogoRegeocodeResult;
|
||||
}
|
||||
|
||||
//
|
||||
public static SuggestionSearchOption fromMogo( MogoInputtipsQuery query ) {
|
||||
if ( query == null ) {
|
||||
return null;
|
||||
}
|
||||
SuggestionSearchOption searchOption = new SuggestionSearchOption();
|
||||
searchOption.city( query.getCity() )
|
||||
.keyword( query.getKeyword() )
|
||||
.citylimit( query.isCityLimit() );
|
||||
return searchOption;
|
||||
}
|
||||
|
||||
public static MogoTip fromBMap( SuggestionResult.SuggestionInfo tip ) {
|
||||
if ( tip == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoTip mogoTip = new MogoTip();
|
||||
mogoTip.setAddress( tip.getAddress() );
|
||||
mogoTip.setAdCode( "" );
|
||||
mogoTip.setDistrict( tip.getDistrict() );
|
||||
mogoTip.setName( tip.getKey() );
|
||||
mogoTip.setPoiID( tip.getUid() );
|
||||
mogoTip.setPoint( fromBMap( tip.getPt() ) );
|
||||
mogoTip.setTypeCode( "" );
|
||||
return mogoTip;
|
||||
}
|
||||
//
|
||||
// public static MogoPoi fromBMap( Poi poi ) {
|
||||
// if ( poi == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoPoi mogoPoi = new MogoPoi();
|
||||
// mogoPoi.setCoordinate( fromBMap( poi.getCoordinate() ) );
|
||||
// mogoPoi.setName( poi.getName() );
|
||||
// mogoPoi.setPoiId( poi.getPoiId() );
|
||||
// return mogoPoi;
|
||||
// }
|
||||
//
|
||||
// public static MogoPoiSearchQuery fromBMap( PoiSearch.Query query ) {
|
||||
// if ( query == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoPoiSearchQuery mogoPoiSearchQuery = new MogoPoiSearchQuery( query.getQueryString(), query.getCategory(), query.getCity() );
|
||||
// mogoPoiSearchQuery.setBuilding( query.getBuilding() );
|
||||
// mogoPoiSearchQuery.setCityLimit( query.getCityLimit() );
|
||||
// mogoPoiSearchQuery.setDistanceSort( query.isDistanceSort() );
|
||||
// mogoPoiSearchQuery.setLocation( fromBMap( query.getLocation() ) );
|
||||
// mogoPoiSearchQuery.setPageNum( query.getPageNum() );
|
||||
// mogoPoiSearchQuery.setPageSize( query.getPageSize() );
|
||||
// return mogoPoiSearchQuery;
|
||||
// }
|
||||
//
|
||||
// public static PoiSearch.Query fromMogo( MogoPoiSearchQuery query ) {
|
||||
// if ( query == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// PoiSearch.Query psq = new PoiSearch.Query( query.getQuery(), query.getCategory(), query.getCity() );
|
||||
// psq.setBuilding( query.getBuilding() );
|
||||
// psq.setCityLimit( query.isCityLimit() );
|
||||
// psq.setDistanceSort( query.isDistanceSort() );
|
||||
// psq.setLocation( fromMogo( query.getLocation() ) );
|
||||
// psq.setPageNum( query.getPageNum() );
|
||||
// psq.setPageSize( query.getPageSize() );
|
||||
// return psq;
|
||||
// }
|
||||
//
|
||||
// public static MogoSearchBound fromBMap( PoiSearch.SearchBound bound ) {
|
||||
// if ( bound == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// if ( bound.getShape() == PoiSearch.SearchBound.BOUND_SHAPE ) {
|
||||
// return new MogoSearchBound( fromBMap( bound.getCenter() ), bound.getRange(), bound.isDistanceSort() );
|
||||
// } else if ( bound.getShape() == PoiSearch.SearchBound.POLYGON_SHAPE ) {
|
||||
// return new MogoSearchBound( fromBMap( bound.getPolyGonList() ) );
|
||||
// } else if ( bound.getShape() == PoiSearch.SearchBound.RECTANGLE_SHAPE ) {
|
||||
// return new MogoSearchBound( fromBMap( bound.getLowerLeft() ), fromBMap( bound.getUpperRight() ) );
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// public static List< MogoLatLng > fromBMap( List< LatLonPoint > latLngs ) {
|
||||
// if ( latLngs == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// List< MogoLatLng > result = new ArrayList<>( latLngs.size() );
|
||||
// for ( LatLonPoint latLng : latLngs ) {
|
||||
// result.add( fromBMap( latLng ) );
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// public static List< LatLonPoint > fromMogo( List< MogoLatLng > latLngs ) {
|
||||
// if ( latLngs == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// List< LatLonPoint > result = new ArrayList<>( latLngs.size() );
|
||||
// for ( MogoLatLng latLng : latLngs ) {
|
||||
// result.add( fromMogo( latLng ) );
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static PoiSearch.SearchBound fromMogo( MogoSearchBound bound ) {
|
||||
// if ( bound == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// if ( bound.getShape() == MogoSearchBound.SHAPE_BOUND ) {
|
||||
// return new PoiSearch.SearchBound( fromMogo( bound.getCenterPoint() ), bound.getRadiusInMeters(), bound.isDistanceSort() );
|
||||
// } else if ( bound.getShape() == MogoSearchBound.SHAPE_POLYGON ) {
|
||||
// return new PoiSearch.SearchBound( fromMogo( bound.getPolyGonList() ) );
|
||||
// } else if ( bound.getShape() == MogoSearchBound.SHAPE_RECTANGLE ) {
|
||||
// return new PoiSearch.SearchBound( fromMogo( bound.getLowerLeft() ), fromMogo( bound.getUpperRight() ) );
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// public static MogoPoiResult fromBMap( PoiResult result ) {
|
||||
// if ( result == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoPoiResult mogoPoiResult = new MogoPoiResult();
|
||||
// if ( result.getPois() != null ) {
|
||||
// final List< PoiItem > poiItems = result.getPois();
|
||||
// final ArrayList< MogoPoiItem > mogoPoiItems = new ArrayList<>( poiItems.size() );
|
||||
// for ( PoiItem poiItem : poiItems ) {
|
||||
// mogoPoiItems.add( fromBMap( poiItem ) );
|
||||
// }
|
||||
// mogoPoiResult.setPois( mogoPoiItems );
|
||||
// }
|
||||
// return mogoPoiResult;
|
||||
// }
|
||||
//
|
||||
// public static MogoNaviInfo fromBMap( NaviInfo naviInfo ) {
|
||||
// if ( naviInfo == null ) {
|
||||
// return null;
|
||||
// }
|
||||
// MogoNaviInfo mogoNaviInfo = new MogoNaviInfo();
|
||||
// mogoNaviInfo.setCurrentRoadName( naviInfo.getCurrentRoadName() );
|
||||
// mogoNaviInfo.setCurrentSpeed( naviInfo.getCurrentSpeed() );
|
||||
// mogoNaviInfo.setCurStepRetainDistance( naviInfo.getCurStepRetainDistance() );
|
||||
// mogoNaviInfo.setCurStepRetainTime( naviInfo.getCurStepRetainTime() );
|
||||
// mogoNaviInfo.setIconType( naviInfo.getIconType() );
|
||||
// mogoNaviInfo.setNextRoadName( naviInfo.getNextRoadName() );
|
||||
// mogoNaviInfo.setPathRetainDistance( naviInfo.getPathRetainDistance() );
|
||||
// mogoNaviInfo.setPathRetainTime( naviInfo.getPathRetainTime() );
|
||||
// return mogoNaviInfo;
|
||||
// }
|
||||
}
|
||||
3
libraries/map-baidu/src/main/res/values/strings.xml
Normal file
3
libraries/map-baidu/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">map-baidu</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<base-config cleartextTrafficPermitted="true" />
|
||||
</network-security-config>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.mogo.map.impl.baidu;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals( 4, 2 + 2 );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user