Commit 5728e76f by luo_sp

增加地址接口回调操作类型

parent 145069a8
...@@ -8,7 +8,6 @@ import android.widget.Toast; ...@@ -8,7 +8,6 @@ import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import cn.com.founder.arcgislib.ArcGisFounder; import cn.com.founder.arcgislib.ArcGisFounder;
import cn.com.founder.arcgislib.cluster.option.IArcGisClusterOption;
import cn.com.founder.arcgislib.compass.option.IArcGisCompassOption; import cn.com.founder.arcgislib.compass.option.IArcGisCompassOption;
import cn.com.founder.arcgislib.location.option.IArcGisLocationOption; import cn.com.founder.arcgislib.location.option.IArcGisLocationOption;
import cn.com.founder.arcgislib.view.ArcGisBaseView; import cn.com.founder.arcgislib.view.ArcGisBaseView;
...@@ -42,8 +41,8 @@ public class MainActivity extends AppCompatActivity { ...@@ -42,8 +41,8 @@ public class MainActivity extends AppCompatActivity {
.setDefaultArcGisCompass()//设置默认罗盘 .setDefaultArcGisCompass()//设置默认罗盘
.setOpenNavi()//开启导航 .setOpenNavi()//开启导航
// .setOpenSearch()//开启搜索 // .setOpenSearch()//开启搜索
.setOpenHotPots()//开启热力图 // .setOpenHotPots()//开启热力图
.setOpenCluster()//开启聚合 // .setOpenCluster()//开启聚合
.createArcGisFounder();//创建ArcGisFounder地图实例 .createArcGisFounder();//创建ArcGisFounder地图实例
IArcGisZoomOption iArcGisZoomOption = arcGisFounder.arcGisZoomOption(); IArcGisZoomOption iArcGisZoomOption = arcGisFounder.arcGisZoomOption();
...@@ -90,8 +89,8 @@ public class MainActivity extends AppCompatActivity { ...@@ -90,8 +89,8 @@ public class MainActivity extends AppCompatActivity {
IArcGisCompassOption iArcGisCompassOption = arcGisFounder.arcGisCompassOption(); IArcGisCompassOption iArcGisCompassOption = arcGisFounder.arcGisCompassOption();
iArcGisCompassOption.setIRotationAngleListener(() -> Toast.makeText(MainActivity.this, "转动结束。。。", Toast.LENGTH_LONG).show()); iArcGisCompassOption.setIRotationAngleListener(() -> Toast.makeText(MainActivity.this, "转动结束。。。", Toast.LENGTH_LONG).show());
IArcGisClusterOption iArcGisClusterOption = arcGisFounder.arcGisClusterOption(); // IArcGisClusterOption iArcGisClusterOption = arcGisFounder.arcGisClusterOption();
iArcGisClusterOption.setCluseterData(null); // iArcGisClusterOption.setCluseterData(null);
} }
} }
\ No newline at end of file
...@@ -73,7 +73,7 @@ public class Variable { ...@@ -73,7 +73,7 @@ public class Variable {
} }
public static enum LocationChangeType implements Parcelable { public static enum LocationChangeType implements Parcelable {
STARTA_LOCATION, START_LOCATION,
MOVE_MAP, MOVE_MAP,
CLICK_MAP, CLICK_MAP,
IMPORT_POINT, IMPORT_POINT,
......
...@@ -9,35 +9,48 @@ package cn.com.founder.arcgislib.constants; ...@@ -9,35 +9,48 @@ package cn.com.founder.arcgislib.constants;
*/ */
public class Constants { public class Constants {
/*****************************************互联网***********************************************/
//互联网-地图
private static String baseUrl = "http://47.92.225.109:6080/arcgis/rest/services/founder/dg20191120/MapServer";
//互联网-Geo
private static String baseGeoUrl = "http://47.92.226.24:8051/selectVdzjx";
//互联网-搜索
private static String searchUrl = "http://47.92.226.24:8051/selectPoiDataList";
//互联网-导航
private static String naviUrl = "minedata.cn/lbsservice/navi/";
/**********************************************************************************************/
/**
* 测试热力图 /*****************************************用户网***********************************************
*/ //用户网-地图
private static String hotPotsUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/911CallsHotspot/GPServer/911%20Calls%20Hotspot"; private static String baseUrl = "http://20.97.50.41:6080/arcgis/rest/services/founder/dg20191120/MapServer";
/** //互联网-Geo
* argis证书 private static String baseGeoUrl = "http://20.97.50.41:8050/selectVdzjx";
*/ //用户网-搜索
private static String searchUrl = "http://20.97.50.41:8051/selectPoiDataList";
/**********************************************************************************************/
/*****************************************公安网***********************************************
//公安网-地图
private static String baseUrl = "http://68.174.69.45:6080/arcgis/rest/services/founder/dg20191120/MapServer";
//公安网-Geo
private static String baseGeoUrl = "http://68.174.69.46:8051/selectVdzjx";
//公安网-搜索
private static String searchUrl = "http://68.174.69.46:8051/selectPoiDataList";
//公安网-导航
private static String naviUrl = "http://68.26.19.5/";
/**********************************************************************************************/
// argis证书
private static String baseRunTime = "runtimelite,1000,rud9526010123,none,XXMFA0PL4S0MC2EN0175"; private static String baseRunTime = "runtimelite,1000,rud9526010123,none,XXMFA0PL4S0MC2EN0175";
/** //天地图key,使用的是服务器端
* 天地图key,使用的是服务器端
*/
private static String baseTianDiTuKey = "39edeab91620fe3c5a1b282228ef6e46"; private static String baseTianDiTuKey = "39edeab91620fe3c5a1b282228ef6e46";
//天地图Geo
private static String baseTianDiTuGeoUrl = "http://api.tianditu.gov.cn/geocoder"; private static String baseTianDiTuGeoUrl = "http://api.tianditu.gov.cn/geocoder";
//测试热力图
private static String hotPotsUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/911CallsHotspot/GPServer/911%20Calls%20Hotspot";
//互联网-地图
private static String baseUrl = "http://47.92.225.109:6080/arcgis/rest/services/founder/dg20191120/MapServer";
//公安网-地图
// private static String baseUrl = "http://68.174.69.45:6080/arcgis/rest/services/founder/dg20191120/MapServer";
//用户网-地图
// private static String baseUrl = "http://20.97.50.41:6080/arcgis/rest/services/founder/dg20191120/MapServer";
//互联网-搜索接口
private static String searchUrl = "http://47.92.226.24:8051/selectPoiDataList";
//公安网-搜索接口
// private static String searchUrl = "http://68.174.69.46:8051/selectPoiDataList";
//用户网
// private static String searchUrl = "http://20.97.50.41:8051/selectPoiDataList";
//arcGis证书 //arcGis证书
public static final String BASE_MAP_RUNTIME = baseRunTime; public static final String BASE_MAP_RUNTIME = baseRunTime;
...@@ -45,10 +58,14 @@ public class Constants { ...@@ -45,10 +58,14 @@ public class Constants {
public static final String BASE_MAP_SERVER_URL = baseUrl; public static final String BASE_MAP_SERVER_URL = baseUrl;
//天地图 //天地图
public static final String BASE_TIANDITU_KEY = baseTianDiTuKey; public static final String BASE_TIANDITU_KEY = baseTianDiTuKey;
//逆地理编码查询 //天地图逆地理编码查询
public static final String BASE_TIANDITU_GEO_URL = baseTianDiTuGeoUrl; public static final String BASE_TIANDITU_GEO_URL = baseTianDiTuGeoUrl;
//逆地理编码
public static final String BASE_GEO_URL = baseGeoUrl;
//搜索 //搜索
public static final String BASE_SEARCH_URL = searchUrl; public static final String BASE_SEARCH_URL = searchUrl;
//导航
public static final String BASE_NAVI_URL = naviUrl;
//热力图 //热力图
public static final String BASE_HOT_POTS_URL = hotPotsUrl; public static final String BASE_HOT_POTS_URL = hotPotsUrl;
......
...@@ -154,8 +154,21 @@ public class LocationModel implements Parcelable { ...@@ -154,8 +154,21 @@ public class LocationModel implements Parcelable {
this.extraInfo = extraInfo; this.extraInfo = extraInfo;
} }
public Variable.LocationChangeType getLocationChangeType() { public String getLocationChangeType() {
return locationChangeType; switch (locationChangeType){
case START_LOCATION:
return "START_LOCATION";
case MOVE_MAP:
return "MOVE_MAP";
case CLICK_MAP:
return "CLICK_MAP";
case IMPORT_POINT:
return "IMPORT_POINT";
case CALLOUT_OK:
return "CALLOUT_OK";
default:
return "未知操作";
}
} }
public void setLocationChangeType(Variable.LocationChangeType locationChangeType) { public void setLocationChangeType(Variable.LocationChangeType locationChangeType) {
......
...@@ -9,6 +9,8 @@ import android.view.View; ...@@ -9,6 +9,8 @@ import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.Toast; import android.widget.Toast;
import com.esri.arcgisruntime.geometry.Point;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -227,4 +229,30 @@ public class ToolUtil { ...@@ -227,4 +229,30 @@ public class ToolUtil {
} }
return newList; return newList;
} }
/**
* 通过中心点获取指定范围内的最大最小经纬度
* @param point 中心点
* @param distance 距离 单位km
* @return 数组:最大经度,最小经度,最大纬度,最小纬度
*/
public static double[] calcMaxMinLng(Point point, double distance){
//范围
double range = 180 / Math.PI * distance / 6372.797;
//经度弧度
double lngRad = range / Math.cos(point.getY() * Math.PI / 180);
double[] resultPoint = new double[4];
//最大经度
resultPoint[0] = point.getX() + lngRad;
//最小经度
resultPoint[1] = point.getX() - lngRad;
//最大纬度
resultPoint[2] = point.getY() + range;
//最小纬度
resultPoint[3] = point.getY() - range;
return resultPoint;
}
} }
...@@ -14,6 +14,7 @@ import android.os.Handler; ...@@ -14,6 +14,7 @@ import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
...@@ -24,6 +25,7 @@ import android.widget.EditText; ...@@ -24,6 +25,7 @@ import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
...@@ -43,11 +45,15 @@ import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; ...@@ -43,11 +45,15 @@ import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult;
import com.esri.arcgisruntime.mapping.view.LocationDisplay; import com.esri.arcgisruntime.mapping.view.LocationDisplay;
import com.esri.arcgisruntime.mapping.view.MapView; import com.esri.arcgisruntime.mapping.view.MapView;
import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; import com.esri.arcgisruntime.symbology.PictureMarkerSymbol;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.minedata.minenavi.common.OkHttp3Utils; import com.minedata.minenavi.common.OkHttp3Utils;
import com.yanzhenjie.permission.AndPermission; import com.yanzhenjie.permission.AndPermission;
import com.yanzhenjie.permission.runtime.Permission; import com.yanzhenjie.permission.runtime.Permission;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -277,10 +283,10 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -277,10 +283,10 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
} }
/** /**
* @param isShow boolean-是否显示导入布局 * @param isShow boolean-是否显示导入布局
* 默认不显示 * 默认不显示
*/ */
public void setShowImportLayout(boolean isShow){ public void setShowImportLayout(boolean isShow) {
if (isShow) { if (isShow) {
mImportIv.setVisibility(VISIBLE); mImportIv.setVisibility(VISIBLE);
} else { } else {
...@@ -373,7 +379,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -373,7 +379,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
mManualGraphicsOverlay.getGraphics().add(new Graphic(point, campsiteSymbol)); mManualGraphicsOverlay.getGraphics().add(new Graphic(point, campsiteSymbol));
mMapView.setViewpointCenterAsync(point).addDoneListener(() -> { mMapView.setViewpointCenterAsync(point).addDoneListener(() -> {
mMapView.setViewpointScaleAsync(mManualScale); mMapView.setViewpointScaleAsync(mManualScale);
requestGeoCeoder(point, Variable.LocationChangeType.STARTA_LOCATION, FLAG_START_LOCATION); requestGeoCeoder(point, Variable.LocationChangeType.START_LOCATION, FLAG_START_LOCATION);
}); });
} catch (Exception ie) { } catch (Exception ie) {
ie.printStackTrace(); ie.printStackTrace();
...@@ -473,7 +479,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -473,7 +479,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
public void onLocationChanged(LocationDisplay.LocationChangedEvent locationChangedEvent) { public void onLocationChanged(LocationDisplay.LocationChangedEvent locationChangedEvent) {
mLocationDisplay.removeLocationChangedListener(this); mLocationDisplay.removeLocationChangedListener(this);
LocationDataSource.Location locationInfo = locationChangedEvent.getLocation(); LocationDataSource.Location locationInfo = locationChangedEvent.getLocation();
requestGeoCeoder(new Point(locationInfo.getPosition().getX(), locationInfo.getPosition().getY()), Variable.LocationChangeType.STARTA_LOCATION, FLAG_START_LOCATION); requestGeoCeoder(new Point(locationInfo.getPosition().getX(), locationInfo.getPosition().getY()), Variable.LocationChangeType.START_LOCATION, FLAG_START_LOCATION);
} }
}); });
} }
...@@ -508,6 +514,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -508,6 +514,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
}, LOCTION_PERMISSION_GROUP); }, LOCTION_PERMISSION_GROUP);
} }
} }
/** /**
* 获取文件读写权限 * 获取文件读写权限
*/ */
...@@ -535,16 +542,16 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -535,16 +542,16 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
} }
//x(经度)y(纬度) //x(经度)y(纬度)
private void getSDTxtFile(){ private void getSDTxtFile() {
String path = Environment.getExternalStorageDirectory().getPath(); String path = Environment.getExternalStorageDirectory().getPath();
File file = new File(path + File.separator +"LngLat.txt" ); File file = new File(path + File.separator + "LngLat.txt");
List<String> contentList = ToolUtil.getFileContent(mContext,file.getPath()); List<String> contentList = ToolUtil.getFileContent(mContext, file.getPath());
if(contentList.size() > 0){ if (contentList.size() > 0) {
for (String pointStr : contentList){ for (String pointStr : contentList) {
double x = Double.parseDouble(pointStr.split(",")[0]); double x = Double.parseDouble(pointStr.split(",")[0]);
double y = Double.parseDouble(pointStr.split(",")[1]); double y = Double.parseDouble(pointStr.split(",")[1]);
Point point = new Point(x,y, SpatialReference.create(4326)); Point point = new Point(x, y, SpatialReference.create(4326));
try { try {
BitmapDrawable bitmapDrawableNormal = (BitmapDrawable) ContextCompat BitmapDrawable bitmapDrawableNormal = (BitmapDrawable) ContextCompat
...@@ -558,7 +565,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -558,7 +565,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
.getDrawable(mContext, mLabelLocationNormalImage); .getDrawable(mContext, mLabelLocationNormalImage);
PictureMarkerSymbol destinationSymbolCenter = PictureMarkerSymbol.createAsync(bitmapDrawableCenter).get(); PictureMarkerSymbol destinationSymbolCenter = PictureMarkerSymbol.createAsync(bitmapDrawableCenter).get();
mCenteredGraphic.setSymbol(destinationSymbolCenter); mCenteredGraphic.setSymbol(destinationSymbolCenter);
requestGeoCeoder(point, Variable.LocationChangeType.IMPORT_POINT,FLAG_CREATE_MARKER,false,false); requestGeoCeoder(point, Variable.LocationChangeType.IMPORT_POINT, FLAG_CREATE_MARKER, false, false);
} catch (InterruptedException | ExecutionException ie) { } catch (InterruptedException | ExecutionException ie) {
ie.printStackTrace(); ie.printStackTrace();
...@@ -805,7 +812,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -805,7 +812,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
mCallout.setStyle(mCalloutStyle); mCallout.setStyle(mCalloutStyle);
mCallout.setLocation(point); mCallout.setLocation(point);
mCallout.setContent(view); mCallout.setContent(view);
if(isShowCallout){ if (isShowCallout) {
mCallout.show(); mCallout.show();
} }
mMapView.setViewpointCenterAsync(point); mMapView.setViewpointCenterAsync(point);
...@@ -851,7 +858,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -851,7 +858,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
Point centerPoint = (Point) mCenteredGraphic.getGeometry(); Point centerPoint = (Point) mCenteredGraphic.getGeometry();
for (LocationModel locationModel : locationModelList) { for (LocationModel locationModel : locationModelList) {
if (locationModel.getXPoint() == centerPoint.getX() && locationModel.getYPoint() == centerPoint.getY()) { if (locationModel.getXPoint() == centerPoint.getX() && locationModel.getYPoint() == centerPoint.getY()) {
setCallout(mCenteredGraphic, locationModel.getAddress(), locationModel.getPoi(),true); setCallout(mCenteredGraphic, locationModel.getAddress(), locationModel.getPoi(), true);
} }
} }
} else { } else {
...@@ -882,9 +889,9 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -882,9 +889,9 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
PictureMarkerSymbol destinationSymbolSelected = PictureMarkerSymbol.createAsync(getBitmapDrawable(mLabelLocationSelectedImage)).get(); PictureMarkerSymbol destinationSymbolSelected = PictureMarkerSymbol.createAsync(getBitmapDrawable(mLabelLocationSelectedImage)).get();
mCenteredGraphic.setSymbol(destinationSymbolSelected); mCenteredGraphic.setSymbol(destinationSymbolSelected);
if(mFollowMapGetCenterPoint){ if (mFollowMapGetCenterPoint) {
requestGeoCeoder(point, Variable.LocationChangeType.MOVE_MAP, FLAG_CREATE_MARKER); requestGeoCeoder(point, Variable.LocationChangeType.MOVE_MAP, FLAG_CREATE_MARKER);
}else{ } else {
requestGeoCeoder(point, Variable.LocationChangeType.CLICK_MAP, FLAG_CREATE_MARKER); requestGeoCeoder(point, Variable.LocationChangeType.CLICK_MAP, FLAG_CREATE_MARKER);
} }
...@@ -993,14 +1000,14 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -993,14 +1000,14 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if(view.getId() == R.id.location_iv){ if (view.getId() == R.id.location_iv) {
mMapView.setViewpointRotationAsync(0); mMapView.setViewpointRotationAsync(0);
if (mManualGraphicsOverlay != null) { if (mManualGraphicsOverlay != null) {
startLocation(mManualXPoint, mManualYPoint, mManualScale); startLocation(mManualXPoint, mManualYPoint, mManualScale);
} else { } else {
startLocation(mScale); startLocation(mScale);
} }
}else if(view.getId() == R.id.import_iv){ } else if (view.getId() == R.id.import_iv) {
initStoragePermission(); initStoragePermission();
} }
} }
...@@ -1044,7 +1051,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -1044,7 +1051,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
Point centerPoint = (Point) mCenteredGraphic.getGeometry(); Point centerPoint = (Point) mCenteredGraphic.getGeometry();
for (LocationModel locationModel : locationModelList) { for (LocationModel locationModel : locationModelList) {
if (locationModel.getXPoint() == centerPoint.getX() && locationModel.getYPoint() == centerPoint.getY()) { if (locationModel.getXPoint() == centerPoint.getX() && locationModel.getYPoint() == centerPoint.getY()) {
setCallout(mCenteredGraphic, locationModel.getAddress(), locationModel.getPoi(),true); setCallout(mCenteredGraphic, locationModel.getAddress(), locationModel.getPoi(), true);
} }
} }
} else { } else {
...@@ -1095,6 +1102,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -1095,6 +1102,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
public void setLocationImage(int locationImage) { public void setLocationImage(int locationImage) {
mLocationIv.setImageDrawable(getResources().getDrawable(locationImage)); mLocationIv.setImageDrawable(getResources().getDrawable(locationImage));
} }
/** /**
* @param importImage int(资源ID)-导入图片 * @param importImage int(资源ID)-导入图片
*/ */
...@@ -1159,30 +1167,44 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -1159,30 +1167,44 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
/** /**
* 正常点击显示加载狂,显示气泡组件 * 正常点击显示加载狂,显示气泡组件
*
* @param point 坐标点 * @param point 坐标点
* @param what 标志位 * @param what 标志位
*/ */
private void requestGeoCeoder(Point point, Variable.LocationChangeType locationChangeType, int what) { private void requestGeoCeoder(Point point, Variable.LocationChangeType locationChangeType, int what) {
requestGeoCeoder(point,locationChangeType,what,true,true); requestGeoCeoder(point, locationChangeType, what, true, true);
} }
/** /**
* 天地图逆地址编码 * 天地图逆地址编码
* 当导入数据得时候,不显示加载框,不显示气泡组件 * 当导入数据得时候,不显示加载框,不显示气泡组件
* @param point 当前点位 *
* @param what 标志位 * @param point 当前点位
* @param isLoading 加载框 * @param what 标志位
* @param isLoading 加载框
* @param showCallout 气泡 * @param showCallout 气泡
*/ */
private void requestGeoCeoder(Point point,Variable.LocationChangeType locationChangeType, int what, boolean isLoading, boolean showCallout) { private void requestGeoCeoder(Point point, Variable.LocationChangeType locationChangeType, int what, boolean isLoading, boolean showCallout) {
if(isLoading){ if (isLoading) {
showDialog(); showDialog();
} }
String urlParams = Constants.BASE_TIANDITU_GEO_URL + "?postStr={'lon':" + point.getX() + ",'lat':" + point.getY() + ",'ver':1}&type=geocode&tk=" + Constants.BASE_TIANDITU_KEY;
OkHttp3Utils.doGet(urlParams, new Callback() { double[] lngArray = ToolUtil.calcMaxMinLng(point, 0.5);
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("jsjd", String.valueOf(lngArray[0]));
jsonObject.put("qsjd", String.valueOf(lngArray[1]));
jsonObject.put("jswd", String.valueOf(lngArray[2]));
jsonObject.put("qswd", String.valueOf(lngArray[3]));
} catch (JSONException e) {
e.printStackTrace();
}
OkHttp3Utils.doPost(Constants.BASE_GEO_URL, jsonObject.toString(), new Callback() {
@Override @Override
public void onFailure(Call call, IOException e) { public void onFailure(Call call, IOException e) {
disDialog(); disDialog();
Toast.makeText(mContext, "请求失败,请重试", Toast.LENGTH_LONG).show();
Log.e("Fail", "e=" + e.toString());
} }
@Override @Override
...@@ -1192,26 +1214,78 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -1192,26 +1214,78 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
String poi = null; String poi = null;
if (response.isSuccessful()) { if (response.isSuccessful()) {
if (response.body() != null) { if (response.body() != null) {
String responseString = response.body().string(); String responseStr = response.body().string();
JsonObject jsonObject = GsonUtil.gsonToBean(responseString, JsonObject.class); Log.e("responseStr", responseStr);
String status = jsonObject.get("status").getAsString(); JsonObject jsonObject = GsonUtil.gsonToBean(responseStr, JsonObject.class);
if (status.equals("0")) { int status = jsonObject.get("status").getAsInt();
JsonObject resultObject = jsonObject.get("result").getAsJsonObject(); if (status == 200) {
address = resultObject.get("formatted_address").getAsString(); JsonArray dataArray = jsonObject.get("data").getAsJsonArray();
JsonObject addressComponentObject = resultObject.get("addressComponent").getAsJsonObject(); if (dataArray != null && dataArray.size() > 0) {
// address = addressComponentObject.get("address").getAsString(); JsonObject jsonObject1 = (JsonObject) dataArray.get(0);
poi = addressComponentObject.get("poi").getAsString(); //地址全称
address = jsonObject1.get("dzqc").getAsString();
///所属派出所代码_名称
poi = jsonObject1.get("sspcsdm_mc").getAsString();
// if (dataArray.size() == 1) {
// JsonObject jsonObject1 = (JsonObject) dataArray.get(0);
// //地址全称
// address = jsonObject1.get("dzqc").getAsString();
// ///所属派出所代码_名称
// poi = jsonObject1.get("sspcsdm_mc").getAsString();
// } else {
//
// }
}
} }
} }
} }
Message message = Message.obtain(); Message message = Message.obtain();
message.obj = new LocationModel(point.getX(), point.getY(), address, poi, null,locationChangeType); message.obj = new LocationModel(point.getX(), point.getY(), address, poi, null, locationChangeType);
message.what = what; message.what = what;
message.arg1 = showCallout ? 0 : 1; message.arg1 = showCallout ? 0 : 1;
mHandler.sendMessage(message); mHandler.sendMessage(message);
} }
}); });
/**************天地图的逆地址编码**************************/
// String urlParams = Constants.BASE_TIANDITU_GEO_URL + "?postStr={'lon':" + point.getX() + ",'lat':" + point.getY() + ",'ver':1}&type=geocode&tk=" + Constants.BASE_TIANDITU_KEY;
// OkHttp3Utils.doGet(urlParams, new Callback() {
// @Override
// public void onFailure(Call call, IOException e) {
// disDialog();
// }
//
// @Override
// public void onResponse(Call call, Response response) throws IOException {
// disDialog();
// String address = null;
// String poi = null;
// if (response.isSuccessful()) {
// if (response.body() != null) {
// String responseString = response.body().string();
// JsonObject jsonObject = GsonUtil.gsonToBean(responseString, JsonObject.class);
// String status = jsonObject.get("status").getAsString();
// if (status.equals("0")) {
// JsonObject resultObject = jsonObject.get("result").getAsJsonObject();
// address = resultObject.get("formatted_address").getAsString();
// JsonObject addressComponentObject = resultObject.get("addressComponent").getAsJsonObject();
//// address = addressComponentObject.get("address").getAsString();
// poi = addressComponentObject.get("poi").getAsString();
// }
// }
// }
//
// Message message = Message.obtain();
// message.obj = new LocationModel(point.getX(), point.getY(), address, poi, null, locationChangeType);
// message.what = what;
// message.arg1 = showCallout ? 0 : 1;
// mHandler.sendMessage(message);
// }
// });
} }
...@@ -1229,7 +1303,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList ...@@ -1229,7 +1303,7 @@ public class ArcGisLocationView extends LinearLayout implements View.OnClickList
break; break;
case FLAG_CREATE_MARKER: case FLAG_CREATE_MARKER:
locationModelList.add(locationModel); locationModelList.add(locationModel);
setCallout(mCenteredGraphic, locationModel.getAddress(), locationModel.getPoi(),msg.arg1 == 0); setCallout(mCenteredGraphic, locationModel.getAddress(), locationModel.getPoi(), msg.arg1 == 0);
if (mILocationChangeListener != null) { if (mILocationChangeListener != null) {
mILocationChangeListener.locationCallBack(locationModel); mILocationChangeListener.locationCallBack(locationModel);
} }
......
...@@ -60,6 +60,7 @@ import java.util.List; ...@@ -60,6 +60,7 @@ import java.util.List;
import cn.com.founder.arcgislib.R; import cn.com.founder.arcgislib.R;
import cn.com.founder.arcgislib.common.Variable; import cn.com.founder.arcgislib.common.Variable;
import cn.com.founder.arcgislib.constants.Constants;
import cn.com.founder.arcgislib.model.SearchModel; import cn.com.founder.arcgislib.model.SearchModel;
import cn.com.founder.arcgislib.search.listener.ISearchSelectedListener; import cn.com.founder.arcgislib.search.listener.ISearchSelectedListener;
import cn.com.founder.arcgislib.utils.DensityUtil; import cn.com.founder.arcgislib.utils.DensityUtil;
...@@ -220,7 +221,7 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener, ...@@ -220,7 +221,7 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener,
private void initRoute() { private void initRoute() {
//互联网是GCJ-02,内网是WGS-84:内网不用转,在互联网上测试时转换时先将自己的地图点(WGS-84,ArcGis(4326))转换成GCJ-02,获取到路网数据以后,再将GCJ-02转换成WGS-84坐标 //互联网是GCJ-02,内网是WGS-84:内网不用转,在互联网上测试时转换时先将自己的地图点(WGS-84,ArcGis(4326))转换成GCJ-02,获取到路网数据以后,再将GCJ-02转换成WGS-84坐标
if (mineNaviRoute == null) { if (mineNaviRoute == null) {
MineNaviMain.getInstance().setNaviURL("minedata.cn/lbsservice/navi/"); MineNaviMain.getInstance().setNaviURL(Constants.BASE_NAVI_URL);
/** /**
* 获取路径 * 获取路径
*/ */
...@@ -530,21 +531,21 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener, ...@@ -530,21 +531,21 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener,
Log.i(TAG, "====GPS回调经纬度=======" + simpleGidPoint.pos.getLatitude() + "," + simpleGidPoint.pos.getLongitude()); Log.i(TAG, "====GPS回调经纬度=======" + simpleGidPoint.pos.getLatitude() + "," + simpleGidPoint.pos.getLongitude());
} }
arcGisLocationView.mRouteMarkerGraphicsOverlay.getGraphics().clear(); arcGisLocationView.mRouteMarkerGraphicsOverlay.getGraphics().clear();
if(matchRes != null){ if (matchRes != null) {
double[] pointArr = GpsUtil.toWGS84Point(matchRes.pos.getLatitude(), matchRes.pos.getLongitude()); double[] pointArr = GpsUtil.toWGS84Point(matchRes.pos.getLatitude(), matchRes.pos.getLongitude());
Point point = new Point(pointArr[1],pointArr[0], SpatialReference.create(4326)); Point point = new Point(pointArr[1], pointArr[0], SpatialReference.create(4326));
try { try {
BitmapDrawable bitmapDrawableNormal = (BitmapDrawable) ContextCompat BitmapDrawable bitmapDrawableNormal = (BitmapDrawable) ContextCompat
.getDrawable(mContext, R.drawable.icon_route_text_start); .getDrawable(mContext, R.drawable.icon_route_text_start);
PictureMarkerSymbol destinationSymbolNormal= PictureMarkerSymbol.createAsync(bitmapDrawableNormal).get(); PictureMarkerSymbol destinationSymbolNormal = PictureMarkerSymbol.createAsync(bitmapDrawableNormal).get();
if(matchRes.dir < 0){ if (matchRes.dir < 0) {
matchRes.dir += 360; matchRes.dir += 360;
} }
destinationSymbolNormal.setAngle( -matchRes.dir); destinationSymbolNormal.setAngle(-matchRes.dir);
arcGisLocationView.mRouteMarkerGraphicsOverlay.getGraphics().add(new Graphic(point, destinationSymbolNormal)); arcGisLocationView.mRouteMarkerGraphicsOverlay.getGraphics().add(new Graphic(point, destinationSymbolNormal));
arcGisLocationView.mMapView.setViewpointCenterAsync(point); arcGisLocationView.mMapView.setViewpointCenterAsync(point);
arcGisLocationView.mMapView.setViewpointScaleAsync(mapScanleValue/20); arcGisLocationView.mMapView.setViewpointScaleAsync(mapScanleValue / 20);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
...@@ -933,11 +934,11 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener, ...@@ -933,11 +934,11 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener,
naviTv.setOnClickListener(view -> { naviTv.setOnClickListener(view -> {
startNavi(); startNavi();
mineNaviGuide.startDemo(); // mineNaviGuide.startDemo();
mineNaviGuide.setDemoSpeed(MineNaviGuide.DEMO_SPEED_Middle); // mineNaviGuide.setDemoSpeed(MineNaviGuide.DEMO_SPEED_Middle);
//导航 //导航
// mineNaviGuide.startGuide(); mineNaviGuide.startGuide();
}); });
addView(bottomView); addView(bottomView);
} }
...@@ -947,7 +948,7 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener, ...@@ -947,7 +948,7 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener,
private void startNavi() { private void startNavi() {
Toast.makeText(mContext, "开始导航", Toast.LENGTH_LONG).show(); Toast.makeText(mContext, "开始导航", Toast.LENGTH_LONG).show();
ttsProvider.startSpeak("模拟导航开始"); ttsProvider.startSpeak("导航开始");
if (bottomView != null) { if (bottomView != null) {
bottomView.setVisibility(View.GONE); bottomView.setVisibility(View.GONE);
...@@ -963,9 +964,9 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener, ...@@ -963,9 +964,9 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener,
} }
if (ArcGisSearchView.instance != null) { if (ArcGisSearchView.instance != null) {
if(isHasSearchView){ if (isHasSearchView) {
ArcGisSearchView.instance.setVisibility(View.VISIBLE); ArcGisSearchView.instance.setVisibility(View.VISIBLE);
}else{ } else {
ArcGisSearchView.instance.setVisibility(View.GONE); ArcGisSearchView.instance.setVisibility(View.GONE);
} }
...@@ -1006,7 +1007,7 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener, ...@@ -1006,7 +1007,7 @@ public class ArcGisNaviView extends FrameLayout implements View.OnClickListener,
@Override @Override
protected void onWindowVisibilityChanged(int visibility) { protected void onWindowVisibilityChanged(int visibility) {
super.onWindowVisibilityChanged(visibility); super.onWindowVisibilityChanged(visibility);
switch (visibility){ switch (visibility) {
case 0://onResume case 0://onResume
break; break;
......
...@@ -27,6 +27,8 @@ import androidx.recyclerview.widget.LinearLayoutManager; ...@@ -27,6 +27,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.minedata.minenavi.common.OkHttp3Utils; import com.minedata.minenavi.common.OkHttp3Utils;
import org.json.JSONException; import org.json.JSONException;
...@@ -354,14 +356,37 @@ public class ArcGisSearchView extends LinearLayout { ...@@ -354,14 +356,37 @@ public class ArcGisSearchView extends LinearLayout {
disDialog(); disDialog();
if (response.isSuccessful()) { if (response.isSuccessful()) {
if (response.body() != null) { if (response.body() != null) {
String jsonString = GsonUtil.getNoteJsonString(response.body().string(), "data"); String responseStr = response.body().string();
List<SearchModel> searchModelList = (List<SearchModel>) GsonUtil.jsonToList(jsonString, SearchModel.class); JsonObject jsonObject = GsonUtil.gsonToBean(responseStr, JsonObject.class);
if (searchModelList != null && searchModelList.size() > 0) { int status = jsonObject.get("status").getAsInt();
Message message = new Message(); if (status == 200) {
message.what = HANDLE_MSG_HAS_DATA; JsonArray dataArray = jsonObject.get("data").getAsJsonArray();
message.obj = searchModelList; if(dataArray !=null && dataArray.size() > 0){
mHandler.sendMessage(message); List<SearchModel> searchModelList = new ArrayList<>();
} else { for (int i = 0; i < dataArray.size(); i++) {
JsonObject jsonObject1 = (JsonObject) dataArray.get(i);
SearchModel searchModel = new SearchModel();
searchModel.setX(jsonObject1.get("x").getAsDouble());
searchModel.setY(jsonObject1.get("y").getAsDouble());
searchModel.setPoiaddress(jsonObject1.get("poiaddress").getAsString());
searchModel.setPoiname(jsonObject1.get("poiname").getAsString());
searchModelList.add(searchModel);
}
if (searchModelList.size() > 0) {
Message message = new Message();
message.what = HANDLE_MSG_HAS_DATA;
message.obj = searchModelList;
mHandler.sendMessage(message);
} else {
mHandler.sendEmptyMessage(HANDLE_MSG_NO_DATA);
}
}else{
mHandler.sendEmptyMessage(HANDLE_MSG_NO_DATA);
}
}else{
mHandler.sendEmptyMessage(HANDLE_MSG_NO_DATA); mHandler.sendEmptyMessage(HANDLE_MSG_NO_DATA);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment