1.在地图中心显示中心点。
2.优化地图覆盖物显示,使显示的图标正对坐标。
3.优化地图覆盖物文字居中显示。
| | |
| | | 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 () { |
| | |
| | | } |
| | | } |
| | | |
| | | // 模拟添加取水口标注 |
| | | 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) { |
| | |
| | | } |
| | | |
| | | |
| | | // 将方法挂载到 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; |
| | | |
| | | } |
| | | |
| | | // 调用原生安卓方法显示取水口详情 |
| | | function showWaterIntakeDetail(data) { |
| | |
| | | // 上次点击的标注改为黑色 |
| | | 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); |
| | | } |
| | |
| | | } |
| | | |
| | | // 点击标注的事件 |
| | | function addMarkerListener(id,data) { |
| | | function addMarkerListener(id, data) { |
| | | chageMarkerIcon(data); |
| | | showWaterIntakeDetail(id); |
| | | } |
| | |
| | | // 点击后图标 |
| | | 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); |
| | |
| | | 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); |
| | | } |
| | |
| | | return data1.lat === data2.lat && data1.lng === data2.lng; |
| | | } |
| | | //添加从原生传过来的坐标并显示在地图上 |
| | | function addMarker(id,lng,lat,name) { |
| | | function addMarker(id, lng, lat, name) { |
| | | console.log("function》》》》》addMarker"); |
| | | |
| | | |
| | | 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加载成功" |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | //在地图上显示中心点 |
| | | 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); // 将标注添加到地图中 |
| | | } |
| | | |
| | | })(); |
New file |
| | |
| | | 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; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.dayu.pipirrapp.bean.net; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * author; zuo |
| | | * Date; 2024-09-20 |
| | | * Time; 14;12 |
| | | * 备注: |
| | | * MarkerResult -取水口详情 |
| | | * |
| | | * @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;//取水口名称 |
| | | |
| | | 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;//取水口名称 |
| | | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | LatLonBean lastLatLonBean; |
| | | InspectionRequest inspectionRequest; |
| | | // volatile boolean isHaseAginData = false; |
| | | //web是否加载完成 |
| | | volatile boolean webViewIsFinished = false; |
| | | List<InspectionLocationBean> aginShowlocationBeans; |
| | | //web加载时网页还没加载完时的数据 |
| | |
| | | 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); |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | |
| | | * 获取取水口列表 |
| | | */ |
| | | 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()); |
| | |
| | | |
| | | 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)) { |
| | |
| | | Intent issue = new Intent(MapFragment.this.getActivity(), AddIssueActivity.class); |
| | | MapFragment.this.getActivity().startActivity(issue); |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 显示取水口详情 |
| | | * |
| | | * @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 -> { |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | } |
| | |
| | | * 获取地图中心点 |
| | | */ |
| | | 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) { |
New file |
| | |
| | | <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> |
New file |
| | |
| | | <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> |
New file |
| | |
| | | <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> |
New file |
| | |
| | | <?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> |
| | |
| | | <!-- 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" |
| | |
| | | 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" |
| | |
| | | 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" |
| | |
| | | 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" |
| | |
| | | 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> |
| | |
| | | |
| | | <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> |