dev
This commit is contained in:
@@ -21,7 +21,6 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -41,7 +42,7 @@ public abstract class MogoBaseMapView extends FrameLayout implements ILifeCycle
|
||||
if ( mMapView != null ) {
|
||||
final View mapView = mMapView.getMapView();
|
||||
if ( mapView != null ) {
|
||||
addView( mapView );
|
||||
addView( mapView, new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT ) );
|
||||
MogoMap.getInstance().init( context, getMap() );
|
||||
} else {
|
||||
Logger.e( TAG, "create MapView instance failed." );
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.map.amap;
|
||||
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* marker 点击事件处理
|
||||
*/
|
||||
public class AMapMarkerClickHandler {
|
||||
|
||||
public boolean handleMarkerClicked( Marker marker ) {
|
||||
if ( marker == null ) {
|
||||
return false;
|
||||
}
|
||||
if ( marker.getObject() instanceof IMogoMarker ) {
|
||||
final IMogoMarkerClickListener listener = ( ( IMogoMarker ) marker.getObject() ).getOnMarkerClickListener();
|
||||
if ( listener != null ) {
|
||||
return listener.onMarkerClicked( ( ( IMogoMarker ) marker.getObject() ) );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,19 @@
|
||||
package com.mogo.map.amap;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.Poi;
|
||||
import com.amap.api.navi.AMapNaviView;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoMapView;
|
||||
import com.mogo.map.amap.utils.ObjectUtils;
|
||||
import com.mogo.map.listener.MogoMapListenerHandler;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -13,13 +21,26 @@ import com.mogo.map.IMogoMapView;
|
||||
* <p>
|
||||
* 代理高德导航地图
|
||||
*/
|
||||
public class AMapNaviViewWrapper implements IMogoMapView {
|
||||
public class AMapNaviViewWrapper implements IMogoMapView,
|
||||
AMap.OnMarkerClickListener,
|
||||
AMap.OnMapLoadedListener,
|
||||
AMap.OnMapTouchListener,
|
||||
AMap.OnPOIClickListener {
|
||||
|
||||
private final AMapNaviView mMapView;
|
||||
private IMogoMap mIMap;
|
||||
|
||||
private AMapMarkerClickHandler mMarkerClickHandler;
|
||||
|
||||
public AMapNaviViewWrapper( AMapNaviView mapView ) {
|
||||
this.mMapView = mapView;
|
||||
mMapView.setOnMarkerClickListener( this );
|
||||
mMarkerClickHandler = new AMapMarkerClickHandler();
|
||||
mMapView.setOnMapLoadedListener( this );
|
||||
mMapView.setOnMapTouchListener( this );
|
||||
if ( mMapView.getMap() != null ) {
|
||||
mMapView.getMap().setOnPOIClickListener( this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,4 +96,44 @@ public class AMapNaviViewWrapper implements IMogoMapView {
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 地图marker点击
|
||||
*
|
||||
* @param marker
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onMarkerClick( Marker marker ) {
|
||||
return mMarkerClickHandler.handleMarkerClicked( marker );
|
||||
}
|
||||
|
||||
/**
|
||||
* 地图加载完毕
|
||||
*/
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
MogoMapListenerHandler.getInstance().onMapLoaded();
|
||||
}
|
||||
|
||||
/**
|
||||
* 地图点击回调
|
||||
*
|
||||
* @param motionEvent
|
||||
*/
|
||||
@Override
|
||||
public void onTouch( MotionEvent motionEvent ) {
|
||||
MogoMapListenerHandler.getInstance().onTouch( motionEvent );
|
||||
}
|
||||
|
||||
/**
|
||||
* POI 点击
|
||||
*
|
||||
* @param poi
|
||||
*/
|
||||
@Override
|
||||
public void onPOIClick( Poi poi ) {
|
||||
MogoMapListenerHandler.getInstance().onPOIClick( ObjectUtils.fromAMap( poi ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@ package com.mogo.map.amap;
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.Poi;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.IUiSettings;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.amap.marker.AMapMarkerWrapper;
|
||||
import com.mogo.map.amap.utils.ObjectUtils;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.utils.TipToast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@ import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.amap.utils.ObjectUtils;
|
||||
|
||||
@@ -22,9 +24,14 @@ import java.util.ArrayList;
|
||||
public class AMapMarkerWrapper implements IMogoMarker {
|
||||
|
||||
private Marker mMarker;
|
||||
private Object mObject;
|
||||
private IMogoMarkerClickListener mMogoMarkerClickListener;
|
||||
|
||||
public AMapMarkerWrapper( Marker mMarker ) {
|
||||
this.mMarker = mMarker;
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setObject( this );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -120,9 +127,12 @@ public class AMapMarkerWrapper implements IMogoMarker {
|
||||
|
||||
@Override
|
||||
public void setObject( Object object ) {
|
||||
if ( mMarker != null ) {
|
||||
mMarker.setObject( object );
|
||||
}
|
||||
mObject = object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject() {
|
||||
return mObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,6 +149,15 @@ public class AMapMarkerWrapper implements IMogoMarker {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getPosition() {
|
||||
if ( mMarker != null ) {
|
||||
final LatLng latLng = mMarker.getPosition();
|
||||
return ObjectUtils.fromAMap( latLng );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRotateAngle( float rotate ) {
|
||||
if ( mMarker != null ) {
|
||||
@@ -187,4 +206,14 @@ public class AMapMarkerWrapper implements IMogoMarker {
|
||||
mMarker.showInfoWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnMarkerClickListener( IMogoMarkerClickListener listener ) {
|
||||
mMogoMarkerClickListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarkerClickListener getOnMarkerClickListener() {
|
||||
return mMogoMarkerClickListener;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ import com.amap.api.services.geocoder.RegeocodeAddress;
|
||||
import com.amap.api.services.geocoder.RegeocodeResult;
|
||||
import com.mogo.map.amap.utils.ObjectUtils;
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
import com.mogo.map.search.IMogoGeoSearch;
|
||||
import com.mogo.map.search.IMogoGeoSearchListener;
|
||||
import com.mogo.map.search.MogoGeocodeAddress;
|
||||
import com.mogo.map.search.MogoRegeocodeAddress;
|
||||
import com.mogo.map.search.query.MogoGeocodeQuery;
|
||||
import com.mogo.map.search.query.MogoRegeocodeQuery;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -8,10 +8,10 @@ import com.amap.api.services.help.InputtipsQuery;
|
||||
import com.amap.api.services.help.Tip;
|
||||
import com.mogo.map.amap.utils.ObjectUtils;
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
import com.mogo.map.search.IMogoInputtipsListener;
|
||||
import com.mogo.map.search.IMogoInputtipsSearch;
|
||||
import com.mogo.map.search.MogoTip;
|
||||
import com.mogo.map.search.query.MogoInputtipsQuery;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.mogo.map.amap.search;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.amap.api.services.core.AMapException;
|
||||
import com.amap.api.services.core.PoiItem;
|
||||
import com.amap.api.services.poisearch.PoiResult;
|
||||
import com.amap.api.services.poisearch.PoiSearch;
|
||||
import com.mogo.map.amap.utils.ObjectUtils;
|
||||
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;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* poi搜索高德实现
|
||||
* <p>
|
||||
* 错误码对照表:https://lbs.amap.com/api/android-sdk/guide/map-tools/error-code
|
||||
*/
|
||||
public class PoiSearchClient implements IMogoPoiSearch, PoiSearch.OnPoiSearchListener {
|
||||
|
||||
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 = new PoiSearch( context, ObjectUtils.fromMogo( mQuery ) );
|
||||
mClient.setOnPoiSearchListener( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPoiSearchListener( IMogoPoiSearchListener listener ) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void searchPOIAsyn() {
|
||||
if ( mClient != null ) {
|
||||
mClient.searchPOIAsyn();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoPoiResult searchPOI() throws MogoMapException {
|
||||
if ( mClient != null ) {
|
||||
try {
|
||||
PoiResult search = mClient.searchPOI();
|
||||
return ObjectUtils.fromAMap( search );
|
||||
} catch ( AMapException e ) {
|
||||
throw new MogoMapException( e );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuery( MogoPoiSearchQuery query ) {
|
||||
mQuery = query;
|
||||
if ( mClient != null ) {
|
||||
mClient.setQuery( ObjectUtils.fromMogo( mQuery ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoPoiItem searchPOIId( String poiId ) throws MogoMapException {
|
||||
if ( mClient != null ) {
|
||||
try {
|
||||
PoiItem poiItem = mClient.searchPOIId( poiId );
|
||||
return ObjectUtils.fromAMap( poiItem );
|
||||
} catch ( AMapException e ) {
|
||||
throw new MogoMapException( e );
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void searchPOIIdAsyn( String poiId ) {
|
||||
if ( mClient != null ) {
|
||||
mClient.searchPOIIdAsyn( poiId );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBound( MogoSearchBound bound ) {
|
||||
mBound = bound;
|
||||
if ( mClient != null ) {
|
||||
mClient.setBound( ObjectUtils.fromMogo( bound ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPoiSearched( PoiResult poiResult, int errorCode ) {
|
||||
if ( errorCode != 1000 ) {
|
||||
Logger.e( TAG, "errorcode is %d", errorCode );
|
||||
}
|
||||
if ( mListener != null ) {
|
||||
mListener.onPoiSearched( ObjectUtils.fromAMap( poiResult ), errorCode );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPoiItemSearched( PoiItem poiItem, int errorCode ) {
|
||||
if ( errorCode != 1000 ) {
|
||||
Logger.e( TAG, "errorcode is %d", errorCode );
|
||||
}
|
||||
if ( mListener != null ) {
|
||||
mListener.onPoiItemSearched( ObjectUtils.fromAMap( poiItem ), errorCode );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.amap.api.maps.model.BitmapDescriptor;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.Poi;
|
||||
import com.amap.api.services.core.LatLonPoint;
|
||||
import com.amap.api.services.core.PoiItem;
|
||||
import com.amap.api.services.geocoder.AoiItem;
|
||||
@@ -24,29 +25,35 @@ import com.amap.api.services.help.Tip;
|
||||
import com.amap.api.services.poisearch.IndoorData;
|
||||
import com.amap.api.services.poisearch.Photo;
|
||||
import com.amap.api.services.poisearch.PoiItemExtension;
|
||||
import com.amap.api.services.poisearch.PoiResult;
|
||||
import com.amap.api.services.poisearch.PoiSearch;
|
||||
import com.amap.api.services.poisearch.SubPoiItem;
|
||||
import com.amap.api.services.road.Crossroad;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.search.MogoAoiItem;
|
||||
import com.mogo.map.search.MogoBusinessArea;
|
||||
import com.mogo.map.search.MogoCrossroad;
|
||||
import com.mogo.map.search.MogoGeocodeAddress;
|
||||
import com.mogo.map.search.MogoGeocodeResult;
|
||||
import com.mogo.map.search.MogoIndoorData;
|
||||
import com.mogo.map.search.MogoPhoto;
|
||||
import com.mogo.map.search.MogoPoiItem;
|
||||
import com.mogo.map.search.MogoPoiItemExtension;
|
||||
import com.mogo.map.search.MogoRegeocodeAddress;
|
||||
import com.mogo.map.search.MogoRegeocodeResult;
|
||||
import com.mogo.map.search.MogoRegeocodeRoad;
|
||||
import com.mogo.map.search.MogoStreetNumber;
|
||||
import com.mogo.map.search.MogoSubPoiItem;
|
||||
import com.mogo.map.search.MogoTip;
|
||||
import com.mogo.map.search.query.MogoGeocodeQuery;
|
||||
import com.mogo.map.search.query.MogoInputtipsQuery;
|
||||
import com.mogo.map.search.query.MogoRegeocodeQuery;
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
import com.mogo.map.search.geo.MogoAoiItem;
|
||||
import com.mogo.map.search.geo.MogoBusinessArea;
|
||||
import com.mogo.map.search.geo.MogoCrossroad;
|
||||
import com.mogo.map.search.geo.MogoGeocodeAddress;
|
||||
import com.mogo.map.search.geo.MogoGeocodeResult;
|
||||
import com.mogo.map.search.geo.MogoIndoorData;
|
||||
import com.mogo.map.search.geo.MogoPhoto;
|
||||
import com.mogo.map.search.geo.MogoPoiItem;
|
||||
import com.mogo.map.search.geo.MogoPoiItemExtension;
|
||||
import com.mogo.map.search.geo.MogoRegeocodeAddress;
|
||||
import com.mogo.map.search.geo.MogoRegeocodeResult;
|
||||
import com.mogo.map.search.geo.MogoRegeocodeRoad;
|
||||
import com.mogo.map.search.geo.MogoStreetNumber;
|
||||
import com.mogo.map.search.geo.MogoSubPoiItem;
|
||||
import com.mogo.map.search.inputtips.MogoTip;
|
||||
import com.mogo.map.search.geo.query.MogoGeocodeQuery;
|
||||
import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
|
||||
import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
|
||||
import com.mogo.map.search.poisearch.MogoPoiResult;
|
||||
import com.mogo.map.search.poisearch.MogoSearchBound;
|
||||
import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -136,6 +143,13 @@ public class ObjectUtils {
|
||||
return new LatLonPoint( 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 fromAMap( LatLonPoint point ) {
|
||||
if ( point == null ) {
|
||||
return null;
|
||||
@@ -143,6 +157,13 @@ public class ObjectUtils {
|
||||
return new MogoLatLng( point.getLatitude(), point.getLongitude() );
|
||||
}
|
||||
|
||||
public static MogoLatLng fromAMap( LatLng point ) {
|
||||
if ( point == null ) {
|
||||
return null;
|
||||
}
|
||||
return new MogoLatLng( point.latitude, point.longitude );
|
||||
}
|
||||
|
||||
public static GeocodeQuery fromMogo( MogoGeocodeQuery query ) {
|
||||
if ( query == null ) {
|
||||
return null;
|
||||
@@ -463,4 +484,111 @@ public class ObjectUtils {
|
||||
mogoTip.setTypeCode( tip.getTypeCode() );
|
||||
return mogoTip;
|
||||
}
|
||||
|
||||
public static MogoPoi fromAMap( Poi poi ) {
|
||||
if ( poi == null ) {
|
||||
return null;
|
||||
}
|
||||
MogoPoi mogoPoi = new MogoPoi();
|
||||
mogoPoi.setCoordinate( fromAMap( poi.getCoordinate() ) );
|
||||
mogoPoi.setName( poi.getName() );
|
||||
mogoPoi.setPoiId( poi.getPoiId() );
|
||||
return mogoPoi;
|
||||
}
|
||||
|
||||
public static MogoPoiSearchQuery fromAMap( 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( fromAMap( 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 fromAMap( PoiSearch.SearchBound bound ) {
|
||||
if ( bound == null ) {
|
||||
return null;
|
||||
}
|
||||
if ( bound.getShape() == PoiSearch.SearchBound.BOUND_SHAPE ) {
|
||||
return new MogoSearchBound( fromAMap( bound.getCenter() ), bound.getRange(), bound.isDistanceSort() );
|
||||
} else if ( bound.getShape() == PoiSearch.SearchBound.POLYGON_SHAPE ) {
|
||||
return new MogoSearchBound( fromAMap( bound.getPolyGonList() ) );
|
||||
} else if ( bound.getShape() == PoiSearch.SearchBound.RECTANGLE_SHAPE ) {
|
||||
return new MogoSearchBound( fromAMap( bound.getLowerLeft() ), fromAMap( bound.getUpperRight() ) );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List< MogoLatLng > fromAMap( List< LatLonPoint > latLngs ) {
|
||||
if ( latLngs == null ) {
|
||||
return null;
|
||||
}
|
||||
List< MogoLatLng > result = new ArrayList<>( latLngs.size() );
|
||||
for ( LatLonPoint latLng : latLngs ) {
|
||||
result.add( fromAMap( 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 fromAMap( 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( fromAMap( poiItem ) );
|
||||
}
|
||||
mogoPoiResult.setPois( mogoPoiItems );
|
||||
}
|
||||
return mogoPoiResult;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.mogo.map.listener;
|
||||
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
* <p>
|
||||
* 地图操作回调
|
||||
*/
|
||||
public interface IMogoMapListener {
|
||||
|
||||
/**
|
||||
* 地图加载完毕
|
||||
*/
|
||||
void onMapLoaded();
|
||||
|
||||
/**
|
||||
* 地图点击
|
||||
*
|
||||
* @param motionEvent
|
||||
*/
|
||||
void onTouch( MotionEvent motionEvent );
|
||||
|
||||
/**
|
||||
* 地图上的任意poi点击
|
||||
*
|
||||
* @param poi
|
||||
*/
|
||||
void onPOIClick( MogoPoi poi );
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.map.listener;
|
||||
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
* <p>
|
||||
* 地图操作回调
|
||||
*/
|
||||
public interface IMogoMapListenerRegister {
|
||||
|
||||
/**
|
||||
* 注册地图事件
|
||||
*
|
||||
* @param listener 回调事件
|
||||
*/
|
||||
void registerHostMapListener( IMogoMapListener listener );
|
||||
|
||||
/**
|
||||
* 反注册注册地图事件
|
||||
*/
|
||||
void unregisterHostMapListener();
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mogo.map.listener;
|
||||
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* 地图监听注册管理
|
||||
*/
|
||||
public class MogoMapListenerHandler implements IMogoMapListener, IMogoMapListenerRegister {
|
||||
|
||||
private static volatile MogoMapListenerHandler sInstance;
|
||||
|
||||
private MogoMapListenerHandler() {
|
||||
}
|
||||
|
||||
public static MogoMapListenerHandler getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( MogoMapListenerHandler.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new MogoMapListenerHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上层模块代理对象
|
||||
*/
|
||||
private IMogoMapListener mDelegateListener = null;
|
||||
|
||||
@Override
|
||||
public void registerHostMapListener( IMogoMapListener listener ) {
|
||||
mDelegateListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterHostMapListener() {
|
||||
mDelegateListener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
if ( mDelegateListener != null ) {
|
||||
synchronized ( mDelegateListener ) {
|
||||
mDelegateListener.onMapLoaded();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch( MotionEvent motionEvent ) {
|
||||
if ( mDelegateListener != null ) {
|
||||
synchronized ( mDelegateListener ) {
|
||||
mDelegateListener.onTouch( motionEvent );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPOIClick( MogoPoi poi ) {
|
||||
if ( mDelegateListener != null ) {
|
||||
synchronized ( mDelegateListener ) {
|
||||
mDelegateListener.onPOIClick( poi );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,9 @@ package com.mogo.map.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
@@ -80,6 +83,8 @@ public interface IMogoMarker {
|
||||
|
||||
void setObject( Object object );
|
||||
|
||||
Object getObject();
|
||||
|
||||
/**
|
||||
* 设置多少帧刷新一次图片资源,Marker动画的间隔时间,值越小动画越快。
|
||||
*
|
||||
@@ -87,8 +92,16 @@ public interface IMogoMarker {
|
||||
*/
|
||||
void setPeriod( int period );
|
||||
|
||||
/**
|
||||
* 设置位置
|
||||
*
|
||||
* @param lat
|
||||
* @param lng
|
||||
*/
|
||||
void setPosition( double lat, double lng );
|
||||
|
||||
MogoLatLng getPosition();
|
||||
|
||||
/**
|
||||
* 设置Marker覆盖物图片旋转的角度,从正北开始,逆时针计算。
|
||||
*
|
||||
@@ -133,4 +146,18 @@ public interface IMogoMarker {
|
||||
* 显示 Marker 覆盖物的信息窗口。
|
||||
*/
|
||||
void showInfoWindow();
|
||||
|
||||
/**
|
||||
* 设置点击事件
|
||||
*
|
||||
* @param listener
|
||||
*/
|
||||
void setOnMarkerClickListener( IMogoMarkerClickListener listener );
|
||||
|
||||
/**
|
||||
* 获取点击事件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoMarkerClickListener getOnMarkerClickListener();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mogo.map.marker;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-23
|
||||
* <p>
|
||||
* marker 点击事件
|
||||
*/
|
||||
public interface IMogoMarkerClickListener {
|
||||
|
||||
/**
|
||||
* 事件是否继续往下传递
|
||||
*
|
||||
* @param marker
|
||||
* @return true - 时间已经处理完毕不继续往下传,否则继续往下传
|
||||
*/
|
||||
boolean onMarkerClicked( IMogoMarker marker );
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mogo.map.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* 地图上的poi
|
||||
*/
|
||||
public class MogoPoi implements Parcelable {
|
||||
|
||||
private String name;
|
||||
private MogoLatLng coordinate;
|
||||
private String poiId;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName( String name ) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public MogoLatLng getCoordinate() {
|
||||
return coordinate;
|
||||
}
|
||||
|
||||
public void setCoordinate( MogoLatLng coordinate ) {
|
||||
this.coordinate = coordinate;
|
||||
}
|
||||
|
||||
public String getPoiId() {
|
||||
return poiId;
|
||||
}
|
||||
|
||||
public void setPoiId( String poiId ) {
|
||||
this.poiId = poiId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeString( this.name );
|
||||
dest.writeParcelable( this.coordinate, flags );
|
||||
dest.writeString( this.poiId );
|
||||
}
|
||||
|
||||
public MogoPoi() {
|
||||
}
|
||||
|
||||
protected MogoPoi( Parcel in ) {
|
||||
this.name = in.readString();
|
||||
this.coordinate = in.readParcelable( MogoLatLng.class.getClassLoader() );
|
||||
this.poiId = in.readString();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator< MogoPoi > CREATOR = new Parcelable.Creator< MogoPoi >() {
|
||||
@Override
|
||||
public MogoPoi createFromParcel( Parcel source ) {
|
||||
return new MogoPoi( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoPoi[] newArray( int size ) {
|
||||
return new MogoPoi[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
import com.mogo.map.search.query.MogoGeocodeQuery;
|
||||
import com.mogo.map.search.query.MogoRegeocodeQuery;
|
||||
import com.mogo.map.search.geo.query.MogoGeocodeQuery;
|
||||
import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.map.amap.search.GeocodeSearchClient;
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
import com.mogo.map.search.query.MogoGeocodeQuery;
|
||||
import com.mogo.map.search.query.MogoRegeocodeQuery;
|
||||
import com.mogo.map.search.geo.query.MogoGeocodeQuery;
|
||||
import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.geo;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search.query;
|
||||
package com.mogo.map.search.geo.query;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search.query;
|
||||
package com.mogo.map.search.geo.query;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.inputtips;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.inputtips;
|
||||
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
import com.mogo.map.search.query.MogoInputtipsQuery;
|
||||
import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.inputtips;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.map.amap.search.InputtipsSearch;
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
import com.mogo.map.search.query.MogoInputtipsQuery;
|
||||
import com.mogo.map.search.inputtips.query.MogoInputtipsQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search;
|
||||
package com.mogo.map.search.inputtips;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.map.search.query;
|
||||
package com.mogo.map.search.inputtips.query;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.mogo.map.search.poisearch;
|
||||
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
import com.mogo.map.search.geo.MogoPoiItem;
|
||||
import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* poi 搜索
|
||||
*/
|
||||
public interface IMogoPoiSearch {
|
||||
|
||||
void setPoiSearchListener( IMogoPoiSearchListener listener );
|
||||
|
||||
/**
|
||||
* 异步搜索poi信息
|
||||
*/
|
||||
void searchPOIAsyn();
|
||||
|
||||
/**
|
||||
* 同步搜索poi信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
MogoPoiResult searchPOI() throws MogoMapException;
|
||||
|
||||
/**
|
||||
* 设置查询条件
|
||||
*
|
||||
* @param query
|
||||
*/
|
||||
void setQuery( MogoPoiSearchQuery query );
|
||||
|
||||
/**
|
||||
* 根据poiId搜索详情,同步
|
||||
*
|
||||
* @param poiId
|
||||
* @return
|
||||
*/
|
||||
MogoPoiItem searchPOIId( String poiId ) throws MogoMapException;
|
||||
|
||||
/**
|
||||
* 根据poiId搜索详情,异步
|
||||
*
|
||||
* @param poiId
|
||||
*/
|
||||
void searchPOIIdAsyn( String poiId );
|
||||
|
||||
/**
|
||||
* 周边检索POI
|
||||
*
|
||||
* @param bound
|
||||
*/
|
||||
void setBound( MogoSearchBound bound );
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mogo.map.search.poisearch;
|
||||
|
||||
import com.mogo.map.search.geo.MogoPoiItem;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* poi 检索结果回调
|
||||
*/
|
||||
public interface IMogoPoiSearchListener {
|
||||
|
||||
/**
|
||||
* 返回POI搜索异步处理的结果。
|
||||
*/
|
||||
void onPoiSearched( MogoPoiResult result, int errorCode );
|
||||
|
||||
/**
|
||||
* poi ID 检索结果回调方法
|
||||
*/
|
||||
void onPoiItemSearched( MogoPoiItem item, int errorCode );
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.map.search.poisearch;
|
||||
|
||||
import com.mogo.map.search.geo.MogoPoiItem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* poi搜索结果集
|
||||
*/
|
||||
public class MogoPoiResult {
|
||||
|
||||
private ArrayList< MogoPoiItem > pois;
|
||||
|
||||
public ArrayList< MogoPoiItem > getPois() {
|
||||
return pois;
|
||||
}
|
||||
|
||||
public void setPois( ArrayList< MogoPoiItem > pois ) {
|
||||
this.pois = pois;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.mogo.map.search.poisearch;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.mogo.map.amap.search.PoiSearchClient;
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
import com.mogo.map.search.geo.MogoPoiItem;
|
||||
import com.mogo.map.search.poisearch.query.MogoPoiSearchQuery;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class MogoPoiSearch implements IMogoPoiSearch {
|
||||
|
||||
private IMogoPoiSearch mDelegate;
|
||||
|
||||
public MogoPoiSearch( Context context, MogoPoiSearchQuery query ) {
|
||||
mDelegate = new PoiSearchClient( context, query );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPoiSearchListener( IMogoPoiSearchListener listener ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.setPoiSearchListener( listener );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void searchPOIAsyn() {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.searchPOIAsyn();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoPoiResult searchPOI() throws MogoMapException {
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.searchPOI();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuery( MogoPoiSearchQuery query ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.setQuery( query );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoPoiItem searchPOIId( String poiId ) throws MogoMapException {
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.searchPOIId( poiId );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void searchPOIIdAsyn( String poiId ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.searchPOIIdAsyn( poiId );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBound( MogoSearchBound bound ) {
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.setBound( bound );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.mogo.map.search.poisearch;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* 周边搜索范围
|
||||
*/
|
||||
public class MogoSearchBound implements Parcelable {
|
||||
|
||||
public static final String SHAPE_BOUND = "Bound";
|
||||
public static final String SHAPE_RECTANGLE = "Rectangle";
|
||||
public static final String SHAPE_POLYGON = "Polygon";
|
||||
|
||||
/**
|
||||
* 中心点
|
||||
*/
|
||||
private MogoLatLng centerPoint;
|
||||
/**
|
||||
* 半径:米
|
||||
*/
|
||||
private int radiusInMeters;
|
||||
|
||||
/**
|
||||
* 搜索范围的形状
|
||||
*/
|
||||
private String shape;
|
||||
|
||||
/**
|
||||
* 按距离排序
|
||||
*/
|
||||
private boolean isDistanceSort;
|
||||
|
||||
/**
|
||||
* 左下角
|
||||
*/
|
||||
private MogoLatLng lowerLeft;
|
||||
/**
|
||||
* 右上角
|
||||
*/
|
||||
private MogoLatLng upperRight;
|
||||
|
||||
/**
|
||||
* 范围搜索地点列表
|
||||
*/
|
||||
private List< MogoLatLng > polyGonList;
|
||||
|
||||
public MogoSearchBound( MogoLatLng centerPoint, int radiusInMeters ) {
|
||||
this( centerPoint, radiusInMeters, true );
|
||||
}
|
||||
|
||||
public MogoSearchBound( MogoLatLng centerPoint, int radiusInMeters, boolean isDistanceSort ) {
|
||||
this.centerPoint = centerPoint;
|
||||
this.radiusInMeters = radiusInMeters;
|
||||
this.isDistanceSort = isDistanceSort;
|
||||
this.shape = SHAPE_BOUND;
|
||||
}
|
||||
|
||||
public MogoSearchBound( MogoLatLng lowerLeft, MogoLatLng upperRight ) {
|
||||
this.lowerLeft = lowerLeft;
|
||||
this.upperRight = upperRight;
|
||||
this.shape = SHAPE_RECTANGLE;
|
||||
}
|
||||
|
||||
public MogoSearchBound( List< MogoLatLng > polyGonList ) {
|
||||
this.polyGonList = polyGonList;
|
||||
this.shape = SHAPE_POLYGON;
|
||||
}
|
||||
|
||||
public MogoLatLng getCenterPoint() {
|
||||
return centerPoint;
|
||||
}
|
||||
|
||||
public int getRadiusInMeters() {
|
||||
return radiusInMeters;
|
||||
}
|
||||
|
||||
public String getShape() {
|
||||
return shape;
|
||||
}
|
||||
|
||||
public boolean isDistanceSort() {
|
||||
return isDistanceSort;
|
||||
}
|
||||
|
||||
public MogoLatLng getLowerLeft() {
|
||||
return lowerLeft;
|
||||
}
|
||||
|
||||
public MogoLatLng getUpperRight() {
|
||||
return upperRight;
|
||||
}
|
||||
|
||||
public List< MogoLatLng > getPolyGonList() {
|
||||
return polyGonList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeParcelable( this.centerPoint, flags );
|
||||
dest.writeInt( this.radiusInMeters );
|
||||
dest.writeString( this.shape );
|
||||
dest.writeByte( this.isDistanceSort ? ( byte ) 1 : ( byte ) 0 );
|
||||
dest.writeParcelable( this.lowerLeft, flags );
|
||||
dest.writeParcelable( this.upperRight, flags );
|
||||
dest.writeTypedList( this.polyGonList );
|
||||
}
|
||||
|
||||
protected MogoSearchBound( Parcel in ) {
|
||||
this.centerPoint = in.readParcelable( MogoLatLng.class.getClassLoader() );
|
||||
this.radiusInMeters = in.readInt();
|
||||
this.shape = in.readString();
|
||||
this.isDistanceSort = in.readByte() != 0;
|
||||
this.lowerLeft = in.readParcelable( MogoLatLng.class.getClassLoader() );
|
||||
this.upperRight = in.readParcelable( MogoLatLng.class.getClassLoader() );
|
||||
this.polyGonList = in.createTypedArrayList( MogoLatLng.CREATOR );
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator< MogoSearchBound > CREATOR = new Parcelable.Creator< MogoSearchBound >() {
|
||||
@Override
|
||||
public MogoSearchBound createFromParcel( Parcel source ) {
|
||||
return new MogoSearchBound( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoSearchBound[] newArray( int size ) {
|
||||
return new MogoSearchBound[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.mogo.map.search.poisearch.query;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2019-12-24
|
||||
* <p>
|
||||
* poi 搜索查询条件
|
||||
*/
|
||||
public class MogoPoiSearchQuery implements Parcelable {
|
||||
|
||||
private String query;
|
||||
private String category;
|
||||
private String city;
|
||||
private String building;
|
||||
private int pageNum;
|
||||
private int pageSize;
|
||||
private boolean isCityLimit;
|
||||
private boolean isSubPois;
|
||||
private boolean isDistanceSort;
|
||||
private MogoLatLng location;
|
||||
|
||||
/**
|
||||
* @param query 查询字符串,多个关键字用“|”分割
|
||||
* @param category 类型的组合,比如定义如下组合:餐馆|电影院|景点
|
||||
*/
|
||||
public MogoPoiSearchQuery( String query, String category ) {
|
||||
this.query = query;
|
||||
this.category = category;
|
||||
this.city = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param query 查询字符串,多个关键字用“|”分割
|
||||
* @param category 类型的组合,比如定义如下组合:餐馆|电影院|景点
|
||||
*/
|
||||
public MogoPoiSearchQuery( String query, String category, String city ) {
|
||||
this.query = query;
|
||||
this.category = category;
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getBuilding() {
|
||||
return building;
|
||||
}
|
||||
|
||||
public void setBuilding( String building ) {
|
||||
this.building = building;
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public int getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
|
||||
public void setPageNum( int pageNum ) {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
public void setPageSize( int pageSize ) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
|
||||
public boolean isCityLimit() {
|
||||
return isCityLimit;
|
||||
}
|
||||
|
||||
public void setCityLimit( boolean cityLimit ) {
|
||||
isCityLimit = cityLimit;
|
||||
}
|
||||
|
||||
public boolean isSubPois() {
|
||||
return isSubPois;
|
||||
}
|
||||
|
||||
public void setSubPois( boolean subPois ) {
|
||||
isSubPois = subPois;
|
||||
}
|
||||
|
||||
public boolean isDistanceSort() {
|
||||
return isDistanceSort;
|
||||
}
|
||||
|
||||
public void setDistanceSort( boolean distanceSort ) {
|
||||
isDistanceSort = distanceSort;
|
||||
}
|
||||
|
||||
public MogoLatLng getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation( MogoLatLng location ) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeString( this.building );
|
||||
dest.writeString( this.category );
|
||||
dest.writeString( this.city );
|
||||
dest.writeInt( this.pageNum );
|
||||
dest.writeInt( this.pageSize );
|
||||
dest.writeByte( this.isCityLimit ? ( byte ) 1 : ( byte ) 0 );
|
||||
dest.writeByte( this.isSubPois ? ( byte ) 1 : ( byte ) 0 );
|
||||
dest.writeByte( this.isDistanceSort ? ( byte ) 1 : ( byte ) 0 );
|
||||
dest.writeParcelable( this.location, flags );
|
||||
}
|
||||
|
||||
public MogoPoiSearchQuery() {
|
||||
}
|
||||
|
||||
protected MogoPoiSearchQuery( Parcel in ) {
|
||||
this.building = in.readString();
|
||||
this.category = in.readString();
|
||||
this.city = in.readString();
|
||||
this.pageNum = in.readInt();
|
||||
this.pageSize = in.readInt();
|
||||
this.isCityLimit = in.readByte() != 0;
|
||||
this.isSubPois = in.readByte() != 0;
|
||||
this.isDistanceSort = in.readByte() != 0;
|
||||
this.location = in.readParcelable( MogoLatLng.class.getClassLoader() );
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator< MogoPoiSearchQuery > CREATOR = new Parcelable.Creator< MogoPoiSearchQuery >() {
|
||||
@Override
|
||||
public MogoPoiSearchQuery createFromParcel( Parcel source ) {
|
||||
return new MogoPoiSearchQuery( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoPoiSearchQuery[] newArray( int size ) {
|
||||
return new MogoPoiSearchQuery[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user