function GeoServerContext(opt,geoserver_path){ this.local_wms_path = geoserver_path+"/wuhan/wms" this.local_wmts_path = geoserver_path+"/gwc/service/wmts" this.local_wfs_path = geoserver_path + "/wuhan/ows" this.actions = {} this.clicks = {} this.currentMap = opt.currentMap || window.map this.currentView = opt.currentView || window.view this.projection = opt.projection || window.projection this.wkt = new ol.format.WKT() let that = this this.currentMap.on("click", function(event){ for(let id in that.clicks){ let action = that.clicks[id] if(action && action.click){ action.click(event, action) } } }) } GeoServerContext.prototype = { createAction(key, Action, ext){ if(!this.actions[key]){ this.actions[key] = new Action(this, key, ext) this.actions[key].create() } return this.actions[key] }, stopActions(currentKey){ for(let key in this.actions){ let always = false; if(this.actions[key].obj && this.actions[key].obj.layerData){ always = this.actions[key].obj.layerData["always"] } if(!always && currentKey != key){ this.actions[key].stop() } } }, getInfo(layerName , coordinate, callback, error) { // coordinate = ol.proj.transform([coordinate[0],coordinate[1]],"EPSG:4326","EPSG:4526") console.log(layerName, coordinate) $.ajax({ type : 'POST', url : "/crop/getInfo", data : {layerName: layerName, x : coordinate[0], y : coordinate[1]}, dataType : 'json', success : function(res){ callback(res) },error: function(req){ if(error) error(req) } }); },getBuffer(coordinate,m, callback, error) { // coordinate = ol.proj.transform([coordinate[0],coordinate[1]],"EPSG:4326","EPSG:4526") $.ajax({ type : 'POST', url : "/crop/getBuffer", data : { x : coordinate[0], y : coordinate[1], m:m}, dataType : 'json', success : function(res){ callback(res) },error: function(req){ if(error) error(req) } }); }, //获取图例 getSldStyleSign(styleName){ $.ajax({ type : 'POST', url : "/sld_style/sign", data : {styleName: styleName}, dataType : 'json', success : function(res){ let html = "" let data = JSON.parse(res.msg) for(let item of data){ html += '