OpenLayers.Map.prototype.omGetZoom = function(zoom) { if (OpenMap.Config.currentBaseMapsSpec == "daum" || OpenMap.Config.currentBaseMapsSpec == "daum_satellite") { return zoom; //다음 좌표계일때 } else { return zoom + 7; //구글 좌표계일때 } }; OpenLayers.Map.prototype.omGetPrintBody = function(zoom, x, y, width, height) { var res = this.getResolutionForZoom(zoom); var width2 = width / 2; var height2 = height / 2; var minX = x - width2; var minY = y - height2; var maxX = x + width2; var maxY = y + height2; var imageSize = OpenLayers.String.format('${width}x${height}', { 'width' : width, 'height' : height }); var center = OpenLayers.String.format('${x}x${y}', { 'x' : x, 'y' : y }); var body = { 'setting' : { 'returnType' : 'U', 'tileType' : 'G', // D:다음, G:구글 'coordType' : 'W', 'imageType' : 'P', 'imageSize' : imageSize, 'zoom' : zoom, 'center' : center }, 'data' : [] }; var data = body.data; var layers = this.layers; for (var i in layers) { var layer = layers[i]; if (layer.omprint && layer.visibility) { // console.log(layer.name); // todo: remove var list = layer.omprint(zoom, minX, minY, maxX, maxY); if (!$.isArray(list)) { data.push(list); } else if (list.length) { for (var index in list) { if (list[index].type) { data.push(list[index]); } } } } } // console.log(body); // todo: remove return body; }; OpenLayers.Map.prototype.omprint = function(setting, cb) { if (!setting) { setting = {}; } var zoom = setting.zoom || this.getZoom(); var center = this.getCenter(); var x = setting.x || center.lon; var y = setting.y || center.lat; var mapDiv = $(this.div); var width = setting.width || mapDiv.width(); var height = setting.height || mapDiv.height(); var body = this.omGetPrintBody(this.omGetZoom(zoom), x, y, width, height); // var layerProperty = null; $.ajax({ url : OpenMap.Config.openmapPrintUrl, data : JSON.stringify(body), cache : false, type : "POST", timeout : 60 * 5 * 1000, dataType : "json", async : true, success : function(data) { if (cb && cb.success) { cb.success(data); } else { console.log(window.location.origin + OpenMap.Config.openmapPrintImageUrl + data.printId); // alert(window.location.origin + OpenMap.Config.openmapPrintImageUrl + data.printId); } }, error : function(XMLHttpRequest, textStatus, errorThrown) { if (cb && cb.fail) { cb.fail(textStatus, errorThrown); } else { alert("Status: " + textStatus + '\n' + "Error: " + errorThrown); } } }); };