提交 33c32c64 authored 作者: 张航's avatar 张航

开始添加页面,提升用户体验

上级 3503c78b
...@@ -123,7 +123,8 @@ public class DownMap implements ApplicationRunner { ...@@ -123,7 +123,8 @@ public class DownMap implements ApplicationRunner {
System.out.println("Falid count num: " + errResults.size()); System.out.println("Falid count num: " + errResults.size());
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
// 执行退出 // 打印结果,执行退出
System.out.println("Total Size: "+ CLStringUtil.getDownTotalSizeUnitsM() +"("+CLStringUtil.getDownTotalSizeUnitsB()+")");
System.out.println("All Task Finished!! \nTotal Time:" + (end - start) / 1000 + " s"); System.out.println("All Task Finished!! \nTotal Time:" + (end - start) / 1000 + " s");
System.exit(0); System.exit(0);
} }
......
package com.comleader.ldmapdownload.util; package com.comleader.ldmapdownload.util;
import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.FileUtil;
import org.omg.CORBA.PUBLIC_MEMBER; import cn.hutool.core.math.MathUtil;
import com.fasterxml.jackson.datatype.jsr310.DecimalUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.io.File; import java.io.File;
import java.text.DecimalFormat;
/** /**
* @ClassName LDStringUtil * @ClassName LDStringUtil
...@@ -131,4 +133,36 @@ public class CLStringUtil { ...@@ -131,4 +133,36 @@ public class CLStringUtil {
return str; return str;
} }
/**
* @description: 下载文件的M级大小
* @param
* @return: java.lang.String
* @author: zhanghang
* @date: 2020/4/9
**/
public static String getDownTotalSizeUnitsM(){
File file = FileUtil.file(BASE_PATH);
if (file != null){
long size = FileUtil.size(file);
return new DecimalFormat("#.00").format(size/1024.0/1024.0) + " M";
}
return null;
}
/**
* @description: 下载文件的字节大小
* @param
* @return: java.lang.String
* @author: zhanghang
* @date: 2020/4/9
**/
public static String getDownTotalSizeUnitsB(){
File file = FileUtil.file(BASE_PATH);
if (file != null){
long size = FileUtil.size(file);
return new DecimalFormat("#,###").format(size) + " 字节";
}
return null;
}
} }
...@@ -27,7 +27,7 @@ map.threadNum=2000 ...@@ -27,7 +27,7 @@ map.threadNum=2000
# 是否下载前6级(不能与其余的同时进行) # 是否下载前6级(不能与其余的同时进行)
map.Lv6.flag=false map.Lv6.flag=false
# 是否继续下载 # 是否覆盖已有
map.download.append=false map.download.append=false
# 这个注释用来备注下下载地图的经纬度(注意: 不要写错了), # 这个注释用来备注下下载地图的经纬度(注意: 不要写错了),
......
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>下属行政区查询</title>
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css"/>
<style type="text/css">
html,body,#container{
height:100%;
}
</style>
</head>
<body>
<div id="container"></div>
<div class="input-card">
<h4>下属行政区查询</h4>
<div class="input-item">
<div class="input-item-prepend"><span class="input-item-text" >省市区</span></div>
<select id='province' style="width:100px" onchange='search(this)'></select>
</div>
<div class="input-item">
<div class="input-item-prepend"><span class="input-item-text" >地级市</span></div>
<select id='city' style="width:100px" onchange='search(this)'></select>
</div>
<div class="input-item">
<div class="input-item-prepend"><span class="input-item-text" >区县</span></div>
<select id='district' style="width:100px" onchange='search(this)'></select>
</div>
<div class="input-item">
<div class="input-item-prepend"><span class="input-item-text" >街道</span></div>
<select id='street' style="width:100px" onchange='setCenter(this)'></select>
</div>
</div>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=a335cc8ac3803361df25094aadc62a53&plugin=AMap.DistrictSearch"></script>
<script type="text/javascript">
var map, district, polygons = [], citycode;
var citySelect = document.getElementById('city');
var districtSelect = document.getElementById('district');
var areaSelect = document.getElementById('street');
map = new AMap.Map('container', {
resizeEnable: true,
center: [116.30946, 39.937629],
zoom: 3
});
//行政区划查询
var opts = {
subdistrict: 1, //返回下一级行政区
showbiz:false //最后一级返回街道信息
};
district = new AMap.DistrictSearch(opts);//注意:需要使用插件同步下发功能才能这样直接使用
district.search('中国', function(status, result) {
if(status=='complete'){
getData(result.districtList[0]);
}
});
function getData(data,level) {
// 记录边界的最大和最小坐标
var minLng = "";
var maxLng = "";
var minLat = "";
var maxLat = "";
var bounds = data.boundaries;
console.log(data.name);
if (bounds) {
for (var i = 0, l = bounds.length; i < l; i++) {
var polygon = new AMap.Polygon({
map: map,
strokeWeight: 1,
strokeColor: '#0091ea',
fillColor: '#80d8ff',
fillOpacity: 0.2,
path: bounds[i]
});
polygons.push(polygon);
// 获取出最大最小的经纬集合
for(var item in bounds[i]){
if (minLng && minLng != '') {
if (bounds[i][item].lng < minLng){
minLng = bounds[i][item].lng;
}
}else {
minLng = bounds[i][item].lng;
}
if (maxLng && maxLng != '') {
if (bounds[i][item].lng > maxLng){
maxLng = bounds[i][item].lng;
}
}else {
maxLng = bounds[i][item].lng;
}
if (minLat && minLat != '') {
if (bounds[i][item].lat < minLat){
minLat = bounds[i][item].lat;
}
}else {
minLat = bounds[i][item].lat;
}
if (maxLat && maxLat != '') {
if (bounds[i][item].lat > maxLat){
maxLat = bounds[i][item].lat;
}
}else {
maxLat = bounds[i][item].lat;
}
}
}
// todo 获取行政区域边框完成
console.log(minLng+","+minLat+";"+maxLng+","+maxLat)
map.setFitView();//地图自适应
}
//清空下一级别的下拉列表
if (level === 'province') {
citySelect.innerHTML = '';
districtSelect.innerHTML = '';
areaSelect.innerHTML = '';
} else if (level === 'city') {
districtSelect.innerHTML = '';
areaSelect.innerHTML = '';
} else if (level === 'district') {
areaSelect.innerHTML = '';
}
var subList = data.districtList;
if (subList) {
var contentSub = new Option('--请选择--');
var curlevel = subList[0].level;
var curList = document.querySelector('#' + curlevel);
curList.add(contentSub);
for (var i = 0, l = subList.length; i < l; i++) {
var name = subList[i].name;
var levelSub = subList[i].level;
var cityCode = subList[i].citycode;
contentSub = new Option(name);
contentSub.setAttribute("value", levelSub);
contentSub.center = subList[i].center;
contentSub.adcode = subList[i].adcode;
curList.add(contentSub);
}
}
}
function search(obj) {
//清除地图上所有覆盖物
for (var i = 0, l = polygons.length; i < l; i++) {
polygons[i].setMap(null);
}
var option = obj[obj.options.selectedIndex];
var keyword = option.text; //关键字
var adcode = option.adcode;
district.setLevel(option.value); //行政区级别
district.setExtensions('all');
//行政区查询
//按照adcode进行查询可以保证数据返回的唯一性
district.search(adcode, function(status, result) {
if(status === 'complete'){
getData(result.districtList[0],obj.id);
}
});
}
function setCenter(obj){
map.setCenter(obj[obj.options.selectedIndex].center)
}
</script>
<script type="text/javascript" src="https://webapi.amap.com/demos/js/liteToolbar.js"></script>
</body>
</html>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论