画开发区围栏时支持改点的位置
This commit is contained in:
@@ -9,9 +9,9 @@
|
|||||||
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
|
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<#include "/common_js.ftl" />
|
<#include "/common_js.ftl" />
|
||||||
<#include "/layout/header.ftl" />
|
<#include "/layout/header.ftl" />
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
<div class="menuButton">
|
<div class="menuButton">
|
||||||
<a href="../developmentZone/list" class="list">开发区列表</a>
|
<a href="../developmentZone/list" class="list">开发区列表</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -56,17 +56,17 @@
|
|||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<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/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>
|
<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" />
|
<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>
|
<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" />
|
<link rel="stylesheet" href="https://api.map.baidu.com/library/SearchInfoWindow/1.4/src/SearchInfoWindow_min.css" />
|
||||||
|
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
var map = new BMap.Map("allmap"); // 创建Map实例
|
var map = new BMap.Map("allmap"); // 创建Map实例
|
||||||
if($("#cityDisplay").val()) {
|
if($("#cityDisplay").val()) {
|
||||||
map.centerAndZoom($("#cityDisplay").val(), 13);
|
map.centerAndZoom($("#cityDisplay").val(), 13);
|
||||||
@@ -93,19 +93,21 @@
|
|||||||
bdShape.push(location);
|
bdShape.push(location);
|
||||||
}
|
}
|
||||||
$("#bdShape").val(bdShape.join(";"));
|
$("#bdShape").val(bdShape.join(";"));
|
||||||
|
// 在创建多边形后立即启用编辑
|
||||||
|
e.overlay.enableEditing();
|
||||||
};
|
};
|
||||||
|
|
||||||
var styleOptions = {
|
var styleOptions = {
|
||||||
strokeColor:"red", //边线颜色。
|
strokeColor:"red", //边线颜色。
|
||||||
fillColor:"red", //填充颜色。当参数为空时,圆形将没有填充效果。
|
fillColor:"red", //填充颜色。当参数为空时,圆形将没有填充效果。
|
||||||
strokeWeight: 3, //边线的宽度,以像素为单位。
|
strokeWeight: 1, //边线的宽度,以像素为单位。
|
||||||
strokeOpacity: 0.8, //边线透明度,取值范围0 - 1。
|
strokeOpacity: 0.8, //边线透明度,取值范围0 - 1。
|
||||||
fillOpacity: 0.6, //填充的透明度,取值范围0 - 1。
|
fillOpacity: 0.6, //填充的透明度,取值范围0 - 1。
|
||||||
strokeStyle: 'solid' //边线的样式,solid或dashed。
|
strokeStyle: 'solid' //边线的样式,solid或dashed。
|
||||||
}
|
}
|
||||||
//实例化鼠标绘制工具
|
//实例化鼠标绘制工具
|
||||||
var drawingManager = new BMapLib.DrawingManager(map, {
|
var drawingManager = new BMapLib.DrawingManager(map, {
|
||||||
isOpen: false, //是否开启绘制模式
|
isOpen: true, //是否开启绘制模式
|
||||||
enableDrawingTool: true, //是否显示工具栏
|
enableDrawingTool: true, //是否显示工具栏
|
||||||
drawingToolOptions: {
|
drawingToolOptions: {
|
||||||
anchor: BMAP_ANCHOR_TOP_RIGHT, //位置
|
anchor: BMAP_ANCHOR_TOP_RIGHT, //位置
|
||||||
@@ -125,7 +127,47 @@
|
|||||||
overlays.length = 0;
|
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(){
|
$("#saveOrUpdate").click(function(){
|
||||||
|
// 更新表单中的点位置数据
|
||||||
|
updatePolygonPoints();
|
||||||
|
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: '../developmentZone/saveOrUpdate',
|
url: '../developmentZone/saveOrUpdate',
|
||||||
@@ -140,10 +182,32 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
})
|
});
|
||||||
|
|
||||||
|
// 更新表单中的多边形点位置数据
|
||||||
|
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>
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
<th>开发区级别</th>
|
<th>开发区级别</th>
|
||||||
<th>省份</th>
|
<th>省份</th>
|
||||||
<th>区块</th>
|
<th>区块</th>
|
||||||
|
<th>是否有围栏</th>
|
||||||
<th style="width: 160px">操作人员</th>
|
<th style="width: 160px">操作人员</th>
|
||||||
<th style="width: 120px;">操作</th>
|
<th style="width: 120px;">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -50,8 +51,11 @@
|
|||||||
<td>${it.province!}</td>
|
<td>${it.province!}</td>
|
||||||
<td>${it.block!}</td>
|
<td>${it.block!}</td>
|
||||||
<td>
|
<td>
|
||||||
${it.operator!}
|
<#if it.bdShape?has_content>
|
||||||
|
已有围栏
|
||||||
|
</#if>
|
||||||
</td>
|
</td>
|
||||||
|
<td>${it.operator!}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="show?id=${it.id!}" target="_blank">查看</a>
|
<a href="show?id=${it.id!}" target="_blank">查看</a>
|
||||||
<a href="../developmentZone/edit?id=${it.id!}" target="_blank">新建围栏</a>
|
<a href="../developmentZone/edit?id=${it.id!}" target="_blank">新建围栏</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user