|
@@ -3,6 +3,7 @@ function CityLandAction(context, id){
|
|
this.id = id
|
|
this.id = id
|
|
this.selected = {}
|
|
this.selected = {}
|
|
this.tempVectorLayer = null
|
|
this.tempVectorLayer = null
|
|
|
|
+ this.popup = null
|
|
this.obj = new CityLand({
|
|
this.obj = new CityLand({
|
|
url : context.local_wmts_path,
|
|
url : context.local_wmts_path,
|
|
projection: context.projection
|
|
projection: context.projection
|
|
@@ -14,8 +15,13 @@ CityLandAction.prototype = {
|
|
startStatus : false,
|
|
startStatus : false,
|
|
createStatus : false,
|
|
createStatus : false,
|
|
create(){
|
|
create(){
|
|
|
|
+ let that = this
|
|
this.obj.getTileLayer()
|
|
this.obj.getTileLayer()
|
|
this.tempVectorLayer = this.loadTempVectorLayer()
|
|
this.tempVectorLayer = this.loadTempVectorLayer()
|
|
|
|
+ this.popup = new Popup({map: this.context.currentMap,
|
|
|
|
+ close(){
|
|
|
|
+ that.tempVectorLayer.getSource().clear()
|
|
|
|
+ }});
|
|
this.createStatus = true;
|
|
this.createStatus = true;
|
|
},
|
|
},
|
|
start(){
|
|
start(){
|
|
@@ -38,6 +44,8 @@ CityLandAction.prototype = {
|
|
console.log("tempVectorLayer cleared")
|
|
console.log("tempVectorLayer cleared")
|
|
this.context.clicks[this.id] = null
|
|
this.context.clicks[this.id] = null
|
|
console.log("remove click")
|
|
console.log("remove click")
|
|
|
|
+ this.popup._close()
|
|
|
|
+ console.log("close popup")
|
|
this.startStatus = false;
|
|
this.startStatus = false;
|
|
},
|
|
},
|
|
click(event, that){
|
|
click(event, that){
|
|
@@ -48,12 +56,29 @@ CityLandAction.prototype = {
|
|
that.clickLock = true
|
|
that.clickLock = true
|
|
let layerName = that.obj.wmsData.params.LAYER.substring(that.obj.wmsData.params.LAYER.indexOf(":") + 1)
|
|
let layerName = that.obj.wmsData.params.LAYER.substring(that.obj.wmsData.params.LAYER.indexOf(":") + 1)
|
|
that.context.getInfo(layerName, event.coordinate, function(res){
|
|
that.context.getInfo(layerName, event.coordinate, function(res){
|
|
- let feature = new ol.Feature({
|
|
|
|
- geometry: that.context.wkt.readGeometry(res.data.geom.substring(res.data.geom.indexOf(";") +1 )).transform("EPSG:4526","EPSG:4326")
|
|
|
|
- });
|
|
|
|
- that.tempVectorLayer.getSource().clear()
|
|
|
|
- that.tempVectorLayer.getSource().addFeature(feature)
|
|
|
|
- that.clickLock = false
|
|
|
|
|
|
+ try {
|
|
|
|
+ console.log(res.data)
|
|
|
|
+ let geometry = that.context.wkt.readGeometry(res.data.wkt)
|
|
|
|
+ let area = geometry.getArea()
|
|
|
|
+ area = (area + area / 2) / 1000
|
|
|
|
+ res.data["area"] = area.toFixed(2)
|
|
|
|
+ let feature = new ol.Feature({
|
|
|
|
+ geometry: geometry.transform("EPSG:4526","EPSG:4326")
|
|
|
|
+ });
|
|
|
|
+ for(let key in res.data){
|
|
|
|
+ if(key != "wkt"){
|
|
|
|
+ feature.set(key, res.data[key])
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ that.tempVectorLayer.getSource().clear()
|
|
|
|
+ that.tempVectorLayer.getSource().addFeature(feature)
|
|
|
|
+ that.popup.show(ol.extent.getCenter(feature.getGeometry().getExtent()), that.getInfoHtml(feature))
|
|
|
|
+ }catch (e){
|
|
|
|
+ console.log(e)
|
|
|
|
+ }finally {
|
|
|
|
+ that.clickLock = false
|
|
|
|
+ }
|
|
|
|
+
|
|
},function(){
|
|
},function(){
|
|
that.clickLock = false
|
|
that.clickLock = false
|
|
})
|
|
})
|
|
@@ -77,6 +102,27 @@ CityLandAction.prototype = {
|
|
},
|
|
},
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ landType:{
|
|
|
|
+ 0:"其他",
|
|
|
|
+ 1:"湿地",
|
|
|
|
+ 2:"耕地",
|
|
|
|
+ 3:"种植",
|
|
|
|
+ 4:"林地",
|
|
|
|
+ 5:"草地",
|
|
|
|
+ 6:"水域",
|
|
|
|
+ },getInfoHtml(feature){
|
|
|
|
+ let html = ""
|
|
|
|
+ let data = {
|
|
|
|
+ "地块类别":this.landType[feature.get("gridcode")],
|
|
|
|
+ "地块图斑编号":feature.get("id"),
|
|
|
|
+ "地块面积(亩)":feature.get("area"),
|
|
|
|
+ "地块周长(米)":"10000",
|
|
|
|
+ }
|
|
|
|
+ for(let key in data){
|
|
|
|
+ html += "<div class='layui-row'><div class='lab' >"+key+"</div><div class='val' >"+data[key]+"</div></div>"
|
|
|
|
+ }
|
|
|
|
+ return html
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -138,6 +184,8 @@ CityLand.prototype = {
|
|
this.layerData.layer = new ol.layer.Tile({
|
|
this.layerData.layer = new ol.layer.Tile({
|
|
source: this.layerData.source,
|
|
source: this.layerData.source,
|
|
zIndex: 2,
|
|
zIndex: 2,
|
|
|
|
+ minZoom: 8,
|
|
|
|
+ maxZoom: 14
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|