From 2fb397e4a31d14880ed2524f898ae67a0d664c06 Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期二, 17 十二月 2024 11:24:29 +0800 Subject: [PATCH] 1.在地图中心显示中心点。 2.优化地图覆盖物显示,使显示的图标正对坐标。 3.优化地图覆盖物文字居中显示。 --- app/src/main/res/drawable/ic_edit_btn.xml | 19 + app/src/main/res/drawable/ic_intake.xml | 20 + app/src/main/res/layout/fragment_map.xml | 225 ++++++++--- app/src/main/assets/js/map.js | 130 +++--- app/src/main/res/layout/activity_intake_detail.xml | 183 +++++++++ app/src/main/res/drawable/ic_center_pin.xml | 9 app/src/main/java/com/dayu/pipirrapp/bean/net/MarkerListResult.java | 59 +++ app/src/main/java/com/dayu/pipirrapp/bean/net/MarkerResult.java | 294 ++++++--------- app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java | 160 ++++---- app/src/main/res/values/dimens.xml | 2 10 files changed, 715 insertions(+), 386 deletions(-) diff --git a/app/src/main/assets/js/map.js b/app/src/main/assets/js/map.js index 3df1bb6..3b54c66 100644 --- a/app/src/main/assets/js/map.js +++ b/app/src/main/assets/js/map.js @@ -4,11 +4,27 @@ const markerBalckPath = 'img/marker_black.svg'; const markerRedPath = 'img/marker_red.svg'; const markerBluePath = 'img/marker_blue.svg'; + const centerPin = 'img/push_pin.svg'; let map; let lastMarker = null; let lastClickedMarker = null; let isShowWaterIntakeDetail = false; let zoom = 12; + + // 灏嗘柟娉曟寕杞藉埌 window 涓� + function mountMethodToWindow() { + window.locationOverLay = locationOverLay; + window.showToast = showToast; + window.addMarker = addMarker; + window.setCenterAndZoom = setCenterAndZoom; + window.updateLocation = updateLocation; + window.aginShowLocation = aginShowLocation; + window.cleanLocationLay = cleanLocationLay; + window.updateInspectionLocation = updateInspectionLocation; + window.cleanLoclLay = cleanLoclLay; + window.showPin = showPin; + + } document.addEventListener('DOMContentLoaded', function () { @@ -87,47 +103,6 @@ } } - // 妯℃嫙娣诲姞鍙栨按鍙f爣娉� - function buttonOverLay() { - map.clearOverLays(); // 娓呯悊鍦板浘涓婄殑鎵�鏈夎鐩栫墿 - - let data_info = [ - [116.417854, 39.921988, "235鍙栨按鍙�"], - [116.406605, 39.921585, "237鍙栨按鍙�"], - [116.412222, 39.912345, "236鍙栨按鍙�"] - ]; - - for (let i = 0; i < data_info.length; i++) { - let icon = new T.Icon({ - iconUrl: markerBluePath, - iconSize: new T.Point(27, 27), - iconAnchor: new T.Point(10, 25) - }); - - let marker = new T.Marker( - new T.LngLat(data_info[i][0], data_info[i][1]), // 鍒涘缓鏍囨敞 - { icon: icon } - ); - - marker.addEventListener("click", function (data) { - addMarkerListener(data); - }); - - map.addOverLay(marker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓� - - let label = new T.Label({ - text: data_info[i][2], - position: marker.getLngLat(), - offset: new T.Point(-50, 10), // 璁剧疆鏍囨敞鏂囧瓧鐨勪綅缃� - opacity: 1, // 璁剧疆鏂囨湰鐨勬樉绀轰笉閫忔槑搴︼紙鑼冨洿0-1锛� - }); - label.setBorderLine(0); // 璁剧疆鏂囨湰鐨勮竟妗嗙嚎瀹� - label.setBackgroundColor("transparent"); // 璁剧疆鏂囨湰鐨勮儗鏅壊锛堥�忔槑鑹诧級 - label.setFontColor("#0000FF"); - label.setFontSize(10); - map.addOverLay(label); - } - } // 鏄剧ず鏍囨敞鐐瑰嚮鍚庣殑绐楀彛 function openInfo(content, e) { @@ -161,19 +136,7 @@ } - // 灏嗘柟娉曟寕杞藉埌 window 涓� - function mountMethodToWindow() { - window.locationOverLay = locationOverLay; - window.showToast = showToast; - window.addMarker = addMarker; - window.setCenterAndZoom = setCenterAndZoom; - window.updateLocation = updateLocation; - window.aginShowLocation = aginShowLocation; - window.cleanLocationLay = cleanLocationLay; - window.updateInspectionLocation = updateInspectionLocation; - window.cleanLoclLay = cleanLoclLay; - } // 璋冪敤鍘熺敓瀹夊崜鏂规硶鏄剧ず鍙栨按鍙h鎯� function showWaterIntakeDetail(data) { @@ -188,8 +151,8 @@ // 涓婃鐐瑰嚮鐨勬爣娉ㄦ敼涓洪粦鑹� var defaulticon = new T.Icon({ iconUrl: markerBluePath, - iconSize: new T.Point(27, 27), - iconAnchor: new T.Point(10, 25) + iconSize: new T.Point(28, 28), + iconAnchor: new T.Point(14, 28) }); lastClickedMarker.setIcon(defaulticon); } @@ -204,7 +167,7 @@ } // 鐐瑰嚮鏍囨敞鐨勪簨浠� - function addMarkerListener(id,data) { + function addMarkerListener(id, data) { chageMarkerIcon(data); showWaterIntakeDetail(id); } @@ -216,8 +179,8 @@ // 鐐瑰嚮鍚庡浘鏍� var clickedIcon = new T.Icon({ iconUrl: markerRedPath, - iconSize: new T.Point(27, 27), - iconAnchor: new T.Point(10, 25) + iconSize: new T.Point(28, 28), + iconAnchor: new T.Point(14, 28) }); // 璁剧疆褰撳墠鐐瑰嚮鐨� marker 涓虹偣鍑诲悗鍥炬爣 currentMarker.setIcon(clickedIcon); @@ -226,8 +189,8 @@ if (!isEqualsLngLat(data.target.getLngLat(), lastClickedMarker.getLngLat())) { var defaulticon = new T.Icon({ iconUrl: markerBluePath, - iconSize: new T.Point(27, 27), - iconAnchor: new T.Point(10, 25) + iconSize: new T.Point(28, 28), + iconAnchor: new T.Point(14, 28) }); lastClickedMarker.setIcon(defaulticon); } @@ -244,31 +207,31 @@ return data1.lat === data2.lat && data1.lng === data2.lng; } //娣诲姞浠庡師鐢熶紶杩囨潵鐨勫潗鏍囧苟鏄剧ず鍦ㄥ湴鍥句笂 - function addMarker(id,lng,lat,name) { + function addMarker(id, lng, lat, name) { console.log("function銆嬨�嬨�嬨�嬨�媋ddMarker"); - + var icon = new T.Icon({ iconUrl: markerBluePath, - iconSize: new T.Point(27, 27), - iconAnchor: new T.Point(10, 25) + iconSize: new T.Point(28, 28), + iconAnchor: new T.Point(14, 28) }); let marker = new T.Marker( new T.LngLat(lng, lat) // 鍒涘缓鏍囨敞 , { icon: icon }); //娣诲姞鐐瑰嚮浜嬩欢 marker.addEventListener("click", (data) => { - addMarkerListener(id,data) + addMarkerListener(id, data) }); map.addOverLay(marker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓� let label = new T.Label({ - text: name, + text: `<div style='position:absolute;left:-50%;transform: translateX(-50%);'>${name}<div>`, position: marker.getLngLat(), - offset: new T.Point(-35, 8), // 璁剧疆鏍囨敞鏂囧瓧鐨勪綅缃� + offset: new T.Point(0, 8), // 璁剧疆鏍囨敞鏂囧瓧鐨勪綅缃� opacity: 1, // 璁剧疆鏂囨湰鐨勬樉绀轰笉閫忔槑搴︼紙鑼冨洿0-1锛� }); label.setBorderLine(0); // 璁剧疆鏂囨湰鐨勮竟妗嗙嚎瀹� label.setBackgroundColor("transparent"); // 璁剧疆鏂囨湰鐨勮儗鏅壊锛堥�忔槑鑹诧級 - label.setFontColor("#0000FF"); + label.setFontColor("#FFFFFF"); label.setFontSize(10); map.addOverLay(label); return "addMarker鍔犺浇鎴愬姛" @@ -338,4 +301,35 @@ } + + //鍦ㄥ湴鍥句笂鏄剧ず涓績鐐� + var pinMarker; + function showPin() { + var icon = new T.Icon({ + iconUrl: centerPin, + iconSize: new T.Point(28, 28), + iconAnchor: new T.Point(14, 28) + }); + pinMarker = new T.Marker( + new T.LngLat(map.getCenter().getLng(), map.getCenter().getLat()) // 鍒涘缓鏍囨敞 + , { icon: icon }); + map.addOverLay(pinMarker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓� + map.addEventListener("moveend", MapMoveend); + } + + function MapMoveend(e) { + map.removeOverLay(pinMarker); + var icon = new T.Icon({ + iconUrl: centerPin, + iconSize: new T.Point(28, 28), + iconAnchor: new T.Point(14, 28) + }); + var center = e.target.getCenter(); + console.log("lng:" + center.getLng() + " lat:" + center.getLat()) + pinMarker = new T.Marker( + new T.LngLat(center.getLng(), center.getLat()) // 鍒涘缓鏍囨敞 + , { icon: icon }); + map.addOverLay(pinMarker); // 灏嗘爣娉ㄦ坊鍔犲埌鍦板浘涓� + } + })(); diff --git a/app/src/main/java/com/dayu/pipirrapp/bean/net/MarkerListResult.java b/app/src/main/java/com/dayu/pipirrapp/bean/net/MarkerListResult.java new file mode 100644 index 0000000..54663cf --- /dev/null +++ b/app/src/main/java/com/dayu/pipirrapp/bean/net/MarkerListResult.java @@ -0,0 +1,59 @@ +package com.dayu.pipirrapp.bean.net; + +import java.util.List; + +/** + * author; zuo + * Date; 2024-09-20 + * Time; 14;12 + * 澶囨敞锛氬彇姘村彛鍒楄〃 + */ +public class MarkerListResult extends BaseResult { + int itemTotal; + int pageCurr; + int pageSize; + int pageTotal; + List<MarkerResult> obj; + + public int getItemTotal() { + return itemTotal; + } + + public void setItemTotal(int itemTotal) { + this.itemTotal = itemTotal; + } + + public int getPageCurr() { + return pageCurr; + } + + public void setPageCurr(int pageCurr) { + this.pageCurr = pageCurr; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPageTotal() { + return pageTotal; + } + + public void setPageTotal(int pageTotal) { + this.pageTotal = pageTotal; + } + + public List<MarkerResult> getObj() { + return obj; + } + + public void setObj(List<MarkerResult> obj) { + this.obj = obj; + } + + +} diff --git a/app/src/main/java/com/dayu/pipirrapp/bean/net/MarkerResult.java b/app/src/main/java/com/dayu/pipirrapp/bean/net/MarkerResult.java index 8d49c0f..9cdd6d1 100644 --- a/app/src/main/java/com/dayu/pipirrapp/bean/net/MarkerResult.java +++ b/app/src/main/java/com/dayu/pipirrapp/bean/net/MarkerResult.java @@ -1,200 +1,150 @@ package com.dayu.pipirrapp.bean.net; -import java.util.List; - /** - * author; zuo - * Date; 2024-09-20 - * Time; 14;12 - * 澶囨敞锛� + * MarkerResult -鍙栨按鍙h鎯� + * + * @author zuoxiao + * @version 1.0 + * @since 2024-12-16 */ -public class MarkerResult extends BaseResult { - int itemTotal; - int pageCurr; - int pageSize; - int pageTotal; - List<Obj> obj; +public class MarkerResult { + String blockId; - public int getItemTotal() { - return itemTotal; + String deleted;//閫昏緫鍒犻櫎鏍囪瘑 + String divideId;//string + + String id; + String lat;//缁忓害 + String lng;//绾害 + + String name;//鍙栨按鍙e悕绉� + + String operateDt;//鎿嶄綔鏃堕棿 + String operator;//鎿嶄綔浜虹紪鍙� + String remarks;//澶囨敞 + String townId;//鎵�鍦ㄩ晣缂栧彿 + String villageId;//鎵�鍦ㄦ潙缂栧彿 + String countyId;//鎵�鍦ㄥ幙缂栧彿 + String blockName; + String address; + + public String getBlockName() { + return blockName; } - public void setItemTotal(int itemTotal) { - this.itemTotal = itemTotal; + public void setBlockName(String blockName) { + this.blockName = blockName; } - public int getPageCurr() { - return pageCurr; + public String getAddress() { + return address; } - public void setPageCurr(int pageCurr) { - this.pageCurr = pageCurr; + public void setAddress(String address) { + this.address = address; } - public int getPageSize() { - return pageSize; + public String getBlockId() { + return blockId; } - public void setPageSize(int pageSize) { - this.pageSize = pageSize; + public void setBlockId(String blockId) { + this.blockId = blockId; } - public int getPageTotal() { - return pageTotal; + public String getDeleted() { + return deleted; } - public void setPageTotal(int pageTotal) { - this.pageTotal = pageTotal; + public void setDeleted(String deleted) { + this.deleted = deleted; } - public List<Obj> getObj() { - return obj; + public String getDivideId() { + return divideId; } - public void setObj(List<Obj> obj) { - this.obj = obj; + public void setDivideId(String divideId) { + this.divideId = divideId; } - public class Obj { - String blockId; - - String deleted;//閫昏緫鍒犻櫎鏍囪瘑 - String divideId;//string - - String id; - String lat;//缁忓害 - String lng;//绾害 - - String name;//鍙栨按鍙e悕绉� - - String operateDt;//鎿嶄綔鏃堕棿 - String operator;//鎿嶄綔浜虹紪鍙� - String remarks;//澶囨敞 - String townId;//鎵�鍦ㄩ晣缂栧彿 - String villageId;//鎵�鍦ㄦ潙缂栧彿 - String countyId;//鎵�鍦ㄥ幙缂栧彿 - String blockName; - String address; - - public String getBlockName() { - return blockName; - } - - public void setBlockName(String blockName) { - this.blockName = blockName; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public String getBlockId() { - return blockId; - } - - public void setBlockId(String blockId) { - this.blockId = blockId; - } - - public String getDeleted() { - return deleted; - } - - public void setDeleted(String deleted) { - this.deleted = deleted; - } - - public String getDivideId() { - return divideId; - } - - public void setDivideId(String divideId) { - this.divideId = divideId; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getLat() { - return lat; - } - - public void setLat(String lat) { - this.lat = lat; - } - - public String getLng() { - return lng; - } - - public void setLng(String lng) { - this.lng = lng; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getOperateDt() { - return operateDt; - } - - public void setOperateDt(String operateDt) { - this.operateDt = operateDt; - } - - public String getOperator() { - return operator; - } - - public void setOperator(String operator) { - this.operator = operator; - } - - public String getRemarks() { - return remarks; - } - - public void setRemarks(String remarks) { - this.remarks = remarks; - } - - public String getTownId() { - return townId; - } - - public void setTownId(String townId) { - this.townId = townId; - } - - public String getVillageId() { - return villageId; - } - - public void setVillageId(String villageId) { - this.villageId = villageId; - } - - public String getCountyId() { - return countyId; - } - - public void setCountyId(String countyId) { - this.countyId = countyId; - } + public String getId() { + return id; } + public void setId(String id) { + this.id = id; + } + + public String getLat() { + return lat; + } + + public void setLat(String lat) { + this.lat = lat; + } + + public String getLng() { + return lng; + } + + public void setLng(String lng) { + this.lng = lng; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getOperateDt() { + return operateDt; + } + + public void setOperateDt(String operateDt) { + this.operateDt = operateDt; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getRemarks() { + return remarks; + } + + public void setRemarks(String remarks) { + this.remarks = remarks; + } + + public String getTownId() { + return townId; + } + + public void setTownId(String townId) { + this.townId = townId; + } + + public String getVillageId() { + return villageId; + } + + public void setVillageId(String villageId) { + this.villageId = villageId; + } + + public String getCountyId() { + return countyId; + } + + public void setCountyId(String countyId) { + this.countyId = countyId; + } } diff --git a/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java b/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java index 986247b..61e1fa0 100644 --- a/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java +++ b/app/src/main/java/com/dayu/pipirrapp/fragment/MapFragment.java @@ -32,6 +32,7 @@ import com.dayu.pipirrapp.bean.net.CenterPointResult; import com.dayu.pipirrapp.bean.net.InsectionResult; import com.dayu.pipirrapp.bean.net.InspectionRequest; +import com.dayu.pipirrapp.bean.net.MarkerListResult; import com.dayu.pipirrapp.bean.net.MarkerResult; import com.dayu.pipirrapp.dao.DaoSingleton; import com.dayu.pipirrapp.databinding.FragmentMapBinding; @@ -92,6 +93,7 @@ LatLonBean lastLatLonBean; InspectionRequest inspectionRequest; // volatile boolean isHaseAginData = false; + //web鏄惁鍔犺浇瀹屾垚 volatile boolean webViewIsFinished = false; List<InspectionLocationBean> aginShowlocationBeans; //web鍔犺浇鏃剁綉椤佃繕娌″姞杞藉畬鏃剁殑鏁版嵁 @@ -135,20 +137,77 @@ mWebView.loadUrl("file:///android_asset/index.html"); getCenterPoint(); initView(); - + initWeb(); getMarkerData(); chageInspecState(mInspectionState); return binding.getRoot(); } + private void initWeb() { + mWebView.setWebViewClient(new WebViewClient() { + @Override + public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { + String url = request.getUrl().toString(); + //鍒ゆ柇褰撳墠鏄惁涓哄姞杞界摝鐗� + if (MapJpgUtils.getInsatance().isTianDiTuTileRequest(url)) { + String androidUrl = url.replace(CommonData.webKey, CommonData.androidKey); + // 妫�鏌ユ湰鍦扮紦瀛� + File cachedTile = MapJpgUtils.getInsatance().getCachedTile(androidUrl); + if (cachedTile != null && cachedTile.exists()) { +// Log.d(TAG, "鏈湴缂撳瓨>>>" + androidUrl); +// if (MapJpgUtils.getInsatance().validateImageFile(androidUrl,request.)) + // 鍒ゆ柇缂撳瓨鏄惁杩囨湡 +// if (!MapJpgUtils.getInsatance(MapFragment.this.getContext()).isCacheExpired(cachedTile)) { + try { + // 浠庣紦瀛樺姞杞界摝鐗� + return new WebResourceResponse("image/jpg", "utf-8", new FileInputStream(cachedTile)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } +// } + } else { + //涓嬭浇鐡︾墖 + ApiManager.getInstance().donwLoadTile(MapFragment.this.getContext(), androidUrl); + } - /** - * 鍒濆鍖栧悇涓姸鎬� - */ - private void initState() { - //寮�鍚畾浣� + } + + return super.shouldInterceptRequest(view, request); + } + + @Override + public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { + super.onReceivedError(view, request, error); + // 鎹曡幏鍔犺浇杩囩▼涓彂鐢熺殑閿欒 + int errorCode = error.getErrorCode(); + String description = error.getDescription().toString(); + String failingUrl = request.getUrl().toString(); + Log.e("setWebViewClient", "errorCode:" + errorCode + ">>>>description:" + description + ">>>>failingUrl:" + failingUrl); + // 澶勭悊閿欒锛屼緥濡傛樉绀洪敊璇〉闈㈡垨鎻愮ず鐢ㄦ埛 + } + + @Override + public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { + super.onReceivedHttpError(view, request, errorResponse); + // 鎹曡幏HTTP閿欒锛堝404, 500绛夛級 + int statusCode = errorResponse.getStatusCode(); + String description = errorResponse.getReasonPhrase(); + Log.e("setWebViewClient", "statusCode:" + statusCode + ">>>>description:" + description); + // 鏍规嵁HTTP鐘舵�佺爜澶勭悊閿欒 + } + + @Override + public void onPageFinished(WebView view, String url) { + super.onPageFinished(view, url); + //椤甸潰鍔犺浇瀹屾垚 + webViewIsFinished = true; + initLocalData(); + aginShowLocation(null); + + } + }); } /** @@ -179,15 +238,15 @@ * 鑾峰彇鍙栨按鍙e垪琛� */ private void getMarkerData() { - ApiManager.getInstance().requestGetHideLoading(this.getContext(), Constants.BASE_URL + "/project/intake/all", MarkerResult.class, null, new SubscriberListener<BaseResponse<MarkerResult>>() { + ApiManager.getInstance().requestGetHideLoading(this.getContext(), Constants.BASE_URL + "/project/intake/all", MarkerListResult.class, null, new SubscriberListener<BaseResponse<MarkerListResult>>() { @Override - public void onNext(BaseResponse<MarkerResult> t) { + public void onNext(BaseResponse<MarkerListResult> t) { if (t.isSuccess()) { if (t.isSuccess()) { if (t.getContent().getObj() != null && !t.getContent().getObj().isEmpty()) { List<MarkerBean> markerBeans = new ArrayList<>(); for (int i = 0; i < t.getContent().getObj().size(); i++) { - MarkerResult.Obj result = t.getContent().getObj().get(i); + MarkerResult result = t.getContent().getObj().get(i); //淇濆瓨鏁版嵁 MarkerBean markerBean = new MarkerBean(); markerBean.setId(result.getId()); @@ -229,71 +288,7 @@ void initView() { - mWebView.setWebViewClient(new WebViewClient() { - @Override - public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { - String url = request.getUrl().toString(); -// Log.d(TAG, "鍔犺浇鍦板潃>>>" + url); - //鍒ゆ柇褰撳墠鏄惁涓哄姞杞界摝鐗� - if (MapJpgUtils.getInsatance().isTianDiTuTileRequest(url)) { - String androidUrl = url.replace(CommonData.webKey, CommonData.androidKey); - // 妫�鏌ユ湰鍦扮紦瀛� - File cachedTile = MapJpgUtils.getInsatance().getCachedTile(androidUrl); - if (cachedTile != null && cachedTile.exists()) { -// Log.d(TAG, "鏈湴缂撳瓨>>>" + androidUrl); -// if (MapJpgUtils.getInsatance().validateImageFile(androidUrl,request.)) - // 鍒ゆ柇缂撳瓨鏄惁杩囨湡 -// if (!MapJpgUtils.getInsatance(MapFragment.this.getContext()).isCacheExpired(cachedTile)) { - try { - // 浠庣紦瀛樺姞杞界摝鐗� - return new WebResourceResponse("image/jpg", "utf-8", new FileInputStream(cachedTile)); - } catch (FileNotFoundException e) { - e.printStackTrace(); - } -// } - } else { - //涓嬭浇鐡︾墖 - ApiManager.getInstance().donwLoadTile(MapFragment.this.getContext(), androidUrl); - } -// Log.d(TAG, "鍦ㄧ嚎鍔犺浇>>>" + url); - } - - return super.shouldInterceptRequest(view, request); - } - - @Override - public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { - super.onReceivedError(view, request, error); - // 鎹曡幏鍔犺浇杩囩▼涓彂鐢熺殑閿欒 - int errorCode = error.getErrorCode(); - String description = error.getDescription().toString(); - String failingUrl = request.getUrl().toString(); - Log.e("setWebViewClient", "errorCode:" + errorCode + ">>>>description:" + description + ">>>>failingUrl:" + failingUrl); - // 澶勭悊閿欒锛屼緥濡傛樉绀洪敊璇〉闈㈡垨鎻愮ず鐢ㄦ埛 - // view.loadUrl("file:///android_asset/error.html"); - } - - @Override - public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) { - super.onReceivedHttpError(view, request, errorResponse); - // 鎹曡幏HTTP閿欒锛堝404, 500绛夛級 - int statusCode = errorResponse.getStatusCode(); - String description = errorResponse.getReasonPhrase(); - Log.e("setWebViewClient", "statusCode:" + statusCode + ">>>>description:" + description); - // 鏍规嵁HTTP鐘舵�佺爜澶勭悊閿欒 - } - - @Override - public void onPageFinished(WebView view, String url) { - super.onPageFinished(view, url); - //椤甸潰鍔犺浇瀹屾垚 - webViewIsFinished = true; - initLocalData(); - aginShowLocation(null); - - } - }); //宸℃鎸夐挳 binding.inspectButton.setOnClickListener(v -> { if (XXPermissions.isGranted(MapFragment.this.getContext(), Permission.ACCESS_BACKGROUND_LOCATION)) { @@ -325,17 +320,29 @@ Intent issue = new Intent(MapFragment.this.getActivity(), AddIssueActivity.class); MapFragment.this.getActivity().startActivity(issue); }); + + } - + /** + * 鏄剧ず鍙栨按鍙h鎯� + * + * @param data + */ public void showWaterIntakeDetail(String data) { MyLog.i(data); - MarkerBean markerBean= markerBeanSet.get(data); - if (markerBean!=null){ + MarkerBean markerBean = markerBeanSet.get(data); + if (markerBean != null) { binding.bottomLL.setVisibility(View.VISIBLE); binding.markerAddress.setText(markerBean.getAddress()); binding.markerName.setText(markerBean.getName()); binding.markerBlockName.setText(markerBean.getBlockName()); + binding.lat.setText(markerBean.getLat()); + binding.lng.setText(markerBean.getLng()); + binding.editePoint.setOnClickListener(v -> { + mWebView.evaluateJavascript("javascript:showPin()", value -> { + }); + }); } } @@ -345,7 +352,6 @@ * 鑾峰彇鍦板浘涓績鐐� */ private void getCenterPoint() { - ApiManager.getInstance().requestGet(this.getContext(), Constants.BASE_URL + "/base/dict_item/map_center", CenterPointResult.class, null, new SubscriberListener<BaseResponse<CenterPointResult>>() { @Override public void onNext(BaseResponse<CenterPointResult> t) { diff --git a/app/src/main/res/drawable/ic_center_pin.xml b/app/src/main/res/drawable/ic_center_pin.xml new file mode 100644 index 0000000..6d4b146 --- /dev/null +++ b/app/src/main/res/drawable/ic_center_pin.xml @@ -0,0 +1,9 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:pathData="M14,4v5c0,1.12 0.37,2.16 1,3H9c0.65,-0.86 1,-1.9 1,-3V4H14M17,2H7C6.45,2 6,2.45 6,3c0,0.55 0.45,1 1,1c0,0 0,0 0,0l1,0v5c0,1.66 -1.34,3 -3,3v2h5.97v7l1,1l1,-1v-7H19v-2c0,0 0,0 0,0c-1.66,0 -3,-1.34 -3,-3V4l1,0c0,0 0,0 0,0c0.55,0 1,-0.45 1,-1C18,2.45 17.55,2 17,2L17,2z" + android:fillColor="#75FB4C"/> +</vector> diff --git a/app/src/main/res/drawable/ic_edit_btn.xml b/app/src/main/res/drawable/ic_edit_btn.xml new file mode 100644 index 0000000..c1684b6 --- /dev/null +++ b/app/src/main/res/drawable/ic_edit_btn.xml @@ -0,0 +1,19 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="48" + android:viewportHeight="48"> + <path + android:pathData="M7,42H43" + android:strokeLineJoin="round" + android:strokeWidth="4" + android:fillColor="#00000000" + android:strokeColor="#3D8BFF" + android:strokeLineCap="round"/> + <path + android:pathData="M11,26.72V34H18.317L39,13.308L31.695,6L11,26.72Z" + android:strokeLineJoin="round" + android:strokeWidth="4" + android:fillColor="#00000000" + android:strokeColor="#3D8BFF"/> +</vector> diff --git a/app/src/main/res/drawable/ic_intake.xml b/app/src/main/res/drawable/ic_intake.xml new file mode 100644 index 0000000..c439e56 --- /dev/null +++ b/app/src/main/res/drawable/ic_intake.xml @@ -0,0 +1,20 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="48" + android:viewportHeight="48"> + <path + android:pathData="M9,29C11.761,29 14,26.761 14,24C14,26.761 16.239,29 19,29C21.761,29 24,26.761 24,24C24,26.761 26.239,29 29,29C31.761,29 34,26.761 34,24C34,26.761 36.239,29 39,29C41.761,29 44,26.761 44,24C44,35.046 35.046,44 24,44C12.954,44 4,35.046 4,24C4,26.761 6.239,29 9,29Z" + android:strokeLineJoin="round" + android:strokeWidth="4" + android:fillColor="#00000000" + android:strokeColor="#3D8BFF" + android:strokeLineCap="round"/> + <path + android:pathData="M28,13C28,15.209 26.209,17 24,17C21.791,17 20,15.209 20,13C20,10.791 24,4 24,4C24,4 28,10.791 28,13Z" + android:strokeLineJoin="round" + android:strokeWidth="4" + android:fillColor="#00000000" + android:strokeColor="#3D8BFF" + android:strokeLineCap="round"/> +</vector> diff --git a/app/src/main/res/layout/activity_intake_detail.xml b/app/src/main/res/layout/activity_intake_detail.xml new file mode 100644 index 0000000..cf66891 --- /dev/null +++ b/app/src/main/res/layout/activity_intake_detail.xml @@ -0,0 +1,183 @@ +<?xml version="1.0" encoding="utf-8"?> + +<layout xmlns:android="http://schemas.android.com/apk/res/android"> + + <data> + + <variable + name="itemclidk" + type="com.dayu.pipirrapp.activity.IssueDetailActivity" /> + + <variable + name="data" + type="com.dayu.pipirrapp.bean.net.MarkerResult" /> + + + </data> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical"> + + <include + android:id="@+id/title" + layout="@layout/top_title" /> + + + <ScrollView + android:id="@+id/ScrollView" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_above="@+id/delete_button" + android:layout_below="@+id/title" + android:layout_marginTop="5dp" + android:layout_marginBottom="5dp"> + + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:orientation="vertical" + android:padding="20dp"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:minHeight="30dp" + android:orientation="horizontal"> + + <ImageView + android:id="@+id/ic_project" + android:layout_width="20dp" + android:layout_height="20dp" + android:layout_centerVertical="true" + android:layout_marginLeft="3dp" + android:layout_marginRight="10dp" + android:src="@drawable/ic_intake" /> + + <TextView + android:id="@+id/projectName" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_centerVertical="true" + android:layout_marginEnd="15dp" + android:ellipsize="end" + android:maxLines="1" + android:text="@{data.name}" + android:textColor="@color/title_color" + android:textSize="@dimen/order_detail_text_size" /> + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="5dp" + android:gravity="center_vertical" + android:orientation="horizontal"> + + <LinearLayout + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center_vertical" + android:orientation="horizontal" + android:paddingRight="5dp"> + + <TextView + + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鎵�灞炵墖鍖猴細" + android:textColor="@color/manage_item_text" + android:textSize="@dimen/order_detail_text_size" /> + + <TextView + android:id="@+id/xiangMuJianCheng" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:ellipsize="end" + android:maxLines="1" + android:text="@{data.blockName}" + android:textColor="@color/manage_item_text" + android:textSize="@dimen/order_detail_text_size" /> + </LinearLayout> + + + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="10dp" + android:gravity="center_vertical" + android:orientation="horizontal"> + + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="缁忓害锛�" + android:textColor="@color/manage_item_text" + android:textSize="@dimen/order_detail_text_size" /> + + <TextView + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:ellipsize="end" + android:maxLines="1" + android:text="@{data.lng}" + android:textColor="@color/manage_item_text" + android:textSize="@dimen/order_detail_text_size" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="绾害锛�" + android:textColor="@color/manage_item_text" + android:textSize="@dimen/order_detail_text_size" /> + + <TextView + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:ellipsize="end" + android:maxLines="1" + android:text="@{data.lat}" + android:textColor="@color/manage_item_text" + android:textSize="@dimen/order_detail_text_size" /> + + <ImageView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="5dp" + android:src="@drawable/ic_edit_btn" /> + </LinearLayout> + + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_marginTop="10dp" + android:orientation="vertical"> + + <TextView + + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="涓婃姤鍥剧墖锛�" + android:textColor="@color/manage_item_text" + android:textSize="@dimen/order_detail_text_size" /> + + + </LinearLayout> + + + </LinearLayout> + </ScrollView> + + + </RelativeLayout> + +</layout> diff --git a/app/src/main/res/layout/fragment_map.xml b/app/src/main/res/layout/fragment_map.xml index 9d6a57e..c2f0355 100644 --- a/app/src/main/res/layout/fragment_map.xml +++ b/app/src/main/res/layout/fragment_map.xml @@ -8,17 +8,32 @@ <!-- android:layout_width="match_parent"--> <!-- android:layout_height="match_parent" />--> - - <WebView - android:id="@+id/webView" + <RelativeLayout android:layout_width="match_parent" - android:layout_height="match_parent" /> + android:layout_height="match_parent" + android:layout_above="@+id/bottomLL"> + + + <WebView + android:id="@+id/webView" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + + <ImageView + android:layout_width="26dp" + android:layout_height="52dp" + android:layout_centerHorizontal="true" + android:layout_centerVertical="true" + android:paddingBottom="26dp" + android:src="@drawable/ic_center_pin" /> + </RelativeLayout> <RelativeLayout android:id="@+id/inspectRL" android:layout_width="match_parent" android:layout_height="35dp" - android:background="@color/base_blue"> + android:background="@color/base_blue" + android:visibility="visible"> <TextView android:id="@+id/inspectPause" @@ -66,7 +81,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" - android:layout_marginTop="60dp" + android:layout_marginTop="80dp" android:layout_marginRight="15dp" android:background="@drawable/ic_blue_background" android:padding="10dp" @@ -80,7 +95,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" - android:layout_marginTop="120dp" + android:layout_marginTop="140dp" android:layout_marginRight="15dp" android:background="@drawable/ic_green_bg" android:padding="10dp" @@ -88,6 +103,14 @@ android:textColor="@color/white" android:textSize="18sp" /> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="35dp" + android:layout_above="@+id/bottomLL" + android:background="@color/white"> + + </RelativeLayout> <LinearLayout android:id="@+id/bottomLL" @@ -98,91 +121,155 @@ android:orientation="horizontal" android:visibility="gone"> - <LinearLayout - android:layout_width="0dp" + <ScrollView + android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_weight="1" - android:gravity="center" - android:orientation="vertical" android:padding="10dp"> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:gravity="start" - android:orientation="horizontal"> - - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="鍚嶇О锛�" - android:textColor="@color/black" /> - - <TextView - android:id="@+id/markerName" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:ellipsize="end" - android:maxLines="1" - android:text="" - android:textColor="@color/black" /> - </LinearLayout> <LinearLayout android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="5dp" - android:gravity="start" - android:orientation="horizontal"> + android:layout_height="match_parent" + android:layout_weight="1" + android:gravity="center" + android:orientation="vertical"> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="鐗囧尯锛�" - android:textColor="@color/black" /> - - <TextView - android:id="@+id/markerBlockName" + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:ellipsize="end" - android:maxLines="1" - android:text="" - android:textColor="@color/black" /> - </LinearLayout> + android:gravity="center_vertical" + android:orientation="horizontal"> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="5dp" - android:gravity="start" - android:orientation="horizontal"> + <ImageView + android:id="@+id/ic_project" + android:layout_width="25dp" + android:layout_height="25dp" + android:layout_centerVertical="true" + android:layout_marginRight="10dp" + android:src="@drawable/ic_intake" /> - <TextView - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:text="鍦板潃锛�" - android:textColor="@color/black" /> + <TextView + android:id="@+id/markerName" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:ellipsize="end" + android:maxLines="1" + android:text="" + android:textColor="@color/black" + android:textSize="@dimen/common_text_size_little" /> + </LinearLayout> - <TextView - android:id="@+id/markerAddress" + <LinearLayout + android:layout_width="match_parent" + android:layout_height="25dp" + android:gravity="center_vertical" + android:orientation="horizontal"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鐗囧尯锛�" + android:textColor="@color/black" + android:textSize="@dimen/common_text_size_little" /> + + <TextView + android:id="@+id/markerBlockName" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:ellipsize="end" + android:maxLines="1" + android:text="" + android:textColor="@color/black" + android:textSize="@dimen/common_text_size_little" /> + </LinearLayout> + + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:ellipsize="end" - android:maxLines="1" - android:text="" - android:textColor="@color/black" /> + android:gravity="center_vertical" + android:orientation="horizontal"> + + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="缁忓害锛�" + android:textColor="@color/manage_item_text" + android:textSize="@dimen/common_text_size_little" /> + + <TextView + android:id="@+id/lng" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:ellipsize="end" + android:maxLines="1" + android:textColor="@color/manage_item_text" + android:textSize="@dimen/common_text_size_little" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="绾害锛�" + android:textColor="@color/manage_item_text" + android:textSize="@dimen/common_text_size_little" /> + + <TextView + android:id="@+id/lat" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:ellipsize="end" + android:maxLines="1" + android:textColor="@color/manage_item_text" + android:textSize="@dimen/common_text_size_little" /> + + <ImageView + android:id="@+id/editePoint" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="5dp" + android:src="@drawable/ic_edit_btn" /> + </LinearLayout> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="10dp" + android:gravity="start" + android:orientation="horizontal"> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="鍦板潃锛�" + android:textColor="@color/black" + android:textSize="@dimen/common_text_size_little" /> + + <TextView + android:id="@+id/markerAddress" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:ellipsize="end" + android:maxLines="1" + android:text="" + android:textColor="@color/black" + android:textSize="@dimen/common_text_size_little" /> + </LinearLayout> + </LinearLayout> - </LinearLayout> + </ScrollView> <ImageView android:layout_width="25dp" android:layout_height="30dp" android:layout_gravity="center" android:layout_marginRight="10dp" - android:background="@drawable/ic_right_blue" /> + android:background="@drawable/ic_right_blue" + android:visibility="gone" /> </LinearLayout> + </RelativeLayout> \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 9994b8b..60018fe 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -25,4 +25,6 @@ <dimen name="order_detail_button_size">17sp</dimen> <dimen name="order_detail_button_height">50dp</dimen> + + <dimen name="common_text_size_little">14sp</dimen> </resources> \ No newline at end of file -- Gitblit v1.8.0