From 34b2dee7c648f0cebe72e75b45e32f89822b6448 Mon Sep 17 00:00:00 2001 From: ZCShou <72115@163.com> Date: Thu, 30 Sep 2021 14:29:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=82=AC=E6=B5=AE?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E3=80=81=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E3=80=81=E4=B8=BB=E7=95=8C=E9=9D=A2=E4=B8=89=E8=80=85=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE=E6=9C=89=E5=8F=AF=E8=83=BD=E4=B8=8D=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/zcshou/joystick/JoyStick.java | 33 +++++++++++-------- .../java/com/zcshou/service/ServiceGo.java | 1 + 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/zcshou/joystick/JoyStick.java b/app/src/main/java/com/zcshou/joystick/JoyStick.java index 60a56db..8fbaaef 100644 --- a/app/src/main/java/com/zcshou/joystick/JoyStick.java +++ b/app/src/main/java/com/zcshou/joystick/JoyStick.java @@ -167,6 +167,7 @@ public class JoyStick extends View { mWindowManager.removeView(mHistoryLayout); } if (mMapLayout.getParent() == null) { + resetBaiduMap(); mWindowManager.addView(mMapLayout, mWindowParamMap); } break; @@ -394,13 +395,11 @@ public class JoyStick extends View { } }); mSearchList.setOnItemClickListener((parent, view, position, id) -> { - String lng = ((TextView) view.findViewById(R.id.poi_longitude)).getText().toString(); - String lat = ((TextView) view.findViewById(R.id.poi_latitude)).getText().toString(); - LatLng latLng = new LatLng(Double.parseDouble(lat), Double.parseDouble(lng)); - mSearchLayout.setVisibility(View.GONE); - markBaiduMap(latLng); + String lng = ((TextView) view.findViewById(R.id.poi_longitude)).getText().toString(); + String lat = ((TextView) view.findViewById(R.id.poi_latitude)).getText().toString(); + markBaiduMap(new LatLng(Double.parseDouble(lat), Double.parseDouble(lng))); }); TextView tips = mMapLayout.findViewById(R.id.joystick_map_tips); @@ -448,8 +447,8 @@ public class JoyStick extends View { } }); - ImageButton btnOk = mMapLayout.findViewById(R.id.btnGo); - btnOk.setOnClickListener(v -> { + ImageButton btnGo = mMapLayout.findViewById(R.id.btnGo); + btnGo.setOnClickListener(v -> { // 关闭时清除焦点 mWindowParamMap.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL @@ -468,7 +467,7 @@ public class JoyStick extends View { GoUtils.DisplayToast(mContext, "位置已传送"); }); - btnOk.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); + btnGo.setColorFilter(getResources().getColor(R.color.colorAccent, mContext.getTheme())); ImageButton btnClose = mMapLayout.findViewById(R.id.map_close); btnClose.setOnClickListener(v -> { @@ -634,17 +633,23 @@ public class JoyStick extends View { mSearchView.onActionViewCollapsed(); tips.setVisibility(VISIBLE); - String wgs84Longitude; - String wgs84Latitude; - //wgs84坐标 + // wgs84坐标 String wgs84LatLng = (String) ((TextView) view.findViewById(R.id.WGSLatLngText)).getText(); wgs84LatLng = wgs84LatLng.substring(wgs84LatLng.indexOf("[") + 1, wgs84LatLng.indexOf("]")); - String[] latLngStr2 = wgs84LatLng.split(" "); - wgs84Longitude = latLngStr2[0].substring(latLngStr2[0].indexOf(":") + 1); - wgs84Latitude = latLngStr2[1].substring(latLngStr2[1].indexOf(":") + 1); + String[] wgs84latLngStr = wgs84LatLng.split(" "); + String wgs84Longitude = wgs84latLngStr[0].substring(wgs84latLngStr[0].indexOf(":") + 1); + String wgs84Latitude = wgs84latLngStr[1].substring(wgs84latLngStr[1].indexOf(":") + 1); mListener.onPositionInfo(Double.parseDouble(wgs84Longitude), Double.parseDouble(wgs84Latitude)); + // 注意这里在选择位置之后需要刷新地图 + String bdLatLng = (String) ((TextView) view.findViewById(R.id.BDLatLngText)).getText(); + bdLatLng = bdLatLng.substring(bdLatLng.indexOf("[") + 1, bdLatLng.indexOf("]")); + String[] bdLatLngStr = bdLatLng.split(" "); + String bdLongitude = bdLatLngStr[0].substring(bdLatLngStr[0].indexOf(":") + 1); + String bdLatitude = bdLatLngStr[1].substring(bdLatLngStr[1].indexOf(":") + 1); + mCurMapLngLat = new LatLng(Double.parseDouble(bdLatitude), Double.parseDouble(bdLongitude)); + GoUtils.DisplayToast(mContext, "位置已传送"); }); diff --git a/app/src/main/java/com/zcshou/service/ServiceGo.java b/app/src/main/java/com/zcshou/service/ServiceGo.java index 8157009..8c8e152 100644 --- a/app/src/main/java/com/zcshou/service/ServiceGo.java +++ b/app/src/main/java/com/zcshou/service/ServiceGo.java @@ -290,6 +290,7 @@ public class ServiceGo extends Service { mCurLng = lng; mCurLat = lat; mLocHandler.sendEmptyMessage(HANDLER_MSG_ID); + mJoyStick.setCurrentPosition(mCurLng, mCurLat); } } }