Skip to content

Commit ddec627

Browse files
committed
【fix】修复leaflet设置可见比例尺时,手机端用双指缩放时,超出最大最小级别时出错的问题 review by liqian
1 parent 66c0bee commit ddec627

File tree

5 files changed

+120
-93
lines changed

5 files changed

+120
-93
lines changed

dist/leaflet/iclient9-leaflet-es6.js

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -68177,9 +68177,8 @@ window.proj4 = lib_default.a;
6817768177
window.Proj4js = lib_default.a;
6817868178
external_L_default.a.Proj = {};
6817968179

68180-
external_L_default.a.Proj._isProj4Obj = function (a) {
68181-
return (typeof a.inverse !== 'undefined' &&
68182-
typeof a.forward !== 'undefined');
68180+
external_L_default.a.Proj._isProj4Obj = function(a) {
68181+
return typeof a.inverse !== 'undefined' && typeof a.forward !== 'undefined';
6818368182
};
6818468183

6818568184
/**
@@ -68193,8 +68192,7 @@ external_L_default.a.Proj._isProj4Obj = function (a) {
6819368192
* @param {L.bounds} bounds - 投影范围参数
6819468193
*/
6819568194
external_L_default.a.Proj.Projection = external_L_default.a.Class.extend({
68196-
68197-
initialize: function (code, def, bounds) {
68195+
initialize: function(code, def, bounds) {
6819868196
var isP4 = external_L_default.a.Proj._isProj4Obj(code);
6819968197
this._proj = isP4 ? code : this._projFromCodeDef(code, def);
6820068198
var boundsOption = bounds;
@@ -68210,7 +68208,7 @@ external_L_default.a.Proj.Projection = external_L_default.a.Class.extend({
6821068208
* @param {L.Latlng} latlng - 经纬度坐标。
6821168209
* @returns {L.Point} 返回投影坐标点。
6821268210
*/
68213-
project: function (latlng) {
68211+
project: function(latlng) {
6821468212
var point = this._proj.forward([latlng.lng, latlng.lat]);
6821568213
return new external_L_default.a.Point(point[0], point[1]);
6821668214
},
@@ -68222,16 +68220,26 @@ external_L_default.a.Proj.Projection = external_L_default.a.Class.extend({
6822268220
* @param {number} unbounded - 坐标点高程值等。
6822368221
* @returns {L.LatLng} 返回经纬度坐标
6822468222
*/
68225-
unproject: function (point, unbounded) {
68223+
unproject: function(point, unbounded) {
6822668224
if (this.bounds) {
68227-
point.x = point.x < this.bounds.min.x ? this.bounds.min.x : (point.x > this.bounds.max.x ? this.bounds.max.x : point.x);
68228-
point.y = point.y < this.bounds.min.y ? this.bounds.min.y : (point.y > this.bounds.max.y ? this.bounds.max.y : point.y);
68225+
point.x =
68226+
point.x < this.bounds.min.x
68227+
? this.bounds.min.x
68228+
: point.x > this.bounds.max.x
68229+
? this.bounds.max.x
68230+
: point.x;
68231+
point.y =
68232+
point.y < this.bounds.min.y
68233+
? this.bounds.min.y
68234+
: point.y > this.bounds.max.y
68235+
? this.bounds.max.y
68236+
: point.y;
6822968237
}
6823068238
var point2 = this._proj.inverse([point.x, point.y]);
6823168239
return new external_L_default.a.LatLng(point2[1], point2[0], unbounded);
6823268240
},
6823368241

68234-
_projFromCodeDef: function (code, def) {
68242+
_projFromCodeDef: function(code, def) {
6823568243
if (def) {
6823668244
lib_default.a.defs(code, def);
6823768245
} else if (lib_default.a.defs[code] === undefined) {
@@ -68246,8 +68254,8 @@ external_L_default.a.Proj.Projection = external_L_default.a.Class.extend({
6824668254

6824768255
return lib_default()(code);
6824868256
},
68249-
getUnits: function () {
68250-
return this._proj.oProj.units || "degrees";
68257+
getUnits: function() {
68258+
return this._proj.oProj.units || 'degrees';
6825168259
}
6825268260
});
6825368261

@@ -68286,7 +68294,7 @@ var Proj4Leaflet_CRS = external_L_default.a.Class.extend({
6828668294
transformation: new external_L_default.a.Transformation(1, 0, -1, 0)
6828768295
},
6828868296

68289-
initialize: function (srsCode, options) {
68297+
initialize: function(srsCode, options) {
6829068298
var code, proj, def;
6829168299

6829268300
if (external_L_default.a.Proj._isProj4Obj(srsCode)) {
@@ -68305,7 +68313,7 @@ var Proj4Leaflet_CRS = external_L_default.a.Class.extend({
6830568313
external_L_default.a.Util.setOptions(this, options);
6830668314
this.code = code;
6830768315
this.transformation = this.options.transformation;
68308-
this.options.dpi=this.options.dpi||96;
68316+
this.options.dpi = this.options.dpi || 96;
6830968317
if (this.options.bounds) {
6831068318
this.options.bounds = external_L_default.a.bounds(this.options.bounds);
6831168319
}
@@ -68316,8 +68324,7 @@ var Proj4Leaflet_CRS = external_L_default.a.Class.extend({
6831668324
if (this.options.origin instanceof external_L_default.a.Point) {
6831768325
this.options.origin = [this.options.origin.x, this.options.origin.y];
6831868326
}
68319-
this.transformation =
68320-
new external_L_default.a.Transformation(1, -this.options.origin[0], -1, this.options.origin[1]);
68327+
this.transformation = new external_L_default.a.Transformation(1, -this.options.origin[0], -1, this.options.origin[1]);
6832168328
}
6832268329

6832368330
if (this.options.scales && this.options.scales.length > 0) {
@@ -68341,9 +68348,8 @@ var Proj4Leaflet_CRS = external_L_default.a.Class.extend({
6834168348
}
6834268349
this._rectify();
6834368350
this.infinite = !this.options.bounds;
68344-
6834568351
},
68346-
_rectify: function () {
68352+
_rectify: function() {
6834768353
if (this._scales) {
6834868354
if (!this.resolutions) {
6834968355
this.resolutions = [];
@@ -68352,7 +68358,11 @@ var Proj4Leaflet_CRS = external_L_default.a.Class.extend({
6835268358
if (!this.scales) {
6835368359
this.scales = [];
6835468360
for (let i = 0; i < this.resolutions.length; i++) {
68355-
var scaleD = this.resolutions[i] * this.options.dpi * (1 / 0.0254) * this._getMeterPerMapUnit(this.projection.getUnits());
68361+
var scaleD =
68362+
this.resolutions[i] *
68363+
this.options.dpi *
68364+
(1 / 0.0254) *
68365+
this._getMeterPerMapUnit(this.projection.getUnits());
6835668366
this.scales[i] = 1.0 / scaleD;
6835768367
}
6835868368
}
@@ -68364,7 +68374,7 @@ var Proj4Leaflet_CRS = external_L_default.a.Class.extend({
6836468374
* @param {number} zoom - 缩放级别。
6836568375
* @returns 比例尺值。
6836668376
*/
68367-
scale: function (zoom) {
68377+
scale: function(zoom) {
6836868378
var iZoom = Math.floor(zoom),
6836968379
baseScale,
6837068380
nextScale,
@@ -68377,7 +68387,7 @@ var Proj4Leaflet_CRS = external_L_default.a.Class.extend({
6837768387
baseScale = this._scales[iZoom];
6837868388
nextScale = this._scales[iZoom + 1];
6837968389
scaleDiff = nextScale - baseScale;
68380-
zDiff = (zoom - iZoom);
68390+
zDiff = zoom - iZoom;
6838168391
return baseScale + scaleDiff * zDiff;
6838268392
}
6838368393
},
@@ -68388,22 +68398,25 @@ var Proj4Leaflet_CRS = external_L_default.a.Class.extend({
6838868398
* @param {number} scale - 比例尺。
6838968399
* @returns {number} 缩放级别。
6839068400
*/
68391-
zoom: function (scale) {
68401+
zoom: function(scale) {
6839268402
// Find closest number in this._scales, down
6839368403
var downScale = this._closestElement(this._scales, scale),
6839468404
downZoom = this._scales.indexOf(downScale),
6839568405
nextScale,
6839668406
nextZoom,
6839768407
scaleDiff;
6839868408
// Check if scale is downScale => return array index
68409+
if (!downScale) {
68410+
return 0;
68411+
}
6839968412
if (scale === downScale) {
6840068413
return downZoom;
6840168414
}
6840268415
// Interpolate
6840368416
nextZoom = downZoom + 1;
6840468417
nextScale = this._scales[nextZoom];
6840568418
if (nextScale === undefined) {
68406-
return Infinity;
68419+
return downZoom;
6840768420
}
6840868421
scaleDiff = nextScale - downScale;
6840968422
return (scale - downScale) / scaleDiff + downZoom;
@@ -68414,9 +68427,9 @@ var Proj4Leaflet_CRS = external_L_default.a.Class.extend({
6841468427
R: external_L_default.a.CRS.Earth.R,
6841568428

6841668429
/* Get the closest lowest element in an array */
68417-
_closestElement: function (array, element) {
68430+
_closestElement: function(array, element) {
6841868431
var low;
68419-
for (var i = array.length; i--;) {
68432+
for (var i = array.length; i--; ) {
6842068433
if (array[i] <= element && (low === undefined || low < array[i])) {
6842168434
low = array[i];
6842268435
}
@@ -68432,9 +68445,8 @@ var Proj4Leaflet_CRS = external_L_default.a.Class.extend({
6843268445
resolutions[i] = 1.0 / _scales[i];
6843368446
}
6843468447
return resolutions;
68435-
6843668448
},
68437-
_toProj4Scales: function (scales, dpi) {
68449+
_toProj4Scales: function(scales, dpi) {
6843868450
var proj4Scales = [];
6843968451
if (!scales) {
6844068452
return proj4Scales;
@@ -68445,24 +68457,24 @@ var Proj4Leaflet_CRS = external_L_default.a.Class.extend({
6844568457
}
6844668458
return proj4Scales;
6844768459
},
68448-
_getMeterPerMapUnit: function (mapUnit) {
68460+
_getMeterPerMapUnit: function(mapUnit) {
6844968461
var earchRadiusInMeters = 6378137;
6845068462
var meterPerMapUnit = 1;
68451-
if (mapUnit === "meter") {
68463+
if (mapUnit === 'meter') {
6845268464
meterPerMapUnit = 1;
68453-
} else if (mapUnit === "degrees") {
68465+
} else if (mapUnit === 'degrees') {
6845468466
// 每度表示多少米。
68455-
meterPerMapUnit = Math.PI * 2 * earchRadiusInMeters / 360;
68456-
} else if (mapUnit === "kilometer") {
68457-
meterPerMapUnit = 1.0E-3;
68458-
} else if (mapUnit === "inch") {
68459-
meterPerMapUnit = 1 / 2.5399999918E-2;
68460-
} else if (mapUnit === "feet") {
68467+
meterPerMapUnit = (Math.PI * 2 * earchRadiusInMeters) / 360;
68468+
} else if (mapUnit === 'kilometer') {
68469+
meterPerMapUnit = 1.0e-3;
68470+
} else if (mapUnit === 'inch') {
68471+
meterPerMapUnit = 1 / 2.5399999918e-2;
68472+
} else if (mapUnit === 'feet') {
6846168473
meterPerMapUnit = 0.3048;
6846268474
}
6846368475
return meterPerMapUnit;
6846468476
},
68465-
_getDefaultProj4ScalesByBounds: function (bounds) {
68477+
_getDefaultProj4ScalesByBounds: function(bounds) {
6846668478
if (!bounds) {
6846768479
return [];
6846868480
}
@@ -68477,10 +68489,11 @@ var Proj4Leaflet_CRS = external_L_default.a.Class.extend({
6847768489
return scales;
6847868490
}
6847968491
});
68480-
var Proj4Leaflet_crs = function (srsCode, options) {
68481-
return new Proj4Leaflet_CRS(srsCode, options)
68492+
var Proj4Leaflet_crs = function(srsCode, options) {
68493+
return new Proj4Leaflet_CRS(srsCode, options);
6848268494
};
6848368495
external_L_default.a.Proj.CRS = Proj4Leaflet_crs;
68496+
6848468497
// CONCATENATED MODULE: ./src/leaflet/core/ExtendsCRS.js
6848568498
/* Copyright© 2000 - 2019 SuperMap Software Co.Ltd. All rights reserved.
6848668499
* This program are made available under the terms of the Apache License, Version 2.0

dist/leaflet/iclient9-leaflet-es6.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.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy