123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572 |
- // this L.CRS.Baidu from https://github.com/muyao1987/leaflet-tileLayer-baidugaode/blob/master/src/tileLayer.baidu.js
- if (L.Proj) {
- L.CRS.Baidu = new L.Proj.CRS('EPSG:900913', '+proj=merc +a=6378206 +b=6356584.314245179 +lat_ts=0.0 +lon_0=0.0 +x_0=0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', {
- resolutions: function () {
- level = 19
- var res = [];
- res[0] = Math.pow(2, 18);
- for (var i = 1; i < level; i++) {
- res[i] = Math.pow(2, (18 - i))
- }
- return res;
- }(),
- origin: [0, 0],
- bounds: L.bounds([20037508.342789244, 0], [0, 20037508.342789244])
- });
- }
- L.TileLayer.ChinaProvider = L.TileLayer.extend({
- initialize: function(type, options) { // (type, Object)
- var providers = L.TileLayer.ChinaProvider.providers;
- options = options || {}
- var parts = type.split('.');
- var providerName = parts[0];
- var mapName = parts[1];
- var mapType = parts[2];
- var url = providers[providerName][mapName][mapType];
- function getcookie(objname){
- var arrstr = document.cookie.split("; ");
- for(var i=0;i<arrstr.length;i++){
- var temp = arrstr[i].split("=");
- if(temp[0]==objname)return unescape(temp[1]);
- }
- }
- var login_apikey = localStorage.apikey;
- //如果当前用户没有apikey则取配置中的默认key
- if(typeof(login_apikey) === 'undefined'){
- login_apikey = providers[providerName].key;
- }
- //url += "?apikey=" + login_apikey;
-
- options.subdomains = providers[providerName].Subdomains;
- //options.key = options.key || providers[providerName].key;
- options.key = options.key || login_apikey;
- if ('tms' in providers[providerName]) {
- options.tms = providers[providerName]['tms']
- }
- L.TileLayer.prototype.initialize.call(this, url, options);
- }
- });
- //
- L.TileLayer.ChinaProvider.providers = {
- TianDiTu: {
- Normal: {
- Map: "http://{s}.map.jms.gd/tile/tiandi/{z}/{x}/{y}.png?apikey={key}",
- Annotion: "http://{s}.map.jms.gd/tile/tiandi_cva/{z}/{x}/{y}.png?apikey={key}",
- Ibo: "http://{s}.map.jms.gd/tile/tiandi_ibo/{z}/{x}/{y}.png?apikey={key}",
- Mycva: "http://{s}.map.jms.gd/tile/tdt/{z}/{x}/{y}.png?apikey={key}",
- },
- Satellite: {
- Map: "http://{s}.map.jms.gd/tile/tiandi_wx/{z}/{x}/{y}.png?apikey={key}",
- },
- Terrain: {
- Map: "http://a.map.jms.gd/tile/tiandi_ter/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- GaoDe: {
- Normal: {
- Map: 'http://{s}.map.jms.gd/tile/shiliang/{z}/{x}/{y}.png?apikey={key}',
- XiangTu: 'http://{s}.map.jms.gd/tile/gd_xiangtu/{z}/{x}/{y}.png?apikey={key}',
- XiangTuGray: 'http://{s}.map.jms.gd/tile/gd_xiangtu_gray/{z}/{x}/{y}.png?apikey={key}',
- WuWenZi: 'http://{s}.map.jms.gd/tile/gd_wuwenzi/{z}/{x}/{y}.png?apikey={key}',
- LuWang: 'http://{s}.map.jms.gd/tile/luwang/{z}/{x}/{y}.png?apikey={key}',
- DiBiao: 'http://{s}.map.jms.gd/tile/gd_dibiao/{z}/{x}/{y}.png?apikey={key}',
- Test: "http://{s}.map.jms.gd/tile/test/{z}/{x}/{y}.png?apikey={key}",
- },
- Satellite: {
- Map: 'http://{s}.map.jms.gd/tile/weixing/{z}/{x}/{y}.png?apikey={key}'
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Pengjiang: {
- Normal: {
- Map: "http://{s}.map.jms.gd/tile/pengjiang/{z}/{x}/{y}.png?apikey={key}"
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Taishan: {
- Normal: {
- Map: "http://{s}.map.jms.gd/tile/taishan/{z}/{x}/{y}.png?apikey={key}"
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Test: {
- Normal: {
- Test: "http://f.map.jms.gd/tile/test/{z}/{x}/{y}.png?apikey={key}",
- Test1: "http://f.map.jms.gd/tile/test1/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Guangzhou: {
- Normal: {
- Hdpi: "http://{s}.map.jms.gd/tile/gz_hdpi/{z}/{x}/{y}.png?apikey={key}"
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
-
- Google: {
- Normal: {
- Map: "",
- },
- Satellite: {
- Map: "http://{s}.map.jms.gd/tile/google_s/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- GoogleCn: {
- Normal: {
- Map: "http://{s}.map.jms.gd/tile/google/{z}/{x}/{y}.png?apikey={key}",
- Terrain: "http://{s}.map.jms.gd/tile/google_dx/{z}/{x}/{y}.png?apikey={key}",
- Annotion: "http://{s}.map.jms.gd/tile/google_h/{z}/{x}/{y}.png?apikey={key}",
- Ter: "http://{s}.map.jms.gd/tile/google_t/{z}/{x}/{y}.png?apikey={key}",
- },
- Satellite: {
- Map: "http://{s}.map.jms.gd/tile/google_s/{z}/{x}/{y}.png?apikey={key}",
- Annotion: "http://{s}.map.jms.gd/tile/google_wx/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Tengxun: {
- Normal: {
- Map: "http://{s}.map.jms.gd/tile/tengxun/{z}/{x}/{y}.png?apikey={key}",
- Map9: "http://{s}.map.jms.gd/tile/tengxun_9/{z}/{x}/{y}.png?apikey={key}",
- Map8: "http://{s}.map.jms.gd/tile/tengxun_8/{z}/{x}/{y}.png?apikey={key}",
- Map4: "http://f.map.jms.gd/tile/tengxun_4/{z}/{x}/{y}.png?apikey={key}",
- Map3: "http://{s}.map.jms.gd/tile/tengxun_3/{z}/{x}/{y}.png?apikey={key}",
- Map2: "http://{s}.map.jms.gd/tile/tengxun_2/{z}/{x}/{y}.png?apikey={key}",
- Map1: "http://{s}.map.jms.gd/tile/tengxun_1/{z}/{x}/{y}.png?apikey={key}",
- },
- Satellite: {
- Map: "http://{s}.map.jms.gd/tile/tengxun_wx/{z}/{x}/{y}.png?apikey={key}"
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Carto: {
- Normal: {
- Map: "http://{s}.map.jms.gd/tile/carto_label/{z}/{x}/{y}.png?apikey={key}",
- Light: "http://{s}.map.jms.gd/tile/railmap/{z}/{x}/{y}.png?apikey={key}",
- Dark: "http://{s}.map.jms.gd/tile/carto_dark/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Thunderforest: {
- Normal: {
- Opencyclemap: "http://{s}.map.jms.gd/tile/opencyclemap/{z}/{x}/{y}.png?apikey={key}",
- Transport: "http://{s}.map.jms.gd/tile/transport/{z}/{x}/{y}.png?apikey={key}",
- Landscape: "http://{s}.map.jms.gd/tile/landscape/{z}/{x}/{y}.png?apikey={key}",
- Mobile: "http://{s}.map.jms.gd/tile/mobile-atlas/{z}/{x}/{y}.png?apikey={key}",
- Pioneer: "http://{s}.map.jms.gd/tile/pioneer/{z}/{x}/{y}.png?apikey={key}",
- Neighbourhood: "http://{s}.map.jms.gd/tile/neighbourhood/{z}/{x}/{y}.png?apikey={key}",
- Outdoors: "http://{s}.map.jms.gd/tile/outdoors/{z}/{x}/{y}.png?apikey={key}",
- Atlas: "http://{s}.map.jms.gd/tile/atlas/{z}/{x}/{y}.png?apikey={key}",
- TransportDark: "http://{s}.map.jms.gd/tile/transport-dark/{z}/{x}/{y}.png?apikey={key}",
- Spinal: "http://{s}.map.jms.gd/tile/spinal-map/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- OSM: {
- Normal: {
- Map: "http://{s}.map.jms.gd/tile/osm/{z}/{x}/{y}.png?apikey={key}",
- Topo: "http://{s}.map.jms.gd/tile/osm_topo/{z}/{x}/{y}.png?apikey={key}",
- Openstreetmap: "http://{s}.map.jms.gd/tile/openstreetmap/{z}/{x}/{y}.png?apikey={key}",
- winter: "http://{s}.map.jms.gd/tile/osm_winter/{z}/{x}/{y}.png?apikey={key}",
- summer: "http://{s}.map.jms.gd/tile/osm_summer/{z}/{x}/{y}.png?apikey={key}",
- cycling: "http://{s}.map.jms.gd/tile/osm_cycling/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Opentopomap: {
- Normal: {
- Map: "http://{s}.map.jms.gd/tile/opentopomap/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Baidu: {
- Normal: {
- Map: 'http://{s}.map.jms.gd/tile/baidu/{z}/{x}/{y}.png?apikey={key}'
- },
- Satellite: {
- Map: 'http://{s}.map.jms.gd/tile/baidu_wx/{z}/{x}/{y}.png?apikey={key}',
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118",
- tms: true
- },
- Openrailway: {
- Normal: {
- Map: "http://{s}.map.jms.gd/tile/openrailway/{z}/{x}/{y}.png?apikey={key}",
- Maxspeed: "http://{s}.map.jms.gd/tile/openrailway_maxspeed/{z}/{x}/{y}.png?apikey={key}",
- Elec: "http://{s}.map.jms.gd/tile/openrailway_elec/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Stadia: {
- Normal: {
- Alidade_smooth: "http://{s}.map.jms.gd/tile/alidade_smooth/{z}/{x}/{y}.png?apikey={key}",
- Watercolor: "http://{s}.map.jms.gd/tile/stamen_watercolor/{z}/{x}/{y}.jpg?apikey={key}",
- Terrain: "http://{s}.map.jms.gd/tile/stamen_terrain/{z}/{x}/{y}.png?apikey={key}",
- Toner: "http://{s}.map.jms.gd/tile/stamen_toner/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- ArcgisCn: {
- Normal: {
- Community: "http://{s}.map.jms.gd/tile/arcgis_comm/{z}/{x}/{y}.png?apikey={key}",
- Gray: "http://{s}.map.jms.gd/tile/arcgis_gray/{z}/{x}/{y}.jpg?apikey={key}",
- Blue: "http://{s}.map.jms.gd/tile/arcgis_blue/{z}/{x}/{y}.png?apikey={key}",
- Warm: "http://{s}.map.jms.gd/tile/arcgis_warm/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Arcgis: {
- Normal: {
- Street: "http://{s}.map.jms.gd/tile/arcgis_world_street/{z}/{x}/{y}.png?apikey={key}",
- Hillshade: "http://{s}.map.jms.gd/tile/arcgis_world_hillshade/{z}/{x}/{y}.png?apikey={key}",
- },
- Satellite: {
- Map: "http://{s}.map.jms.gd/tile/arcgis_world_imagery/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Jl1: {
- Normal: {
- Map: "http://{s}.map.jms.gd/tile/jl1_2022/{z}/{x}/{y}.png?apikey={key}",
- Map2023: "http://{s}.map.jms.gd/tile/jl1_2023/{z}/{x}/{y}.png?apikey={key}",
- Map2024: "http://{s}.map.jms.gd/tile/jl1_2024/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Geovis: {
- Normal: {
- Base: "http://{s}.map.jms.gd/tile/geovis_base/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Stamen: {
- Terrain: {
- Lines: "http://{s}.map.jms.gd/tile/stamen_terrain_lines/{z}/{x}/{y}.png?apikey={key}",
- },
- Toner: {
- Lines: "http://{s}.map.jms.gd/tile/stamen_toner_lines/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- BingCn: {
- Normal: {
- Map: "http://{s}.map.jms.gd/tile/bing/{z}/{x}/{y}.png?apikey={key}",
- Dark: "http://{s}.map.jms.gd/tile/bing_dark/{z}/{x}/{y}.png?apikey={key}",
- Cf: "http://{s}.map.jms.gd/tile/bing_cf/{z}/{x}/{y}.png?apikey={key}", //实时路况
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Bing: {
- Satellite: {
- Map: "http://{s}.map.jms.gd/tile/bing_aerial/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Jiangmen: {
- Normal: {
- Map: "http://68.196.3.198/map/mapimg/tile/{z}/{x}/{y}?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Maptiler: {
- Normal: {
- basic: "http://{s}.map.jms.gd/tile/maptiler_basic/{z}/{x}/{y}.png?apikey={key}",
- backdrop: "http://{s}.map.jms.gd/tile/maptiler_backdrop/{z}/{x}/{y}.png?apikey={key}",
- streets: "http://{s}.map.jms.gd/tile/maptiler_streets/{z}/{x}/{y}.png?apikey={key}",
- winter: "http://{s}.map.jms.gd/tile/maptiler_winter/{z}/{x}/{y}.png?apikey={key}",
- ocean: "http://{s}.map.jms.gd/tile/maptiler_ocean/{z}/{x}/{y}.png?apikey={key}",
- toner: "http://{s}.map.jms.gd/tile/maptiler_toner/{z}/{x}/{y}.png?apikey={key}",
- topo: "http://{s}.map.jms.gd/tile/maptiler_topo/{z}/{x}/{y}.png?apikey={key}",
- dataviz: "http://{s}.map.jms.gd/tile/maptiler_dataviz/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- mapbox: {
- Normal: {
- mapbox01: "http://{s}.map.jms.gd/tile/mapbox01/{z}/{x}/{y}.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- Nothing: {
- Normal: {
- Map: "http://map.jms.gd/static/img/512.png?apikey={key}",
- },
- Subdomains: ["a", "b", "c", "d"],
- key: "jm20240118"
- },
- };
- L.tileLayer.chinaProvider = function(type, options) {
- return new L.TileLayer.ChinaProvider(type, options);
- };
- //坐标转换
- L.CoordConver = function () {
- /**百度转84*/
- this.bd09_To_gps84 = function(lng, lat) {
- var gcj02 = this.bd09_To_gcj02(lng, lat);
- var map84 = this.gcj02_To_gps84(gcj02.lng, gcj02.lat);
- return map84;
- }
- /**84转百度*/
- this.gps84_To_bd09 = function (lng, lat) {
- var gcj02 = this.gps84_To_gcj02(lng, lat);
- var bd09 = this.gcj02_To_bd09(gcj02.lng, gcj02.lat);
- return bd09;
- }
- /**84转火星*/
- this.gps84_To_gcj02 = function (lng, lat) {
- var dLat = transformLat(lng - 105.0, lat - 35.0);
- var dLng = transformLng(lng - 105.0, lat - 35.0);
- var radLat = lat / 180.0 * pi;
- var magic = Math.sin(radLat);
- magic = 1 - ee * magic * magic;
- var sqrtMagic = Math.sqrt(magic);
- dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
- dLng = (dLng * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
- var mgLat = lat + dLat;
- var mgLng = lng + dLng;
- var newCoord = {
- lng: mgLng,
- lat: mgLat
- };
- return newCoord;
- }
- /**火星转84*/
- this.gcj02_To_gps84 = function (lng, lat) {
- var coord = transform(lng, lat);
- var lontitude = lng * 2 - coord.lng;
- var latitude = lat * 2 - coord.lat;
- var newCoord = {
- lng: lontitude,
- lat: latitude
- };
- return newCoord;
- }
- /**火星转百度*/
- this.gcj02_To_bd09 = function (x, y) {
- var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
- var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
- var bd_lng = z * Math.cos(theta) + 0.0065;
- var bd_lat = z * Math.sin(theta) + 0.006;
- var newCoord = {
- lng: bd_lng,
- lat: bd_lat
- };
- return newCoord;
- }
- /**百度转火星*/
- this.bd09_To_gcj02 = function (bd_lng, bd_lat) {
- var x = bd_lng - 0.0065;
- var y = bd_lat - 0.006;
- var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
- var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
- var gg_lng = z * Math.cos(theta);
- var gg_lat = z * Math.sin(theta);
- var newCoord = {
- lng: gg_lng,
- lat: gg_lat
- };
- return newCoord;
- }
- var pi = 3.1415926535897932384626;
- var a = 6378245.0;
- var ee = 0.00669342162296594323;
- var x_pi = pi * 3000.0 / 180.0;
- var R = 6378137;
- function transform(lng, lat) {
- var dLat = transformLat(lng - 105.0, lat - 35.0);
- var dLng = transformLng(lng - 105.0, lat - 35.0);
- var radLat = lat / 180.0 * pi;
- var magic = Math.sin(radLat);
- magic = 1 - ee * magic * magic;
- var sqrtMagic = Math.sqrt(magic);
- dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
- dLng = (dLng * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
- var mgLat = lat + dLat;
- var mgLng = lng + dLng;
- var newCoord = {
- lng: mgLng,
- lat: mgLat
- };
- return newCoord;
- }
- function transformLat(x, y) {
- var ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
- ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
- ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
- ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
- return ret;
- }
- function transformLng(x, y) {
- var ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
- ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
- ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
- ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0;
- return ret;
- }
- }
- L.coordConver = function () {
- return new L.CoordConver()
- }
- L.tileLayer.chinaProvider = function (type, options) {
- options = options || {}
- options.corrdType = getCorrdType(type);
- return new L.TileLayer.ChinaProvider(type, options);
- //获取坐标类型
- function getCorrdType(type) {
- var parts = type.split('.');
- var providerName = parts[0];
- var zbName = "wgs84"
- switch (providerName) {
- case "Tengxun":
- case "GaoDe":
- case "Pengjiang":
- case "GoogleCn": //google中国地图
- case "ArcgisCn":
- case "BingCn":
- case "Test":
- zbName = "gcj02";
- break;
- case "Baidu":
- zbName = "bd09";
- break;
- case "Carto":
- case "Thunderforest":
- case "OSM":
- case "TianDiTu":
- case "Jl1":
- case "Openrailway":
- case "Bing":
- case "Jiangmen":
- case "Google":
- case "mapbox":
- zbName = "wgs84";
- break;
- }
- return zbName;
- }
- };
- L.GridLayer.include({
- _setZoomTransform: function (level, _center, zoom) {
- var center = _center;
- if (center != undefined && this.options) {
- if (this.options.corrdType == 'gcj02') {
- center = L.coordConver().gps84_To_gcj02(_center.lng, _center.lat);
- } else if (this.options.corrdType == 'bd09') {
- center = L.coordConver().gps84_To_bd09(_center.lng, _center.lat);
- }
- }
- var scale = this._map.getZoomScale(zoom, level.zoom),
- translate = level.origin.multiplyBy(scale)
- .subtract(this._map._getNewPixelOrigin(center, zoom)).round();
- if (L.Browser.any3d) {
- L.DomUtil.setTransform(level.el, translate, scale);
- } else {
- L.DomUtil.setPosition(level.el, translate);
- }
- },
- _getTiledPixelBounds: function (_center) {
- var center = _center;
- if (center != undefined && this.options) {
- if (this.options.corrdType == 'gcj02') {
- center = L.coordConver().gps84_To_gcj02(_center.lng, _center.lat);
- } else if (this.options.corrdType == 'bd09') {
- center = L.coordConver().gps84_To_bd09(_center.lng, _center.lat);
- }
- }
- var map = this._map,
- mapZoom = map._animatingZoom ? Math.max(map._animateToZoom, map.getZoom()) : map.getZoom(),
- scale = map.getZoomScale(mapZoom, this._tileZoom),
- pixelCenter = map.project(center, this._tileZoom).floor(),
- halfSize = map.getSize().divideBy(scale * 2);
- return new L.Bounds(pixelCenter.subtract(halfSize), pixelCenter.add(halfSize));
- }
- })
|