/* Copyright (c) 2006-2013 by OpenLayers Contributors (see authors.txt for * full list of contributors). Published under the 2-clause BSD license. * See license.txt in the OpenLayers distribution or repository for the * full text of the license. */ /** * @requires OpenLayers/Layer/XYZ.js */ /** * Class: OpenLayers.Layer.OpenmateXYZ * Create a layer for accessing tiles from services that conform with the * Tile Map Service Specification * (http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification). * * Example: * (code) * var layer = new OpenLayers.Layer.XYZ( * "My Layer", // name for display in LayerSwitcher * "http://tilecache.osgeo.org/wms-c/Basic.py/", // service endpoint * {layername: "basic", type: "png"} // required properties * ); * (end) * * Inherits from: * - */ //웹맵 타일 시스템 사용하기 이전의 오래된 타일 시스템 지원 OpenLayers.Layer.OpenmateXYZ = OpenLayers.Class(OpenLayers.Layer.XYZ, { initialize: function(name, url, options) { if(Array.isArray(url)) { this.url = url; } else { this.url = []; this.url[0] = url; } var newArguments = []; options["projection"] = "EPSG:900913"; // options["displayProjection"] = new OpenLayers.Projection("EPSG:4326"); // 전국 // options["maxResolution"] = 1222.9924525624949; // options["numZoomLevels"] = 12; // options["zoomOffset"] = 7; // 강남구 데모 options["maxResolution"] = OpenMap.Config.maxResolution;// 38.21851414253662; options["numZoomLevels"] = OpenMap.Config.numZoomLevels; //7; //강남구 데모. 줄이면 zoom-in 제한된다. options["zoomOffset"] = OpenMap.Config.zoomOffset;// 12 options["singleTile"] = options["singleTile"] | false; //restrictedExtent : new OpenLayers.Bounds(13814748.805522, 3868787.29756, 14694172.782667, 4678789.7959737), //mapCetner : new OpenLayers.LonLat(126.977969, 37.566535), newArguments.push(name, this.url, options); // this.zoomOffset = 7; OpenLayers.Layer.XYZ.prototype.initialize.apply(this, newArguments); /* Map Example * var url = 'http://192.168.0.46/arcgiscache01/tilemap_webmap/Layers/_alllayers/${z}/${y}/${x}.png'; * layer = new OpenLayers.Layer.OpenmateXYZ("XYZ", url, { layername : 'openmate base', isBaseLayer : true }); * vlayer = new OpenLayers.Layer.Vector( "Editable" ); * map = new OpenLayers.Map( 'map', { layers : [layer, vlayer], * restrictedExtent : new OpenLayers.Bounds(13814748.805522, 3868787.29756, 14694172.782667, 4678789.7959737), * numZoomLevels:12, * projection : "EPSG:900913", * displayProjection : new OpenLayers.Projection("EPSG:4326"), * mapCetner : new OpenLayers.LonLat(126.977969, 37.566535), * maxResolution:1222.9924525624949, * } ); */ this.layerProperty = {LAYER_NM:"배경지도",LAYER_ID:"_BASE_MAP_",LAYER_TYPE:'BASEMAP'}; }, getName : function() { return this.layerProperty.LAYER_NM; }, getLayerId : function() { return this.layerProperty.LAYER_ID; }, // getDynamicLayerUrl : function(bounds, server, layerId) { // return OpenLayers.String.format( // this.dynamicUrl, // this.my_url_xyz(bounds, server, layerId)); // }, /** * APIMethod: clone * Create a complete copy of this layer. * * Parameters: * obj - {Object} Should only be provided by subclasses that call this * method. * * Returns: * {} An exact clone of this */ clone: function (obj) { if (obj == null) { obj = new OpenLayers.Layer.OpenmateXYZ(this.name, this.url, this.getOptions()); } //get all additions from superclasses obj = OpenLayers.Layer.XYZ.prototype.clone.apply(this, [obj]); // copy/set any non-init, non-simple values here return obj; }, zeroPad: function(num, len, radix) { var str = num.toString(radix || 10); while (str.length < len) { str = "0" + str; } return str; }, /** * Method: getURL * * Parameters: * bounds - {} * * Returns: * {String} A string with the layer's url and parameters and also the * passed-in bounds and appropriate tile size specified as * parameters */ getURL: function (bounds) { var xyz = this.getXYZ(bounds); var serverIndex = Math.abs((xyz.x + xyz.y) % this.url.length); xyz.x = 'C' + this.zeroPad(xyz.x, 8, 16); xyz.y = 'R' + this.zeroPad(xyz.y, 8, 16); xyz.z = 'L' + this.zeroPad(xyz.z, 2, 10); return OpenLayers.String.format( this.url[serverIndex], xyz); }, /** * Method: setMap * When the layer is added to a map, then we can fetch our origin * (if we don't have one.) * * Parameters: * map - {} */ setMap: function(map) { OpenLayers.Layer.XYZ.prototype.setMap.apply(this, arguments); if (!this.tileOrigin) { var org = new OpenLayers.LonLat(this.map.maxExtent.left, this.map.maxExtent.bottom); this.tileOrigin = org.transform("EPSG:4326", "OPENMATE"); } }, /** * Method: omprint * * Parameters: * zoom - {Number} * minX - {Number} * minY - {Number} * maxX - {Number} * maxY - {Number} */ omprint: function(zoom, minX, minY, maxX, maxY) { return [{ 'type': 'basemap', 'opacity': this.opacity, 'url': this.url, 'formatX': 'C%08x', 'formatY': 'R%08x', 'formatZ': 'L%d' }]; }, CLASS_NAME: "OpenLayers.Layer.OpenmateXYZ" });