|
@@ -21,11 +21,10 @@ CityLandAction.prototype = {
|
|
|
|
|
|
this.popup = new Popup({map: this.context.currentMap,
|
|
|
close(){
|
|
|
- that.tempVectorLayer.getSource().clear()
|
|
|
that.clickLock = false
|
|
|
},
|
|
|
buttons:[
|
|
|
- {"name":"发布任务","click":"pubTask"},{"name":"放大到合适","click":"fit"}
|
|
|
+ {"name":"发布任务","click":"pubTask"},{"name":"缩放","click":"fit"}
|
|
|
],
|
|
|
listener: {
|
|
|
info(){
|
|
@@ -46,7 +45,7 @@ CityLandAction.prototype = {
|
|
|
console.log("startStatus is true")
|
|
|
return
|
|
|
}
|
|
|
- this.context.clicks[this.id] = this
|
|
|
+ // this.context.clicks[this.id] = this
|
|
|
this.drawMultiPolygon.show()
|
|
|
this.context.currentMap.addLayer(this.obj.layerData.layer)
|
|
|
this.context.getSldStyleSign(this.obj.wmsData.params.STYLE)
|
|
@@ -121,32 +120,22 @@ CityLandAction.prototype = {
|
|
|
let source = this.tempVectorLayer.getSource();
|
|
|
source.addFeature(point)
|
|
|
},
|
|
|
- // addFieldPoint(f){
|
|
|
- // let centerPoint = f.get("center_point")
|
|
|
- // let point = new ol.Feature({
|
|
|
- // geometry: new ol.geom.Point(extent)
|
|
|
- // });
|
|
|
- // point.set("isPoint",1)
|
|
|
- // point.setId(cityLand.id)
|
|
|
- // point.set("status",cityLand.status)
|
|
|
- // let source = this.tempVectorLayer.getSource();
|
|
|
- // source.addFeature(point)
|
|
|
- // },
|
|
|
- selectedCountry(f){
|
|
|
- let stroke = new ol.style.Stroke({
|
|
|
- color: 'rgba(200,20,20,0.8)',
|
|
|
- width: 2,
|
|
|
- })
|
|
|
- let fill = new ol.style.Fill({
|
|
|
- color: 'rgba(200,20,20,0.4)',
|
|
|
- })
|
|
|
- const style1 = new ol.style.Style({
|
|
|
- stroke: stroke,
|
|
|
- fill: fill
|
|
|
+ newFieldPoint(f){
|
|
|
+ let centerPoint = f.get("center_point")
|
|
|
+ let point = new ol.Feature({
|
|
|
+ geometry: new ol.geom.Point(centerPoint.coordinates)
|
|
|
});
|
|
|
- return f.get("isPoint") ? globalStyle.pointStyle(f) : style1
|
|
|
+ for(let key of f.getKeys()){
|
|
|
+ if(key != "geometry"){
|
|
|
+ point.set(key,f.get(key))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ point.set("isPoint",1)
|
|
|
+ point.setId(f.getId().substring(f.getId().indexOf(".") + 1))
|
|
|
+ return point;
|
|
|
}
|
|
|
,loadTempVectorLayer(){
|
|
|
+ let that = this
|
|
|
let map = this.context.currentMap
|
|
|
let baseUrl = this.context.local_wfs_path
|
|
|
const vectorSource = new ol.source.Vector({
|
|
@@ -168,6 +157,13 @@ CityLandAction.prototype = {
|
|
|
if (xhr.status == 200) {
|
|
|
const features = vectorSource.getFormat().readFeatures(xhr.responseText);
|
|
|
vectorSource.addFeatures(features);
|
|
|
+ for(let feature of features){
|
|
|
+ feature.set("id",feature.getId().substring(feature.getId().indexOf(".") + 1))
|
|
|
+ let area = feature.getGeometry().getArea()
|
|
|
+ area = (area + area / 2) / 1000
|
|
|
+ feature.set("area", area.toFixed(2));
|
|
|
+ vectorSource.addFeature(that.newFieldPoint(feature))
|
|
|
+ }
|
|
|
success(features);
|
|
|
} else {
|
|
|
onError();
|
|
@@ -178,36 +174,53 @@ CityLandAction.prototype = {
|
|
|
strategy: ol.loadingstrategy.bbox,
|
|
|
});
|
|
|
|
|
|
- return new ol.layer.Vector({
|
|
|
+ let vector = new ol.layer.Vector({
|
|
|
map: map,
|
|
|
source:vectorSource,
|
|
|
- style: this.selectedCountry,
|
|
|
- minZoom:15,
|
|
|
+ style: globalStyle.cropStyle,
|
|
|
+ minZoom:13,
|
|
|
maxZoom:20
|
|
|
});
|
|
|
- },
|
|
|
- landType:{
|
|
|
- 0:"其他",
|
|
|
- 1:"湿地",
|
|
|
- 2:"耕地",
|
|
|
- 3:"种植",
|
|
|
- 4:"林地",
|
|
|
- 5:"草地",
|
|
|
- 6:"水域",
|
|
|
+
|
|
|
+ that.select = new ol.interaction.Select({
|
|
|
+ condition: ol.events.condition.singleClick,
|
|
|
+ layers:[vector],
|
|
|
+ style: globalStyle.selectedCropStyle
|
|
|
+ })
|
|
|
+ map.addInteraction(that.select)
|
|
|
+ that.select.on("select",function(e){
|
|
|
+ if(e.selected.length > 0){
|
|
|
+ console.log(e.selected[0].get("center_point").coordinates)
|
|
|
+ that.popup.show(e.selected[0].get("center_point").coordinates, that.getInfoHtml(e.selected[0]), e.selected[0])
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return vector;
|
|
|
},getInfoHtml(feature){
|
|
|
let html = ""
|
|
|
+ console.log(feature.getKeys())
|
|
|
let data = {
|
|
|
"地块类别":this.landType[feature.get("gridcode")],
|
|
|
+ "名称":feature.get("name"),
|
|
|
+ "地址":feature.get("address"),
|
|
|
+ "作物":cropTypes[feature.get("crop_type")],
|
|
|
"地块图斑编号":feature.get("id"),
|
|
|
+ "地块状态":this.taskStatus[feature.get("status")],
|
|
|
"地块面积(亩)":feature.get("area"),
|
|
|
- "地块周长(米)":"10000",
|
|
|
+ "生长期":cropPeriods[feature.get("growing_period")],
|
|
|
+ "图片信息":"<a style='color: whitesmoke;' href='javascript:layui.tool.open(!,!,!,!)'>点击查看</a>"
|
|
|
+ .format('"/crop_image/view?id='+feature.get("id")+'"','"60%"','"图片信息"','{area:["90%","90%"],shade:0.1}'),
|
|
|
}
|
|
|
for(let key in data){
|
|
|
+ console.log(data[key])
|
|
|
html += "<div class='layui-row'><div class='lab' >"+key+"</div><div class='val' >"+data[key]+"</div></div>"
|
|
|
}
|
|
|
return html
|
|
|
},
|
|
|
+ taskStatus:["未发布","已发布","已领取","已完成"],
|
|
|
+ landType:{0:"其他", 1:"湿地", 2:"耕地", 3:"种植", 4:"林地", 5:"草地", 6:"水域"}
|
|
|
+ ,
|
|
|
saveTask(that, feature){
|
|
|
+ console.log(feature.getKeys())
|
|
|
layui.tool.submit("/crop/publish",{"id":feature.get("id")},function(res){
|
|
|
if(res.code == 0){
|
|
|
that.addFieldPointOfTempLayer(res.data)
|