Skip to content

Commit 071b846

Browse files
committed
优化leaflet投影转换算法 fix客户端专题图在大比例尺下偏移的问题
1 parent d8bcdfd commit 071b846

File tree

4 files changed

+12
-112
lines changed

4 files changed

+12
-112
lines changed

dist/iclient9-leaflet.js

Lines changed: 6 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -27941,9 +27941,9 @@ var ThemeLayer = exports.ThemeLayer = _leaflet2["default"].Layer.extend({
2794127941
var me = this;
2794227942
var latLngBounds = me._map.getBounds();
2794327943
me.update(latLngBounds);
27944-
var bounds = new _leaflet2["default"].Bounds(me._map.latLngToLayerPoint(latLngBounds.getNorthWest()), me._map.latLngToLayerPoint(latLngBounds.getSouthEast()));
27945-
var size = bounds.getSize();
27946-
_leaflet2["default"].DomUtil.setPosition(me.container, bounds.min);
27944+
var topLeft = me._map.containerPointToLayerPoint([0, 0]);
27945+
_leaflet2["default"].DomUtil.setPosition(me.container, topLeft);
27946+
var size = me._map.getSize();
2794727947
me.container.style.width = size.x + 'px';
2794827948
me.container.style.height = size.y + 'px';
2794927949
},
@@ -85117,6 +85117,8 @@ _leaflet2["default"].Proj.Projection = _leaflet2["default"].Class.extend({
8511785117
* @return {LatLng} 返回经纬度坐标
8511885118
*/
8511985119
unproject: function unproject(point, unbounded) {
85120+
point.x = point.x < this.bounds.min.x ? this.bounds.min.x : point.x > this.bounds.max.x ? this.bounds.max.x : point.x;
85121+
point.y = point.y < this.bounds.min.y ? this.bounds.min.y : point.y > this.bounds.max.y ? this.bounds.max.y : point.y;
8512085122
var point2 = this._proj.inverse([point.x, point.y]);
8512185123
return new _leaflet2["default"].LatLng(point2[1], point2[0], unbounded);
8512285124
},
@@ -93970,108 +93972,7 @@ exports.names = ["Van_der_Grinten_I", "VanDerGrinten", "vandg"];
9397093972
/* 466 */
9397193973
/***/ (function(module, exports) {
9397293974

93973-
module.exports = {
93974-
"_from": "proj4@2.3.15",
93975-
"_id": "proj4@2.3.15",
93976-
"_inBundle": false,
93977-
"_integrity": "sha1-WtBui8owvg/6OJpJ5FZfUfBtCJ4=",
93978-
"_location": "/proj4",
93979-
"_phantomChildren": {},
93980-
"_requested": {
93981-
"type": "version",
93982-
"registry": true,
93983-
"raw": "proj4@2.3.15",
93984-
"name": "proj4",
93985-
"escapedName": "proj4",
93986-
"rawSpec": "2.3.15",
93987-
"saveSpec": null,
93988-
"fetchSpec": "2.3.15"
93989-
},
93990-
"_requiredBy": [
93991-
"/"
93992-
],
93993-
"_resolved": "http://registry.npm.taobao.org/proj4/download/proj4-2.3.15.tgz",
93994-
"_shasum": "5ad06e8bca30be0ffa389a49e4565f51f06d089e",
93995-
"_spec": "proj4@2.3.15",
93996-
"_where": "F:\\dev\\iClient",
93997-
"author": "",
93998-
"bugs": {
93999-
"url": "https://github.com/proj4js/proj4js/issues"
94000-
},
94001-
"bundleDependencies": false,
94002-
"contributors": [
94003-
{
94004-
"name": "Mike Adair",
94005-
"email": "madair@dmsolutions.ca"
94006-
},
94007-
{
94008-
"name": "Richard Greenwood",
94009-
"email": "rich@greenwoodmap.com"
94010-
},
94011-
{
94012-
"name": "Calvin Metcalf",
94013-
"email": "calvin.metcalf@gmail.com"
94014-
},
94015-
{
94016-
"name": "Richard Marsden",
94017-
"url": "http://www.winwaed.com"
94018-
},
94019-
{
94020-
"name": "T. Mittan"
94021-
},
94022-
{
94023-
"name": "D. Steinwand"
94024-
},
94025-
{
94026-
"name": "S. Nelson"
94027-
}
94028-
],
94029-
"dependencies": {
94030-
"mgrs": "~0.0.2"
94031-
},
94032-
"deprecated": false,
94033-
"description": "Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.",
94034-
"devDependencies": {
94035-
"browserify": "~12.0.1",
94036-
"chai": "~1.8.1",
94037-
"curl": "git://github.com/cujojs/curl.git",
94038-
"grunt": "~0.4.2",
94039-
"grunt-browserify": "~4.0.1",
94040-
"grunt-cli": "~0.1.13",
94041-
"grunt-contrib-connect": "~0.6.0",
94042-
"grunt-contrib-jshint": "~0.8.0",
94043-
"grunt-contrib-uglify": "~0.11.1",
94044-
"grunt-mocha-phantomjs": "~0.4.0",
94045-
"istanbul": "~0.2.4",
94046-
"mocha": "~1.17.1",
94047-
"tin": "~0.4.0"
94048-
},
94049-
"directories": {
94050-
"test": "test",
94051-
"doc": "docs"
94052-
},
94053-
"homepage": "https://github.com/proj4js/proj4js#readme",
94054-
"jam": {
94055-
"main": "dist/proj4.js",
94056-
"include": [
94057-
"dist/proj4.js",
94058-
"README.md",
94059-
"AUTHORS",
94060-
"LICENSE.md"
94061-
]
94062-
},
94063-
"license": "MIT",
94064-
"main": "lib/index.js",
94065-
"name": "proj4",
94066-
"repository": {
94067-
"type": "git",
94068-
"url": "git://github.com/proj4js/proj4js.git"
94069-
},
94070-
"scripts": {
94071-
"test": "./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"
94072-
},
94073-
"version": "2.3.15"
94074-
};
93975+
module.exports = {"_args":[[{"raw":"proj4@2.3.15","scope":null,"escapedName":"proj4","name":"proj4","rawSpec":"2.3.15","spec":"2.3.15","type":"version"},"E:\\git\\iClient9"]],"_from":"proj4@2.3.15","_id":"proj4@2.3.15","_inCache":true,"_location":"/proj4","_nodeVersion":"6.1.0","_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/proj4-2.3.15.tgz_1471808262546_0.6752060337457806"},"_npmUser":{"name":"ahocevar","email":"andreas.hocevar@gmail.com"},"_npmVersion":"3.8.6","_phantomChildren":{},"_requested":{"raw":"proj4@2.3.15","scope":null,"escapedName":"proj4","name":"proj4","rawSpec":"2.3.15","spec":"2.3.15","type":"version"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/proj4/-/proj4-2.3.15.tgz","_shasum":"5ad06e8bca30be0ffa389a49e4565f51f06d089e","_shrinkwrap":null,"_spec":"proj4@2.3.15","_where":"E:\\git\\iClient9","author":"","bugs":{"url":"https://github.com/proj4js/proj4js/issues"},"contributors":[{"name":"Mike Adair","email":"madair@dmsolutions.ca"},{"name":"Richard Greenwood","email":"rich@greenwoodmap.com"},{"name":"Calvin Metcalf","email":"calvin.metcalf@gmail.com"},{"name":"Richard Marsden","url":"http://www.winwaed.com"},{"name":"T. Mittan"},{"name":"D. Steinwand"},{"name":"S. Nelson"}],"dependencies":{"mgrs":"~0.0.2"},"description":"Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.","devDependencies":{"browserify":"~12.0.1","chai":"~1.8.1","curl":"git://github.com/cujojs/curl.git","grunt":"~0.4.2","grunt-browserify":"~4.0.1","grunt-cli":"~0.1.13","grunt-contrib-connect":"~0.6.0","grunt-contrib-jshint":"~0.8.0","grunt-contrib-uglify":"~0.11.1","grunt-mocha-phantomjs":"~0.4.0","istanbul":"~0.2.4","mocha":"~1.17.1","tin":"~0.4.0"},"directories":{"test":"test","doc":"docs"},"dist":{"shasum":"5ad06e8bca30be0ffa389a49e4565f51f06d089e","tarball":"https://registry.npmjs.org/proj4/-/proj4-2.3.15.tgz"},"gitHead":"9fa5249c1f4183d5ddee3c4793dfd7b9f29f1886","homepage":"https://github.com/proj4js/proj4js#readme","jam":{"main":"dist/proj4.js","include":["dist/proj4.js","README.md","AUTHORS","LICENSE.md"]},"license":"MIT","main":"lib/index.js","maintainers":[{"name":"cwmma","email":"calvin.metcalf@gmail.com"},{"name":"ahocevar","email":"andreas.hocevar@gmail.com"}],"name":"proj4","optionalDependencies":{},"readme":"ERROR: No README data found!","repository":{"type":"git","url":"git://github.com/proj4js/proj4js.git"},"scripts":{"test":"./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"},"version":"2.3.15"}
9407593976

9407693977
/***/ }),
9407793978
/* 467 */

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.

src/leaflet/core/Proj4Leaflet.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ L.Proj.Projection = L.Class.extend({
5353
* @return {LatLng} 返回经纬度坐标
5454
*/
5555
unproject: function (point, unbounded) {
56+
point.x = point.x < this.bounds.min.x ? this.bounds.min.x : (point.x > this.bounds.max.x ? this.bounds.max.x : point.x );
57+
point.y = point.y < this.bounds.min.y ? this.bounds.min.y : (point.y > this.bounds.max.y ? this.bounds.max.y : point.y);
5658
var point2 = this._proj.inverse([point.x, point.y]);
5759
return new L.LatLng(point2[1], point2[0], unbounded);
5860
},

src/leaflet/overlay/theme/ThemeLayer.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,9 @@ export var ThemeLayer = L.Layer.extend({
434434
var me = this;
435435
var latLngBounds = me._map.getBounds();
436436
me.update(latLngBounds);
437-
var bounds = new L.Bounds(
438-
me._map.latLngToLayerPoint(latLngBounds.getNorthWest()),
439-
me._map.latLngToLayerPoint(latLngBounds.getSouthEast())
440-
);
441-
var size = bounds.getSize();
442-
L.DomUtil.setPosition(me.container, bounds.min);
437+
var topLeft = me._map.containerPointToLayerPoint([0, 0]);
438+
L.DomUtil.setPosition(me.container, topLeft);
439+
var size = me._map.getSize();
443440
me.container.style.width = size.x + 'px';
444441
me.container.style.height = size.y + 'px';
445442
},

0 commit comments

Comments
 (0)