开发区省市区改为下拉框
This commit is contained in:
+4
-4
@@ -125,7 +125,7 @@ public class DevelopmentZoneController {
|
||||
entity.setNameEn(StringUtils.isBlank(model.getNameEn()) ? "" : model.getNameEn());
|
||||
entity.setType(StringUtils.isBlank(model.getType()) ? "" : model.getType());
|
||||
entity.setUrl(StringUtils.isBlank(model.getUrl()) ? "" : model.getUrl());
|
||||
entity.setCityName(StringUtils.isBlank(model.getCityName()) ? "" : model.getCityName());
|
||||
entity.setCityName1(StringUtils.isBlank(model.getCityName1()) ? "" : model.getCityName1());
|
||||
entity.setDistrict(StringUtils.isBlank(model.getDistrict()) ? "" : model.getDistrict());
|
||||
//记录操作人员
|
||||
entity.setOperator(user.getRealName());
|
||||
@@ -198,8 +198,8 @@ public class DevelopmentZoneController {
|
||||
if (StringUtils.isNotBlank(model.getUrl())) {
|
||||
udata.put("url", model.getUrl());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getCityName())) {
|
||||
udata.put("cityName", model.getCityName());
|
||||
if (StringUtils.isNotBlank(model.getCityName1())) {
|
||||
udata.put("city", model.getCityName1());
|
||||
}
|
||||
if (StringUtils.isNotBlank(model.getDistrict())){
|
||||
udata.put("district", model.getDistrict());
|
||||
@@ -230,7 +230,7 @@ public class DevelopmentZoneController {
|
||||
|
||||
public JsonModel districtsAction(DevelopmentZoneModel model) {
|
||||
JsonModel jsonModel = new JsonModel();
|
||||
List<String> districts = developmentZoneService.findDistricts(model.getCityName());
|
||||
List<String> districts = developmentZoneService.findDistricts(model.getCityName1());
|
||||
jsonModel.setJsonModel(districts);
|
||||
return jsonModel;
|
||||
}
|
||||
|
||||
+10
@@ -33,6 +33,8 @@ public class DevelopmentZoneModel extends BaseModel {
|
||||
private DevelopmentZone developmentZone;
|
||||
private List<DevelopmentZone> developmentZoneList;
|
||||
|
||||
private String cityName1;
|
||||
|
||||
public String getAlias() {
|
||||
return alias;
|
||||
}
|
||||
@@ -184,4 +186,12 @@ public class DevelopmentZoneModel extends BaseModel {
|
||||
public void setDevelopmentZoneList(List<DevelopmentZone> developmentZoneList) {
|
||||
this.developmentZoneList = developmentZoneList;
|
||||
}
|
||||
|
||||
public String getCityName1() {
|
||||
return cityName1;
|
||||
}
|
||||
|
||||
public void setCityName1(String cityName1) {
|
||||
this.cityName1 = cityName1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,334 +1,320 @@
|
||||
<#ftl attributes={"content_type":"text/html; charset=UTF-8"}>
|
||||
<#compress>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<title>开发区围栏列表</title>
|
||||
<link rel="stylesheet" type="text/css" href="../style/main.css?v=${version}"/>
|
||||
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<#include "/common_js.ftl" />
|
||||
<#include "/layout/header.ftl" />
|
||||
<div class="main-content">
|
||||
<div class="menuButton">
|
||||
<a href="../developmentZone/list" class="list">开发区列表</a>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<form id="form1">
|
||||
<#if developmentZone??>
|
||||
<input id="id" name="id" type="hidden" value="${developmentZone.id!}"/>
|
||||
</#if>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<@d_city defaultValue="" callback="changeCity" callbackField="display" name="cityDisplay" />
|
||||
</td>
|
||||
<td>
|
||||
<label for="province">所在省份:</label>
|
||||
<select id="province" name="province" onchange="updateCityAndDistrict()">
|
||||
<#if province??>
|
||||
<option value="${province}">${province}</option>
|
||||
<#else>
|
||||
<option value="">请选择省份</option>
|
||||
</#if>
|
||||
</select>
|
||||
|
||||
<label for="cityName">城市:</label>
|
||||
<select id="cityName" name="cityName" onchange="updateDistrict()">
|
||||
<!-- Options for cities will be populated by JavaScript -->
|
||||
</select>
|
||||
<label for="district">区域:</label>
|
||||
<select id="district" name="district">
|
||||
<!-- Options for districts will be populated by JavaScript -->
|
||||
</select>
|
||||
<label for="name">开发区名称:</label> <input id="name" name="name" type="text"
|
||||
placeholder="必填"
|
||||
value="<#if developmentZone??>${developmentZone.name!}</#if>"/>
|
||||
<label for="alias">别名:</label>
|
||||
<input id="alias" name="alias" type="text" placeholder="多个别名用,隔开"
|
||||
value="<#if developmentZone??><#list (developmentZone.alias)! as alia>${alia + ','}</#list><#else></#if>"/>
|
||||
<label for="nameEn">开发区名称拼音:</label> <input id="nameEn" name="nameEn" type="text"
|
||||
value="<#if developmentZone??>${developmentZone.nameEn!}</#if>"/>
|
||||
</br>
|
||||
<label for="level">级别:</label> <input id="level" name="level" type="text"
|
||||
placeholder="必填"
|
||||
value="<#if developmentZone??>${developmentZone.level!}</#if>"/>
|
||||
<label for="address">地址:</label> <input id="address" name="address" type="text"
|
||||
value="<#if developmentZone??>${developmentZone.address!}</#if>"/><br>
|
||||
<label for="area">所在地区:</label> <input id="area" name="area" type="text"
|
||||
value="<#if developmentZone??>${developmentZone.area!}</#if>"/>
|
||||
<label for="buildDate">建立年代:</label><input id="buildDate" name="buildDate" type="text"
|
||||
value="<#if developmentZone??>${developmentZone.buildDate!}</#if>"/>
|
||||
<label for="type">类型:</label><input id="type" name="type" type="text"
|
||||
value="<#if developmentZone??>${developmentZone.type!}</#if>"/>
|
||||
<label for="url">URL:</label><input id="url" name="url" type="text"
|
||||
value="<#if developmentZone??>${developmentZone.url!}</#if>"/><br>
|
||||
<label for="industry">主导产业:</label><input id="industry" name="industry" type="text"
|
||||
value="<#if developmentZone??>${developmentZone.industry!}</#if>"/>
|
||||
<label for="block">区块:</label><input id="block" name="block" type="text"
|
||||
value="<#if developmentZone??>${developmentZone.block!}</#if>"/><br/>
|
||||
<input id="saveOrUpdate" type="button" value="提交"/>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input name="bdShape" id="bdShape" type="hidden"/>
|
||||
<div id="allmap" style="width:100%;height:900px;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>开发区围栏列表</title>
|
||||
<link rel="stylesheet" type="text/css" href="../style/main.css?v=${version}" />
|
||||
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<#include "/common_js.ftl" />
|
||||
<#include "/layout/header.ftl" />
|
||||
<div class="main-content">
|
||||
<div class="menuButton">
|
||||
<a href="../developmentZone/list" class="list">开发区列表</a>
|
||||
</div>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
fetchProvinces();
|
||||
|
||||
$('#province').change(function () {
|
||||
updateCityAndDistrict();
|
||||
});
|
||||
<div>
|
||||
<form id="form1">
|
||||
<#if developmentZone??>
|
||||
<input id="id" name="id" type="hidden" value="${developmentZone.id!}"/>
|
||||
</#if>
|
||||
|
||||
$('#cityName').change(function () {
|
||||
updateDistrict();
|
||||
});
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<#if developmentZone??>
|
||||
<@d_city defaultValue="${developmentZone.cityName1!}" callback="changeCity" callbackField="display" name="cityDisplay" />
|
||||
<#else>
|
||||
<@d_city defaultValue="上海" callback="changeCity" callbackField="display" name="cityDisplay" />
|
||||
</#if>
|
||||
</td>
|
||||
<td>
|
||||
<label for="province">所在省份:</label>
|
||||
<select id="province" name="province" onchange="updateCityAndDistrict()">
|
||||
<#if province??>
|
||||
<option value="${province}">${province}</option>
|
||||
<#else>
|
||||
<option value="">请选择省份</option>
|
||||
</#if>
|
||||
</select>
|
||||
|
||||
<label for="cityName1">城市:</label>
|
||||
<select id="cityName1" name="cityName1" onchange="updateDistrict()">
|
||||
<!-- Options for cities will be populated by JavaScript -->
|
||||
</select>
|
||||
<label for="district">区域:</label>
|
||||
<select id="district" name="district">
|
||||
<!-- Options for districts will be populated by JavaScript -->
|
||||
</select>
|
||||
<label for="name">开发区名称:</label> <input id="name" name="name" type="text" placeholder="必填" value="<#if developmentZone??>${developmentZone.name!}</#if>"/>
|
||||
<label for="alias">别名:</label>
|
||||
<input id="alias" name="alias" type="text" placeholder="多个别名用,隔开" value="<#if developmentZone??><#list (developmentZone.alias)! as alia>${alia + ','}</#list><#else></#if>"/>
|
||||
<label for="nameEn">开发区名称拼音:</label> <input id="nameEn" name="nameEn" type="text" value="<#if developmentZone??>${developmentZone.nameEn!}</#if>"/>
|
||||
</br>
|
||||
<label for="level">级别:</label> <input id="level" name="level" type="text" placeholder="必填" value="<#if developmentZone??>${developmentZone.level!}</#if>"/>
|
||||
<label for="address">地址:</label> <input id="address" name="address" type="text" value="<#if developmentZone??>${developmentZone.address!}</#if>"/><br>
|
||||
<label for="area">所在地区:</label> <input id="area" name="area" type="text" value="<#if developmentZone??>${developmentZone.area!}</#if>"/>
|
||||
<label for="buildDate">建立年代:</label><input id="buildDate" name="buildDate" type="text" value="<#if developmentZone??>${developmentZone.buildDate!}</#if>"/>
|
||||
<label for="type">类型:</label><input id="type" name="type" type="text" value="<#if developmentZone??>${developmentZone.type!}</#if>"/>
|
||||
<label for="url">URL:</label><input id="url" name="url" type="text" value="<#if developmentZone??>${developmentZone.url!}</#if>"/><br>
|
||||
<label for="industry">主导产业:</label><input id="industry" name="industry" type="text" value="<#if developmentZone??>${developmentZone.industry!}</#if>"/>
|
||||
<label for="block">区块:</label><input id="block" name="block" type="text" value="<#if developmentZone??>${developmentZone.block!}</#if>"/><br/>
|
||||
<input id="saveOrUpdate" type="button" value="提交"/>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input name="bdShape" id="bdShape" type="hidden"/>
|
||||
<div id="allmap" style="width:100%;height:900px;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
fetchProvinces();
|
||||
|
||||
$('#province').change(function() {
|
||||
updateCityAndDistrict();
|
||||
});
|
||||
|
||||
function fetchProvinces() {
|
||||
$('#cityName1').change(function() {
|
||||
updateDistrict();
|
||||
});
|
||||
});
|
||||
|
||||
function fetchProvinces() {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../developmentZone/provinces',
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
let provinceSelect = $('#province');
|
||||
provinceSelect.empty();
|
||||
provinceSelect.append('<option value="">请选择省份</option>');
|
||||
$.each(data, function(index, province) {
|
||||
provinceSelect.append('<option value="' + province + '">' + province + '</option>');
|
||||
});
|
||||
},
|
||||
error: function() {
|
||||
// 处理错误
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updateCityAndDistrict() {
|
||||
let province = $('#province').val();
|
||||
let citySelect = $('#cityName1');
|
||||
let districtSelect = $('#district');
|
||||
|
||||
citySelect.empty();
|
||||
districtSelect.empty();
|
||||
citySelect.append('<option value="">请选择城市</option>');
|
||||
districtSelect.append('<option value="">请选择区域</option>');
|
||||
|
||||
if (province) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../developmentZone/provinces',
|
||||
url: '../developmentZone/cities',
|
||||
data: { province: province },
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
let provinceSelect = $('#province');
|
||||
provinceSelect.empty();
|
||||
provinceSelect.append('<option value="">请选择省份</option>');
|
||||
$.each(data, function (index, province) {
|
||||
provinceSelect.append('<option value="' + province + '">' + province + '</option>');
|
||||
success: function(data) {
|
||||
$.each(data, function(index, city) {
|
||||
citySelect.append('<option value="' + city + '">' + city + '</option>');
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
error: function() {
|
||||
// 处理错误
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function updateCityAndDistrict() {
|
||||
let province = $('#province').val();
|
||||
let citySelect = $('#cityName');
|
||||
let districtSelect = $('#district');
|
||||
function updateDistrict() {
|
||||
let cityName1 = $('#cityName1').val();
|
||||
let districtSelect = $('#district');
|
||||
|
||||
citySelect.empty();
|
||||
districtSelect.empty();
|
||||
citySelect.append('<option value="">请选择城市</option>');
|
||||
districtSelect.append('<option value="">请选择区域</option>');
|
||||
districtSelect.empty();
|
||||
districtSelect.append('<option value="">请选择区域</option>');
|
||||
|
||||
if (province) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../developmentZone/cities',
|
||||
data: {province: province},
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
$.each(data, function (index, city) {
|
||||
citySelect.append('<option value="' + city + '">' + city + '</option>');
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
// 处理错误
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function updateDistrict() {
|
||||
let cityName = $('#cityName').val();
|
||||
let districtSelect = $('#district');
|
||||
|
||||
districtSelect.empty();
|
||||
districtSelect.append('<option value="">请选择区域</option>');
|
||||
|
||||
if (cityName) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../developmentZone/districts',
|
||||
data: {cityName: cityName},
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
$.each(data, function (index, district) {
|
||||
districtSelect.append('<option value="' + district + '">' + district + '</option>');
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
// 处理错误
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<script type="text/javascript"
|
||||
src="https://api.map.baidu.com/api?v=2.0&ak=3E63A744012f88c9a73a2f051aece58b"></script>
|
||||
<!--加载鼠标绘制工具-->
|
||||
<script type="text/javascript"
|
||||
src="https://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js"></script>
|
||||
<link rel="stylesheet" href="https://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css"/>
|
||||
<!--加载检索信息窗口-->
|
||||
<script type="text/javascript"
|
||||
src="https://api.map.baidu.com/library/SearchInfoWindow/1.4/src/SearchInfoWindow_min.js"></script>
|
||||
<link rel="stylesheet" href="https://api.map.baidu.com/library/SearchInfoWindow/1.4/src/SearchInfoWindow_min.css"/>
|
||||
|
||||
<script type="application/javascript">
|
||||
var map = new BMap.Map("allmap"); // 创建Map实例
|
||||
if ($("#cityDisplay").val()) {
|
||||
map.centerAndZoom($("#cityDisplay").val(), 13);
|
||||
} else {
|
||||
map.centerAndZoom('上海', 13);
|
||||
}
|
||||
map.enableScrollWheelZoom(true);
|
||||
|
||||
function changeCity(display) {
|
||||
clearAll();
|
||||
map.centerAndZoom(display, 13);
|
||||
}
|
||||
|
||||
var overlays = [];
|
||||
var overlaycomplete = function (e) {
|
||||
overlays.push(e.overlay);
|
||||
var points = e.overlay.getPath();
|
||||
|
||||
var bdShape = [];
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
var location = [];
|
||||
location.push(points[i].lng);
|
||||
location.push(points[i].lat);
|
||||
bdShape.push(location);
|
||||
}
|
||||
$("#bdShape").val(bdShape.join(";"));
|
||||
// 在创建多边形后立即启用编辑
|
||||
e.overlay.enableEditing();
|
||||
};
|
||||
|
||||
var styleOptions = {
|
||||
strokeColor: "red", //边线颜色。
|
||||
fillColor: "red", //填充颜色。当参数为空时,圆形将没有填充效果。
|
||||
strokeWeight: 1, //边线的宽度,以像素为单位。
|
||||
strokeOpacity: 0.8, //边线透明度,取值范围0 - 1。
|
||||
fillOpacity: 0.6, //填充的透明度,取值范围0 - 1。
|
||||
strokeStyle: 'solid' //边线的样式,solid或dashed。
|
||||
}
|
||||
//实例化鼠标绘制工具
|
||||
var drawingManager = new BMapLib.DrawingManager(map, {
|
||||
isOpen: true, //是否开启绘制模式
|
||||
enableDrawingTool: true, //是否显示工具栏
|
||||
drawingToolOptions: {
|
||||
anchor: BMAP_ANCHOR_TOP_RIGHT, //位置
|
||||
offset: new BMap.Size(5, 5), //偏离值
|
||||
},
|
||||
circleOptions: styleOptions, //圆的样式
|
||||
polylineOptions: styleOptions, //线的样式
|
||||
polygonOptions: styleOptions, //多边形的样式
|
||||
rectangleOptions: styleOptions //矩形的样式
|
||||
});
|
||||
//添加鼠标绘制工具监听事件,用于获取绘制结果
|
||||
drawingManager.addEventListener('overlaycomplete', overlaycomplete);
|
||||
|
||||
function clearAll() {
|
||||
for (var i = 0; i < overlays.length; i++) {
|
||||
map.removeOverlay(overlays[i]);
|
||||
}
|
||||
overlays.length = 0;
|
||||
}
|
||||
|
||||
// 添加点击覆盖物事件监听器
|
||||
map.addEventListener("click", function (e) {
|
||||
// 判断点击的是否是已存在的覆盖物
|
||||
if (e.overlay) {
|
||||
// 如果是多边形或折线,则可以编辑
|
||||
if (e.overlay instanceof BMap.Polygon || e.overlay instanceof BMap.Polyline) {
|
||||
// 开启覆盖物编辑功能
|
||||
e.overlay.enableEditing();
|
||||
}
|
||||
// 如果是标记点,则可以拖动
|
||||
else if (e.overlay instanceof BMap.Marker) {
|
||||
// 开启标记点拖动功能
|
||||
e.overlay.enableDragging();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 添加覆盖物编辑完成事件监听器
|
||||
map.addEventListener("overlaycomplete", function (e) {
|
||||
// 判断新增的覆盖物是否是多边形或折线
|
||||
if (e.overlay instanceof BMap.Polygon || e.overlay instanceof BMap.Polyline) {
|
||||
// 添加覆盖物编辑完成事件监听器
|
||||
e.overlay.addEventListener("lineupdate", function () {
|
||||
// 编辑完成后获取更新后的路径点,并更新表单中的数据
|
||||
var points = e.overlay.getPath();
|
||||
var bdShape = [];
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
var location = [];
|
||||
location.push(points[i].lng);
|
||||
location.push(points[i].lat);
|
||||
bdShape.push(location);
|
||||
}
|
||||
$("#bdShape").val(bdShape.join(";"));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#saveOrUpdate").click(function () {
|
||||
// 更新表单中的点位置数据
|
||||
updatePolygonPoints();
|
||||
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: '../developmentZone/saveOrUpdate',
|
||||
data: $("#form1").serialize(),
|
||||
if (cityName1) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '../developmentZone/districts',
|
||||
data: { cityName1: cityName1 },
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function (data) {
|
||||
alert(data.msg);
|
||||
location.href = "list";
|
||||
success: function(data) {
|
||||
$.each(data, function(index, district) {
|
||||
districtSelect.append('<option value="' + district + '">' + district + '</option>');
|
||||
});
|
||||
},
|
||||
error: function () {
|
||||
error: function() {
|
||||
// 处理错误
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
});
|
||||
|
||||
// 更新表单中的多边形点位置数据
|
||||
function updatePolygonPoints() {
|
||||
var polygons = map.getOverlays(BMap.Polygon);
|
||||
for (var i = 0; i < polygons.length; i++) {
|
||||
// 确保当前对象是一个多边形对象
|
||||
if (polygons[i] instanceof BMap.Polygon) {
|
||||
var points = polygons[i].getPath();
|
||||
var bdShape = [];
|
||||
for (var j = 0; j < points.length; j++) {
|
||||
var location = [];
|
||||
location.push(points[j].lng);
|
||||
location.push(points[j].lat);
|
||||
bdShape.push(location);
|
||||
}
|
||||
// 将更新后的点位置数据更新到表单中
|
||||
$("#bdShape").val(bdShape.join(";"));
|
||||
}
|
||||
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=3E63A744012f88c9a73a2f051aece58b"></script>
|
||||
<!--加载鼠标绘制工具-->
|
||||
<script type="text/javascript" src="https://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.js"></script>
|
||||
<link rel="stylesheet" href="https://api.map.baidu.com/library/DrawingManager/1.4/src/DrawingManager_min.css" />
|
||||
<!--加载检索信息窗口-->
|
||||
<script type="text/javascript" src="https://api.map.baidu.com/library/SearchInfoWindow/1.4/src/SearchInfoWindow_min.js"></script>
|
||||
<link rel="stylesheet" href="https://api.map.baidu.com/library/SearchInfoWindow/1.4/src/SearchInfoWindow_min.css" />
|
||||
|
||||
<script type="application/javascript">
|
||||
var map = new BMap.Map("allmap"); // 创建Map实例
|
||||
if($("#cityDisplay").val()) {
|
||||
map.centerAndZoom($("#cityDisplay").val(), 13);
|
||||
}else {
|
||||
map.centerAndZoom('上海', 13);
|
||||
}
|
||||
map.enableScrollWheelZoom(true);
|
||||
|
||||
function changeCity(display){
|
||||
clearAll();
|
||||
map.centerAndZoom(display, 13);
|
||||
}
|
||||
|
||||
var overlays = [];
|
||||
var overlaycomplete = function(e){
|
||||
overlays.push(e.overlay);
|
||||
var points = e.overlay.getPath();
|
||||
|
||||
var bdShape = [];
|
||||
for(var i=0;i<points.length;i++) {
|
||||
var location = [];
|
||||
location.push(points[i].lng );
|
||||
location.push(points[i].lat );
|
||||
bdShape.push(location);
|
||||
}
|
||||
$("#bdShape").val(bdShape.join(";"));
|
||||
// 在创建多边形后立即启用编辑
|
||||
e.overlay.enableEditing();
|
||||
};
|
||||
|
||||
var styleOptions = {
|
||||
strokeColor:"red", //边线颜色。
|
||||
fillColor:"red", //填充颜色。当参数为空时,圆形将没有填充效果。
|
||||
strokeWeight: 1, //边线的宽度,以像素为单位。
|
||||
strokeOpacity: 0.8, //边线透明度,取值范围0 - 1。
|
||||
fillOpacity: 0.6, //填充的透明度,取值范围0 - 1。
|
||||
strokeStyle: 'solid' //边线的样式,solid或dashed。
|
||||
}
|
||||
//实例化鼠标绘制工具
|
||||
var drawingManager = new BMapLib.DrawingManager(map, {
|
||||
isOpen: true, //是否开启绘制模式
|
||||
enableDrawingTool: true, //是否显示工具栏
|
||||
drawingToolOptions: {
|
||||
anchor: BMAP_ANCHOR_TOP_RIGHT, //位置
|
||||
offset: new BMap.Size(5, 5), //偏离值
|
||||
},
|
||||
circleOptions: styleOptions, //圆的样式
|
||||
polylineOptions: styleOptions, //线的样式
|
||||
polygonOptions: styleOptions, //多边形的样式
|
||||
rectangleOptions: styleOptions //矩形的样式
|
||||
});
|
||||
//添加鼠标绘制工具监听事件,用于获取绘制结果
|
||||
drawingManager.addEventListener('overlaycomplete', overlaycomplete);
|
||||
function clearAll() {
|
||||
for(var i = 0; i < overlays.length; i++){
|
||||
map.removeOverlay(overlays[i]);
|
||||
}
|
||||
overlays.length = 0;
|
||||
}
|
||||
|
||||
// 添加点击覆盖物事件监听器
|
||||
map.addEventListener("click", function(e) {
|
||||
// 判断点击的是否是已存在的覆盖物
|
||||
if (e.overlay) {
|
||||
// 如果是多边形或折线,则可以编辑
|
||||
if (e.overlay instanceof BMap.Polygon || e.overlay instanceof BMap.Polyline) {
|
||||
// 开启覆盖物编辑功能
|
||||
e.overlay.enableEditing();
|
||||
}
|
||||
// 如果是标记点,则可以拖动
|
||||
else if (e.overlay instanceof BMap.Marker) {
|
||||
// 开启标记点拖动功能
|
||||
e.overlay.enableDragging();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 添加覆盖物编辑完成事件监听器
|
||||
map.addEventListener("overlaycomplete", function(e) {
|
||||
// 判断新增的覆盖物是否是多边形或折线
|
||||
if (e.overlay instanceof BMap.Polygon || e.overlay instanceof BMap.Polyline) {
|
||||
// 添加覆盖物编辑完成事件监听器
|
||||
e.overlay.addEventListener("lineupdate", function() {
|
||||
// 编辑完成后获取更新后的路径点,并更新表单中的数据
|
||||
var points = e.overlay.getPath();
|
||||
var bdShape = [];
|
||||
for (var i = 0; i < points.length; i++) {
|
||||
var location = [];
|
||||
location.push(points[i].lng);
|
||||
location.push(points[i].lat);
|
||||
bdShape.push(location);
|
||||
}
|
||||
$("#bdShape").val(bdShape.join(";"));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$("#saveOrUpdate").click(function(){
|
||||
// 更新表单中的点位置数据
|
||||
updatePolygonPoints();
|
||||
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
url: '../developmentZone/saveOrUpdate',
|
||||
data: $("#form1").serialize(),
|
||||
dataType: 'json',
|
||||
timeout: 100000,
|
||||
success: function(data) {
|
||||
alert(data.msg);
|
||||
location.href="list";
|
||||
},
|
||||
error : function() {
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// 更新表单中的多边形点位置数据
|
||||
function updatePolygonPoints() {
|
||||
var polygons = map.getOverlays(BMap.Polygon);
|
||||
for (var i = 0; i < polygons.length; i++) {
|
||||
// 确保当前对象是一个多边形对象
|
||||
if (polygons[i] instanceof BMap.Polygon) {
|
||||
var points = polygons[i].getPath();
|
||||
var bdShape = [];
|
||||
for (var j = 0; j < points.length; j++) {
|
||||
var location = [];
|
||||
location.push(points[j].lng);
|
||||
location.push(points[j].lat);
|
||||
bdShape.push(location);
|
||||
}
|
||||
// 将更新后的点位置数据更新到表单中
|
||||
$("#bdShape").val(bdShape.join(";"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fetchProvinces()
|
||||
fetchProvinces()
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</body>
|
||||
</html>
|
||||
</#compress>
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
|
||||
<td>${it.level!}</td>
|
||||
<td>${it.province!}</td>
|
||||
<td>${it.cityName!}</td>
|
||||
<td>${it.cityName1!}</td>
|
||||
<td>${it.district!}</td>
|
||||
<td>${it.block!}</td>
|
||||
<td>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>城市</td>
|
||||
<td>${developmentZone.cityName!}</td>
|
||||
<td>${developmentZone.cityName1!}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>区域</td>
|
||||
|
||||
@@ -32,7 +32,7 @@ public class DevelopmentZone implements MongoEntity {
|
||||
|
||||
private String block;
|
||||
private String operator;
|
||||
private String cityName;
|
||||
private String cityName1;
|
||||
private String district;
|
||||
|
||||
//增加别名字段
|
||||
@@ -186,15 +186,19 @@ public class DevelopmentZone implements MongoEntity {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
|
||||
@Column(name = "city")
|
||||
public String getCityName() {
|
||||
return cityName;
|
||||
public String getCityName1() {
|
||||
return cityName1;
|
||||
}
|
||||
|
||||
public void setCityName(String cityName) {
|
||||
this.cityName = cityName;
|
||||
public void setCityName1(String cityName1) {
|
||||
this.cityName1 = cityName1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Column(name = "district")
|
||||
public String getDistrict() {
|
||||
return district;
|
||||
|
||||
Reference in New Issue
Block a user