function JScriptTag(src, charset) { document.write('<'+'script src="' + src + '"' +' type="text/javascript"' + (charset ? ' charset="' + charset + '"' : '') + '><'+'/script>'); } JScriptTag("http://map.wooricy.com/AjaxMap/Resource/js/JMap.js"); function JSpec() { this.tileSize = 256; this.minX = 0; this.maxX = 1000000; this.minY = -100000; this.maxY = 1000000; this.minLevel = 1; this.maxLevel = 12; this.constant = 0.5; // 1lv 1px = 0.5 miter this.CoordType = "KATECH"; this.ResourceUrl = "http://map.wooricy.com/AjaxMap/Resource/"; this.emptyTileUrl = 'http://map.wooricy.com/AjaxMap/Resource/img/mapbg_sea.png'; this.preTileUrl = 'http://map.wooricy.com/AjaxMap/Resource/img/mapbg.png'; this.baseMapUrls = [ 'http://220.95.238.158/gyeonggi_eng/' ]; this.downloadUrl = 'http://220.95.238.158/gyeonggi_eng/download.php'; this.arrDistPerPixel = []; /* this.arrDistPerPixel = [0.5, 1, 2, 4, 8, 16, 32]; */ } JSpec.prototype.getCoordType = function (c) { return this.CoordType; }; JSpec.prototype.setCoordType = function (c) { this.CoordType = c; }; JSpec.prototype.getDistance = function (a, b) { if(!a || !b) return null; var meter = 0; if(this.CoordType=="WGS84") { var RE = 6378137; var LON1 = a.x; var LAT1 = a.y; var LON2 = b.x; var LAT2 = b.y; var DLON= Math.abs((LON2 - LON1) * Math.PI / 180.0); var DLAT= Math.abs((LAT2 - LAT1) * Math.PI / 180.0); var A = Math.abs( Math.pow(Math.sin(DLAT / 2.0), 2) + Math.cos(LAT1* Math.PI / 180.0) * Math.cos(LAT2* Math.PI / 180.0) * Math.pow(Math.sin(DLON / 2.0), 2) ); meter = RE * 2.0 * Math.asin(Math.min(1, Math.sqrt(A))); } else meter = a.distance(b); return meter; }; JSpec.prototype.setConstant = function (c) { this.constant = c; }; JSpec.prototype.distancePerPixel =function (level) { if(!this.arrDistPerPixel[level-1]) this.arrDistPerPixel[level-1] = Math.pow(2, level-1) * this.constant; return this.arrDistPerPixel[level-1]; }; JSpec.prototype.getRowCount =function (level) { var dp = this.distancePerPixel(level); var rowImageCount = Math.floor((this.maxX - this.minX) / (dp * this.tileSize)); return rowImageCount; }; JSpec.prototype.getColCount =function (level) { var dp = this.distancePerPixel(level); var colImageCount = Math.floor((this.maxY - this.minY) / (dp * this.tileSize)); return colImageCount; }; JSpec.prototype.getTileUrl = function(xIndex, yIndex, level) { var rowImageCount = this.getRowCount(level); var colImageCount = this.getColCount(level); if (xIndex < 0 || yIndex < 0 || xIndex >= rowImageCount || yIndex >= colImageCount) { return this.emptyTileUrl; } var imageIndex = yIndex * rowImageCount + xIndex; var orgImageIndex = imageIndex; var fullpath = ""; fullpath = "/" + String(imageIndex % 1000) + fullpath; imageIndex = Math.floor(imageIndex / 1000); fullpath = "/" + String(imageIndex % 1000) + fullpath; imageIndex = Math.floor(imageIndex / 1000); fullpath = "/" + String(imageIndex % 1000) + fullpath; imageIndex = Math.floor(imageIndex / 1000); fullpath = "/" + String(imageIndex % 1000) + fullpath; return this.baseMapUrls[orgImageIndex % this.baseMapUrls.length] + level + fullpath + ".png"; }; JSpec.prototype.getOverlayUrl =function (xIndex,yIndex,level) { return ""; }; JSpec.prototype.point2pixel =function (point,level,pixel) { if (!pixel) { pixel = new JPoint(); } var dp = this.distancePerPixel(level); pixel.set(Math.round((point.x - this.minX)/dp),Math.round((point.y - this.minY)/dp)); return pixel; }; JSpec.prototype.pixel2point =function (pixel,level,point) { if (!point) { point = new JPoint(); } var dp = this.distancePerPixel(level); point.set(Math.round(pixel.x*dp)+this.minX,Math.round(pixel.y*dp)+this.minY); return point; };