Skip to content

Commit 2869d46

Browse files
committed
优化非3857,4326投影下的TiledMapLayer偏移问题
1 parent ba7bef4 commit 2869d46

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

dist/iclient9-leaflet.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17858,9 +17858,17 @@ var TiledMapLayer = exports.TiledMapLayer = _leaflet2["default"].TileLayer.exten
1785817858
getDefaultScale: function getDefaultScale(coords) {
1785917859
var me = this,
1786017860
crs = me._crs;
17861+
if (crs.options && crs.options.scaleDenominators) {
17862+
return 1.0 / crs.options.scaleDenominators[coords.z];
17863+
}
17864+
if (crs.options && crs.options.scales) {
17865+
return crs.options.scales[coords.z];
17866+
}
1786117867
var resolution;
1786217868
if (crs.options && crs.options.resolutions) {
1786317869
resolution = crs.options.resolutions[coords.z];
17870+
} else if (crs._scales) {
17871+
resolution = 1 / crs._scales[coords.z];
1786417872
} else {
1786517873
var tileBounds = me._tileCoordsToBounds(coords);
1786617874
var ne = crs.project(tileBounds.getNorthEast());
@@ -84490,10 +84498,11 @@ var _Util = __webpack_require__(24);
8449084498

8449184499
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
8449284500

84493-
window.Proj4js = _proj2["default"]; /**
84494-
* Inspired by https://github.com/kartena/Proj4Leaflet
84495-
*/
84501+
window.proj4 = _proj2["default"]; /**
84502+
* Inspired by https://github.com/kartena/Proj4Leaflet
84503+
*/
8449684504

84505+
window.Proj4js = _proj2["default"];
8449784506
_leaflet2["default"].Proj = {};
8449884507

8449984508
_leaflet2["default"].Proj._isProj4Obj = function (a) {
@@ -84613,7 +84622,7 @@ var CRS = exports.CRS = _leaflet2["default"].Class.extend({
8461384622
_leaflet2["default"].Util.setOptions(this, options);
8461484623
this.code = code;
8461584624
this.transformation = this.options.transformation;
84616-
if (this.options.bounds) {}
84625+
8461784626
if (this.options.bounds) {
8461884627
this.options.bounds = _leaflet2["default"].bounds(this.options.bounds);
8461984628
}

dist/iclient9-leaflet.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/include-leaflet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
var excludes = (targetScript.getAttribute('exclude') || "").split(",");
3838
if (!inArray(excludes, 'leaflet')) {
3939
inputCSS("http://cdn.bootcss.com/leaflet/1.0.3/leaflet.css");
40-
inputScript("http://cdn.bootcss.com/leaflet/1.0.3/leaflet.js");
40+
inputScript("http://cdn.bootcss.com/leaflet/1.0.3/leaflet-src.js");
4141
}
4242
if (inArray(includes, 'mapv')) {
4343
inputScript("http://mapv.baidu.com/build/mapv.min.js");
@@ -52,7 +52,7 @@
5252
inputScript("http://cdn.bootcss.com/elasticsearch/13.0.1/elasticsearch.min.js");
5353
}
5454
if (!inArray(excludes, 'iclient9-leaflet')) {
55-
inputScript("../../dist/iclient9-leaflet.min.js");
55+
inputScript("../../dist/iclient9-leaflet.js");
5656
}
5757
if (inArray(includes, 'iclient9-leaflet-css')) {
5858
inputCSS("../../dist/iclient9-leaflet.min.css");

src/leaflet/core/Proj4Leaflet.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import L from "leaflet";
55
import proj4 from "proj4";
66
import {getMeterPerMapUnit} from "./Util";
77

8+
window.proj4 = proj4;
89
window.Proj4js = proj4;
910
L.Proj = {};
1011

@@ -126,9 +127,7 @@ export var CRS = L.Class.extend({
126127
L.Util.setOptions(this, options);
127128
this.code = code;
128129
this.transformation = this.options.transformation;
129-
if (this.options.bounds) {
130130

131-
}
132131
if (this.options.bounds) {
133132
this.options.bounds = L.bounds(this.options.bounds);
134133
}

src/leaflet/mapping/TiledMapLayer.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,17 @@ export var TiledMapLayer = L.TileLayer.extend({
127127
*/
128128
getDefaultScale: function (coords) {
129129
var me = this, crs = me._crs;
130+
if (crs.options && crs.options.scaleDenominators) {
131+
return 1.0 / crs.options.scaleDenominators[coords.z];
132+
}
133+
if (crs.options && crs.options.scales) {
134+
return crs.options.scales[coords.z];
135+
}
130136
var resolution;
131137
if (crs.options && crs.options.resolutions) {
132138
resolution = crs.options.resolutions[coords.z];
139+
} else if (crs._scales) {
140+
resolution = 1 / crs._scales[coords.z];
133141
} else {
134142
var tileBounds = me._tileCoordsToBounds(coords);
135143
var ne = crs.project(tileBounds.getNorthEast());

0 commit comments

Comments
 (0)