码迷,mamicode.com
首页 > 其他好文 > 详细

leaflet本地加载arcgis切片

时间:2018-06-11 23:36:44      阅读:322      评论:0      收藏:0      [点我收藏+]

标签:类型   val   value   prot   TE   @param   init   als   fun   

var origin = [-20037700, 33711400];//图层起点坐标  
var resolutions = [  
    8466.6836000338681, // Level 0  
    4233.341800016934, // Level 1  
    2116.670900008467, // Level 2  
    1058.3354500042335, // Level 3  
    529.16772500211675 // Level 4  
];  
var crs = new L.Proj.CRS(  
    ‘‘,   
    ‘+proj=cea +lon_0=0 +lat_ts=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs‘ , {  
        origin:  origin,  
        resolutions: resolutions  
    }  
);  
        var map = L.map(‘map‘,{  
    crs: crs,  
    continuousWorld: true,  
    worldCopyJump: false  
}).setView([23.39552, 113.308189], 0);  
var tileLayer = new L.TileLayer.TileLoad(‘http://localhost:8080/resources/china‘, {  
              maxZoom: resolutions.length - 1,  
              minZoom: 0,  
              continuousWorld: true  
          });  
tileLayer.addTo(map);  
/** 
 * 加载本地arcgis切片类 
 *  
 * @author ful 
 * @date 2014-09-03 
 * @copyright (c)  
 */  
  
/** 
 * 继承自TileLayer 
 * @param {Object} tomcat中映射该切片目录url 
 * @param {Object} options 
 */  
L.TileLayer.TileLoad = L.TileLayer.extend({  
    initialize: function (url, options) {  
        options = L.setOptions(this, options);  
        this.url = url + "/Layers/_alllayers/{z}/{x}/{y}.png";  
        L.TileLayer.prototype.initialize.call(this, this.url, options);  
    }  
});  
  
/** 
 * 重写TileLayer中获取切片url方法 
 * @param {Object} tilePoint 
 */  
L.TileLayer.prototype.getTileUrl = function(tilePoint) {  
    return L.Util.template(this._url, L.extend({  
        s: this._getSubdomain(tilePoint),  
        z: function() {  
            var value = tilePoint.z.toString(16);  
            return "L" + pad(value, 2);  
        },  
        x: function() {  
            var value = tilePoint.y.toString(16);  
            return "R" + pad(value, 8);  
        },  
        y: function() {  
            var value = tilePoint.x.toString(16);  
            return "C" + pad(value, 8);  
        }  
    }));  
};  
  
L.tileLayer.tileLoad = function(url, options){  
  return new L.TileLayer.TileLoad(url, options);  
};  
  
/** 
 * 高位补全方法 
 * @param {Object} 数字类型字符串 
 * @param {Object} 总位数,不足则高位补0 
 */  
var pad = function(numStr, n) {  
    var len = numStr.length;  
    while(len < n) {  
        numStr = "0" + numStr;  
        len++;    
    }  
    return numStr;  
};  

 

leaflet本地加载arcgis切片

标签:类型   val   value   prot   TE   @param   init   als   fun   

原文地址:https://www.cnblogs.com/lishanyang/p/9170352.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!