电子围栏
This commit is contained in:
@ -83,6 +83,8 @@ public class ZcElectronicFenceController extends BaseController
|
|||||||
{
|
{
|
||||||
ZcRentCarRule zcRentCarRule = new ZcRentCarRule();
|
ZcRentCarRule zcRentCarRule = new ZcRentCarRule();
|
||||||
zcRentCarRule.setStatus("0");
|
zcRentCarRule.setStatus("0");
|
||||||
|
// 查询未绑定电子围栏套餐
|
||||||
|
zcRentCarRule.setExtend1("0");
|
||||||
List<ZcRentCarRule> rentCarRuleList = zcRentCarRuleService.selectZcRentCarRuleList(zcRentCarRule);
|
List<ZcRentCarRule> rentCarRuleList = zcRentCarRuleService.selectZcRentCarRuleList(zcRentCarRule);
|
||||||
mmap.put("rentCarRuleList", rentCarRuleList);
|
mmap.put("rentCarRuleList", rentCarRuleList);
|
||||||
return prefix + "/add";
|
return prefix + "/add";
|
||||||
|
|||||||
@ -74,7 +74,7 @@ public class ZcRentCarRule extends BaseEntity
|
|||||||
/** 删除标志(0代表存在 2代表删除) */
|
/** 删除标志(0代表存在 2代表删除) */
|
||||||
private String delFlag;
|
private String delFlag;
|
||||||
|
|
||||||
/** 扩展字段1 */
|
/** 绑定电子围栏 */
|
||||||
private String extend1;
|
private String extend1;
|
||||||
|
|
||||||
/** 扩展字段2 */
|
/** 扩展字段2 */
|
||||||
@ -97,6 +97,9 @@ public class ZcRentCarRule extends BaseEntity
|
|||||||
@Transient
|
@Transient
|
||||||
private String operatingCompanyName;
|
private String operatingCompanyName;
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
private String queryFenceRule;
|
||||||
|
|
||||||
public void setId(Long id)
|
public void setId(Long id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@ -304,6 +307,14 @@ public class ZcRentCarRule extends BaseEntity
|
|||||||
this.flag = flag;
|
this.flag = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getQueryFenceRule() {
|
||||||
|
return queryFenceRule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQueryFenceRule(String queryFenceRule) {
|
||||||
|
this.queryFenceRule = queryFenceRule;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.ruoyi.operation.mapper;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.ruoyi.operation.domain.ZcRentCarRule;
|
import com.ruoyi.operation.domain.ZcRentCarRule;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 租车计费规则Mapper接口
|
* 租车计费规则Mapper接口
|
||||||
@ -59,4 +60,17 @@ public interface ZcRentCarRuleMapper
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteZcRentCarRuleByIds(String[] ids);
|
public int deleteZcRentCarRuleByIds(String[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据套餐ids绑定电子围栏
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int updateZcRentCarRuleBindFence(@Param("ids") List<Long> ids, @Param("fenceId") Long fenceId);
|
||||||
|
/**
|
||||||
|
* 根据电子围栏id 取消与套餐绑定
|
||||||
|
* @param fenceId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int updateZcRentCarRuleUnbindFence(@Param("fenceId") Long fenceId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -51,6 +51,19 @@ public interface IZcRentCarRuleService
|
|||||||
*/
|
*/
|
||||||
public int updateZcRentCarRule(List<Long> carModelIds, ZcRentCarRule zcRentCarRule);
|
public int updateZcRentCarRule(List<Long> carModelIds, ZcRentCarRule zcRentCarRule);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据套餐ids绑定电子围栏
|
||||||
|
* @param rentCarRuleIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int updateZcRentCarRuleBindFence(List<Long> rentCarRuleIds,Long fenceId);
|
||||||
|
/**
|
||||||
|
* 根据电子围栏id 取消与套餐绑定
|
||||||
|
* @param fenceId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int updateZcRentCarRuleUnbindFence(Long fenceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除租车计费规则
|
* 批量删除租车计费规则
|
||||||
*
|
*
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
import com.ruoyi.common.utils.DateUtils;
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
import com.ruoyi.operation.domain.ZcCarModelPackage;
|
import com.ruoyi.operation.domain.ZcCarModelPackage;
|
||||||
import com.ruoyi.operation.mapper.ZcElectronicFenceRuleMapper;
|
import com.ruoyi.operation.mapper.ZcElectronicFenceRuleMapper;
|
||||||
|
import com.ruoyi.operation.service.IZcRentCarRuleService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -29,6 +30,8 @@ public class ZcElectronicFenceServiceImpl implements IZcElectronicFenceService
|
|||||||
private ZcElectronicFenceMapper zcElectronicFenceMapper;
|
private ZcElectronicFenceMapper zcElectronicFenceMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ZcElectronicFenceRuleMapper zcElectronicFenceRuleMapper;
|
private ZcElectronicFenceRuleMapper zcElectronicFenceRuleMapper;
|
||||||
|
@Autowired
|
||||||
|
private IZcRentCarRuleService zcRentCarRuleService;
|
||||||
/**
|
/**
|
||||||
* 查询电子围栏
|
* 查询电子围栏
|
||||||
*
|
*
|
||||||
@ -77,8 +80,9 @@ public class ZcElectronicFenceServiceImpl implements IZcElectronicFenceService
|
|||||||
}
|
}
|
||||||
if (!zcElectronicFenceRuleList.isEmpty()) {
|
if (!zcElectronicFenceRuleList.isEmpty()) {
|
||||||
zcElectronicFenceRuleMapper.batchInsert(zcElectronicFenceRuleList);
|
zcElectronicFenceRuleMapper.batchInsert(zcElectronicFenceRuleList);
|
||||||
}
|
|
||||||
|
|
||||||
|
zcRentCarRuleService.updateZcRentCarRuleBindFence(zcElectronicFence.getRentCarRuleIds(),zcElectronicFence.getId());
|
||||||
|
}
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +98,7 @@ public class ZcElectronicFenceServiceImpl implements IZcElectronicFenceService
|
|||||||
{
|
{
|
||||||
zcElectronicFence.setUpdateTime(DateUtils.getNowDate());
|
zcElectronicFence.setUpdateTime(DateUtils.getNowDate());
|
||||||
zcElectronicFenceMapper.deleteZcElectronicFenceRuleByElectronicFenceId(zcElectronicFence.getId());
|
zcElectronicFenceMapper.deleteZcElectronicFenceRuleByElectronicFenceId(zcElectronicFence.getId());
|
||||||
|
zcRentCarRuleService.updateZcRentCarRuleUnbindFence(zcElectronicFence.getId());
|
||||||
|
|
||||||
// 保存关联表 ZcRentCarRuleBattery 数据
|
// 保存关联表 ZcRentCarRuleBattery 数据
|
||||||
List<ZcElectronicFenceRule> zcElectronicFenceRuleList = new ArrayList<>();
|
List<ZcElectronicFenceRule> zcElectronicFenceRuleList = new ArrayList<>();
|
||||||
@ -106,6 +111,7 @@ public class ZcElectronicFenceServiceImpl implements IZcElectronicFenceService
|
|||||||
}
|
}
|
||||||
if (!zcElectronicFenceRuleList.isEmpty()) {
|
if (!zcElectronicFenceRuleList.isEmpty()) {
|
||||||
zcElectronicFenceRuleMapper.batchInsert(zcElectronicFenceRuleList);
|
zcElectronicFenceRuleMapper.batchInsert(zcElectronicFenceRuleList);
|
||||||
|
zcRentCarRuleService.updateZcRentCarRuleBindFence(zcElectronicFence.getRentCarRuleIds(), zcElectronicFence.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
return zcElectronicFenceMapper.updateZcElectronicFence(zcElectronicFence);
|
return zcElectronicFenceMapper.updateZcElectronicFence(zcElectronicFence);
|
||||||
|
|||||||
@ -92,6 +92,9 @@ public class ZcRentCarRuleServiceImpl implements IZcRentCarRuleService
|
|||||||
{
|
{
|
||||||
ZcRentCarRule zcRentCarRule = new ZcRentCarRule();
|
ZcRentCarRule zcRentCarRule = new ZcRentCarRule();
|
||||||
zcRentCarRule.setStatus("0");
|
zcRentCarRule.setStatus("0");
|
||||||
|
// 查询未绑定电子围栏套餐 和 当前绑定的套餐
|
||||||
|
zcRentCarRule.setQueryFenceRule("0");
|
||||||
|
zcRentCarRule.setExtend1(fenceId.toString());
|
||||||
List<ZcRentCarRule> rentCarRuleList = zcRentCarRuleMapper.selectZcRentCarRuleList(zcRentCarRule);
|
List<ZcRentCarRule> rentCarRuleList = zcRentCarRuleMapper.selectZcRentCarRuleList(zcRentCarRule);
|
||||||
ZcElectronicFenceRule fenceRule = new ZcElectronicFenceRule();
|
ZcElectronicFenceRule fenceRule = new ZcElectronicFenceRule();
|
||||||
fenceRule.setElectronicFenceId(fenceId);
|
fenceRule.setElectronicFenceId(fenceId);
|
||||||
@ -153,6 +156,16 @@ public class ZcRentCarRuleServiceImpl implements IZcRentCarRuleService
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateZcRentCarRuleBindFence(List<Long> rentCarRuleIds,Long fenceId) {
|
||||||
|
return zcRentCarRuleMapper.updateZcRentCarRuleBindFence(rentCarRuleIds,fenceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateZcRentCarRuleUnbindFence(Long fenceId) {
|
||||||
|
return zcRentCarRuleMapper.updateZcRentCarRuleUnbindFence(fenceId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除租车计费规则
|
* 批量删除租车计费规则
|
||||||
*
|
*
|
||||||
|
|||||||
@ -57,6 +57,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="operatingCompanyId != null and operatingCompanyId != ''"> and a.operating_company_id = #{operatingCompanyId}</if>
|
<if test="operatingCompanyId != null and operatingCompanyId != ''"> and a.operating_company_id = #{operatingCompanyId}</if>
|
||||||
<if test="status != null and status != ''"> and a.status = #{status}</if>
|
<if test="status != null and status != ''"> and a.status = #{status}</if>
|
||||||
<if test="isDefault != null and isDefault != ''"> and a.is_default = #{isDefault}</if>
|
<if test="isDefault != null and isDefault != ''"> and a.is_default = #{isDefault}</if>
|
||||||
|
<if test="extend1 != null and extend1 != '' and queryFenceRule == null"> and a.extend1 = #{extend1}</if>
|
||||||
|
<if test="queryFenceRule != null and queryFenceRule != '' and queryFenceRule == 0 ">
|
||||||
|
and (a.extend1 = '0' OR a.extend1 = #{extend1})
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by a.update_time desc
|
order by a.update_time desc
|
||||||
</select>
|
</select>
|
||||||
@ -158,6 +162,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
<update id="updateZcRentCarRuleBindFence">
|
||||||
|
update zc_rent_car_rule set extend1 = #{fenceId} where id in
|
||||||
|
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</update>
|
||||||
|
<update id="updateZcRentCarRuleUnbindFence">
|
||||||
|
update zc_rent_car_rule set extend1 = '0' where extend1 = #{fenceId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<delete id="deleteZcRentCarRuleById" parameterType="Long">
|
<delete id="deleteZcRentCarRuleById" parameterType="Long">
|
||||||
delete from zc_rent_car_rule where id = #{id}
|
delete from zc_rent_car_rule where id = #{id}
|
||||||
|
|||||||
@ -100,6 +100,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<p>提示:<br/>
|
<p>提示:<br/>
|
||||||
绘制:鼠标左键点击及移动即可绘制图形<br/>
|
绘制:鼠标左键点击及移动即可绘制图形<br/>
|
||||||
|
撤销:鼠标右键点击撤销<br/>
|
||||||
结束绘制:鼠标左键双击即可结束绘制折线、多边形会自动闭合;<br/>
|
结束绘制:鼠标左键双击即可结束绘制折线、多边形会自动闭合;<br/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
left: 0px;
|
left: 0px;
|
||||||
right: 0px;
|
right: 0px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
width: 40px;
|
width: 90px;
|
||||||
z-index: 1001;
|
z-index: 1001;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,28 +50,12 @@
|
|||||||
background-color: #d5dff2;
|
background-color: #d5dff2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#marker {
|
|
||||||
background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/marker_editor.png');
|
|
||||||
}
|
|
||||||
|
|
||||||
#polyline {
|
|
||||||
background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/polyline.png');
|
|
||||||
}
|
|
||||||
|
|
||||||
#polygon {
|
#polygon {
|
||||||
background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/polygon.png');
|
background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/polygon.png');
|
||||||
}
|
}
|
||||||
|
|
||||||
#circle {
|
#delete {
|
||||||
background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/circle.png');
|
background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/delete.png');
|
||||||
}
|
|
||||||
|
|
||||||
#rectangle {
|
|
||||||
background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/rectangle.png');
|
|
||||||
}
|
|
||||||
|
|
||||||
#ellipse {
|
|
||||||
background-image: url('https://mapapi.qq.com/web/lbs/javascriptGL/demo/img/ellipse.png');
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
@ -93,13 +77,15 @@
|
|||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div id="container" class="map-container"></div>
|
<div id="container" class="map-container"></div>
|
||||||
<div id="toolControl">
|
<div id="toolControl">
|
||||||
<div class="toolItem active" id="polygon" title="多边形"></div>
|
<!-- <div class="toolItem active" id="polygon" title="多边形"></div> -->
|
||||||
|
<!-- <div class="toolItem" id="delete" onclick="editor.delete();" title="删除"></div> -->
|
||||||
<!-- <div class="toolItem" id="circle" title="圆形"></div>-->
|
<!-- <div class="toolItem" id="circle" title="圆形"></div>-->
|
||||||
<!-- <div class="toolItem" id="rectangle" title="矩形"></div>-->
|
<!-- <div class="toolItem" id="rectangle" title="矩形"></div>-->
|
||||||
<!-- <div class="toolItem" id="ellipse" title="椭圆"></div>-->
|
<!-- <div class="toolItem" id="ellipse" title="椭圆"></div>-->
|
||||||
</div>
|
</div>
|
||||||
<p>提示:<br/>
|
<p>提示:<br/>
|
||||||
绘制:鼠标左键点击及移动即可绘制图形<br/>
|
绘制:鼠标左键点击及移动即可绘制图形<br/>
|
||||||
|
撤销:鼠标右键点击撤销<br/>
|
||||||
结束绘制:鼠标左键双击即可结束绘制折线、多边形会自动闭合;<br/>
|
结束绘制:鼠标左键双击即可结束绘制折线、多边形会自动闭合;<br/>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -108,7 +94,7 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-2 control-label">围栏坐标地址:</label>
|
<label class="col-sm-2 control-label">围栏坐标地址:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<textarea name="address" class="form-control">[[*{address}]]</textarea>
|
<textarea id="address" name="address" class="form-control">[[*{address}]]</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h4 class="form-header h4">关联套餐</h4>
|
<h4 class="form-header h4">关联套餐</h4>
|
||||||
@ -268,80 +254,86 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 转换函数
|
||||||
|
function convertCoordinates(coordinates) {
|
||||||
|
return coordinates.map(coord =>
|
||||||
|
`new TMap.LatLng(${coord.lat},${coord.lng})`
|
||||||
|
).join(',\n');
|
||||||
|
}
|
||||||
|
|
||||||
function initMap() {
|
function initMap() {
|
||||||
var center = new TMap.LatLng(28.228302, 112.938901);
|
// 回显已存在的围栏数据
|
||||||
|
var address = [[${zcElectronicFence.address}]];
|
||||||
|
address = JSON.parse(address);
|
||||||
|
const simplePath = address.map(coord => new TMap.LatLng(coord.lat, coord.lng));
|
||||||
|
|
||||||
|
// 取第一个经纬度用于初始化地图中心位置
|
||||||
|
var center;
|
||||||
|
if (simplePath.length > 0) {
|
||||||
|
center = simplePath[0];
|
||||||
|
console.log('使用围栏第一个点作为中心:', center.lat, center.lng);
|
||||||
|
} else {
|
||||||
|
center = new TMap.LatLng(28.228302, 112.938901);
|
||||||
|
console.log('使用默认中心点:', center.lat, center.lng);
|
||||||
|
}
|
||||||
map = new TMap.Map('container', {
|
map = new TMap.Map('container', {
|
||||||
zoom: 12,
|
zoom: 12,
|
||||||
center: center,
|
center: center,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 初始化几何图形及编辑器
|
// 初始化几何图形及编辑器
|
||||||
var marker = new TMap.MultiMarker({ map: map });
|
|
||||||
var polyline = new TMap.MultiPolyline({ map: map });
|
|
||||||
var polygon = new TMap.MultiPolygon({ map: map });
|
var polygon = new TMap.MultiPolygon({ map: map });
|
||||||
var circle = new TMap.MultiCircle({ map: map });
|
|
||||||
var rectangle = new TMap.MultiRectangle({ map: map });
|
|
||||||
var ellipse = new TMap.MultiEllipse({ map: map });
|
|
||||||
|
|
||||||
editor = new TMap.tools.GeometryEditor({
|
editor = new TMap.tools.GeometryEditor({
|
||||||
map: map,
|
map: map,
|
||||||
overlayList: [
|
overlayList: [
|
||||||
{ overlay: marker, id: 'marker' },
|
|
||||||
{ overlay: polyline, id: 'polyline' },
|
|
||||||
{ overlay: polygon, id: 'polygon' },
|
{ overlay: polygon, id: 'polygon' },
|
||||||
{ overlay: circle, id: 'circle' },
|
|
||||||
{ overlay: rectangle, id: 'rectangle' },
|
|
||||||
{ overlay: ellipse, id: 'ellipse' },
|
|
||||||
],
|
],
|
||||||
actionMode: TMap.tools.constants.EDITOR_ACTION.DRAW,
|
actionMode: TMap.tools.constants.EDITOR_ACTION.DRAW,
|
||||||
activeOverlayId: 'polygon',
|
activeOverlayId: 'polygon',
|
||||||
snappable: true,
|
snappable: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 等待编辑器初始化完成后再回显数据
|
// 初始化几何图形及编辑器
|
||||||
setTimeout(function() {
|
editor = new TMap.tools.GeometryEditor({
|
||||||
echoExistingFence(polygon);
|
map, // 编辑器绑定的地图对象
|
||||||
}, 500);
|
overlayList: [ // 可编辑图层
|
||||||
|
{
|
||||||
// 监听绘制结束事件
|
overlay: new TMap.MultiPolygon({
|
||||||
editor.on('draw_complete', (geometry) => {
|
map,
|
||||||
var id = geometry.id;
|
styles: {
|
||||||
if (editor.getActiveOverlay().id === 'polygon') {
|
highlight: new TMap.PolygonStyle({
|
||||||
var geo = polygon.geometries.filter(function (item) {
|
color: 'rgba(255, 255, 0, 0.6)'
|
||||||
return item.id === id;
|
})
|
||||||
});
|
},
|
||||||
console.log('绘制的多边形坐标:', geo[0].paths);
|
geometries: [
|
||||||
$("#address").val(JSON.stringify(geo[0].paths));
|
{
|
||||||
|
paths: simplePath
|
||||||
}
|
}
|
||||||
});
|
]
|
||||||
|
}),
|
||||||
|
id: 'polygon',
|
||||||
|
selectedStyleId: 'highlight'
|
||||||
}
|
}
|
||||||
|
],
|
||||||
function echoExistingFence(polygon) {
|
actionMode: TMap.tools.constants.EDITOR_ACTION.INTERACT, // 编辑器的工作模式
|
||||||
// 回显已存在的围栏数据
|
activeOverlayId: 'polygon', // 激活图层
|
||||||
var existingAddress = $("#address").val();
|
selectable: true, // 开启点选功能
|
||||||
console.log("existing address:", existingAddress);
|
snappable: true // 开启吸附
|
||||||
|
});
|
||||||
if (existingAddress && existingAddress.trim() !== "") {
|
|
||||||
try {
|
|
||||||
var paths = JSON.parse(existingAddress);
|
// 监听删除、修改完成事件
|
||||||
console.log("parsed paths:", paths);
|
let evtList = ['delete', 'adjust'];
|
||||||
|
evtList.forEach(evtName => {
|
||||||
// 清除可能已存在的几何图形
|
editor.on(evtName + '_complete', evtResult => {
|
||||||
polygon.clear();
|
console.log(evtName, JSON.stringify(evtResult.paths));
|
||||||
|
$("#address").val(JSON.stringify(evtResult.paths));
|
||||||
// 添加几何图形
|
});
|
||||||
polygon.addGeometry({
|
|
||||||
id: "existingPolygon",
|
|
||||||
styleId: "default",
|
|
||||||
paths: paths
|
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("围栏回显完成");
|
|
||||||
} catch (e) {
|
|
||||||
console.error("解析围栏坐标数据失败:", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化地图
|
// 初始化地图
|
||||||
window.onload = initMap;
|
window.onload = initMap;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user