2 L
.Projection
.Mercator
= {
3 MAX_LATITUDE
: 85.0840591556,
8 project: function(/*LatLng*/ latlng
) /*-> Point*/ {
9 var d
= L
.LatLng
.DEG_TO_RAD
,
10 max
= this.MAX_LATITUDE
,
11 lat
= Math
.max(Math
.min(max
, latlng
.lat
), -max
),
13 x
= latlng
.lng
* d
* r
,
15 tmp
= this.R_MINOR
/ r
,
16 eccent
= Math
.sqrt(1.0 - tmp
* tmp
),
17 con
= eccent
* Math
.sin(y
);
19 con
= Math
.pow((1 - con
)/(1 + con
), eccent
* 0.5);
21 var ts
= Math
.tan(0.5 * ((Math
.PI
* 0.5) - y
)) / con
;
22 y
= -r
* Math
.log(ts
);
24 return new L
.Point(x
, y
);
27 unproject: function(/*Point*/ point
, /*Boolean*/ unbounded
) /*-> LatLng*/ {
28 var d
= L
.LatLng
.RAD_TO_DEG
,
30 lng
= point
.x
* d
/ r
,
31 tmp
= this.R_MINOR
/ r
,
32 eccent
= Math
.sqrt(1 - (tmp
* tmp
)),
33 ts
= Math
.exp(- point
.y
/ r
),
34 phi
= Math
.PI
/2 - 2 * Math
.atan(ts
),
41 while ((Math
.abs(dphi
) > tol
) && (--i
> 0)) {
42 con
= eccent
* Math
.sin(phi
);
43 dphi
= Math
.PI
/2 - 2 * Math.atan(ts * Math.pow((1.0 - con)/(1.0 + con
), 0.5 * eccent
)) - phi
;
47 return new L
.LatLng(phi
* d
, lng
, unbounded
);