// Projection coordinate interface, which cannot be instantiated but must be used through inheritance
Function Gprojection ()
{
}
// Converts a from longitude and latitude to pixel. A is a glatlng, and B is a scaling level.
Gprojection. Prototype. fromlatlngtopixel = Function (A, B)
{
Throw Gmsg_implement;
};
// Converts a pixel to latitude and longitude, A is a gpoint, B is a scaling level, and C is true, the returned results are not forcibly limited to-180 ~ Between 180
Gprojection. Prototype. frompixeltolatlng = Function (A, B, C)
{
Throw Gmsg_implement;
};
// Returns whether the specified image sequence number is within the normal range. If the longitude is not within the range, it is converted to a range. If the latitude is no longer within the range, false is returned.
Gprojection. Prototype. tilecheckrange = Function (A, B, C)
{
Return True
};
// Returns the horizontal pixel width of a map under a scaling level.
Gprojection. Prototype. getwrapwidth = Function ()
{
Throw Gmsg_implement;
};
// This object inherits the gprojection interface, which represents the mokto projection coordinate. parameter A represents the number of scaling levels.
// When the scale level is 0, the image with a global width of 128 can be displayed.
Function Gmercatorprojection ()
{
VaR B = This ;
B. pixelsperlondegree = [];
B. pixelsperlonradian = [];
B. bitmaporigo = [];
B. numtiles = [];
VaR C = 256 ;
For ( VaR D = 0 ; D < A; d ++ )
{
VaR E = C / 2 ;
B. pixelsperlondegree. Push (C / 360 );
B. pixelsperlonradian. Push (C / ( 2 * Gmath_pi ));
B. bitmaporigo. Push ( New Gpoint (E, E ));
B. numtiles. Push (C );
C * = 2
}
}
Gmercatorprojection. Prototype = New Gprojection (); // Specify the inherited gprojection Interface
// Implementation of fromlatlngtopixel
Gmercatorprojection. Prototype. fromlatlngtopixel = Function (A, B)
{
VaR C = This ;
VaR D = C. bitmaporigo [B];
VaR E = Getmathround (D. x + A. LNG () * C. pixelsperlondegree [B]);
VaR F = Getnumberinrange (math. Sin (getradianbydegree (A. LAT ())), - 0.9999 , 0.9999 );
VaR G = Getmathround (D. Y + 0.5 * Math. Log (( 1 + F) / ( 1 - F )) *- C. pixelsperlonradian [B]);
Return New Gpoint (e, g)
};
// Implementation of frompixeltolatlng
Gmercatorprojection. Prototype. frompixeltolatlng = Function (A, B, C)
{
VaR D = This ;
VaR E = D. bitmaporigo [B];
VaR F = (A. x - E. X) / D. pixelsperlondegree [B];
VaR G = (A. Y - E. Y) /- D. pixelsperlonradian [B];
VaR H = Getdegreebyradian ( 2 * Math. atan (math. exp (g )) - Gmath_pi / 2 );
Return New Glatlng (H, F, c)
};
// Implement the tilecheckrange Method
Gmercatorprojection. Prototype. tilecheckrange = Function (A, B, C)
{
VaR D = This . Numtiles [B];
If (A. Y < 0 | A. Y * C > = D)
{
Return False
}
If (A. x < 0 | A. x * C > = D)
{
VaR E = Getmathfloor (d / C );
A. x = A. x % E;
If (A. x < 0 )
{
A. x + = E
}
}
Return True
};
// Implement the getwrapwidth Method
Gmercatorprojection. Prototype. getwrapwidth = Function ()
{
Return This . Numtiles [A]
};
Google separated the coordinate system and map type this time, which seems to be more flexible. You can develop your own coordinate system by implementing gprojection. However, I think that in the Image Display Mode of Google, it seems that the image display mode is not big but flexible. I haven't seen it yet. I will continue to learn it below.