Google Maps API 2.0 resolution (5-gpoint gsize gbounds)

Source: Internet
Author: User

 

// Gpoint class, which can represent a geographic location point in 1.0 at the same time. Now, this function has been replaced by glatlng, and 2.0 represents only the pixel location on the screen.
Function Gpoint (A, B)
{
This . X = A;
This . Y = B
}
Gpoint. Origin = New Gpoint ( 0 , 0 );
// Convert to string
Gpoint. Prototype. tostring = Function ()
{
Return " ( " + This . X + " , " + This . Y + " ) "
};
// Check whether two points are equal
Gpoint. Prototype. equals = Function ()
{
If ( ! A) Return   False ;
Return A. x = This . X && A. Y = This . Y
};
// Gsize class, indicating the size of the screen position
Function Gsize (A, B)
{
This . Width = A;
This . Height = B
}
Gsize. Zero = New Gsize ( 0 , 0 );
// Convert to string
Gsize. Prototype. tostring = Function ()
{
Return " ( " + This . Width + " , " + This . Height + " ) "
};
// Checks whether two objects of the same size are equal.
Gsize. Prototype. equals = Function ()
{
If ( ! A) Return   False ;
Return A. Width = This . Width && A. Height = This . Height
};
// The gbounds object represents the rectangular range of the screen. The parameter is the gpoint list, and a rectangular range containing these points is obtained based on the list.
Function Gbounds ()
{
This . Minx = ( This . Miny = Gmath_maxvalue );
This . Maxx = ( This . Maxy =- Gmath_maxvalue );
VaR B = Arguments;
If ( && A. length)
{
For ( VaR C = 0 ; C < A. length; c ++ )
{
This . Extend (A [c])
}
}
Else   If (B. Length > = 4 )
{
This . Minx = B [ 0 ];
This . Miny = B [ 1 ];
This . Maxx = B [ 2 ];
This . Maxy = B [ 3 ]
}
}
// Minimum Coordinate Position on the rectangle
Gbounds. Prototype. Min = Function ()
{
Return   New Gpoint ( This . Minx, This . Miny)
};
// Maximum Coordinate Position on the rectangle
Gbounds. Prototype. Max = Function ()
{
Return   New Gpoint ( This . Maxx, This . Maxy)
};
// Convert to string
Gbounds. Prototype. tostring = Function ()
{
Return " ( " + This . Min () + " , " + This . Max () + " ) "
};
// Whether the specified rectangle is included
Gbounds. Prototype. containsbounds = Function ()
{
VaR B = This ;
Return B. minx < A. minx && B. Maxx > A. Maxx && B. miny < A. miny && B. Maxy > A. Maxy
};
// Extended to include the specified Vertex
Gbounds. Prototype. Extend = Function ()
{
VaR B = This ;
B. minx = Getmathmin (B. Minx, A. X );
B. Maxx = Getmathmax (B. Maxx, A. X );
B. miny = Getmathmin (B. miny, A. Y );
B. Maxy = Getmathmax (B. Maxy, A. Y)
};
// Obtains the cross area of the two rectangle ranges.
Gbounds. Intersection = Function (A, B)
{
Return   New Gbounds ([ New Gpoint (getmathmax (A. Minx, B. Minx), getmathmax (A. miny, B. miny )), New Gpoint (getmathmin (A. Maxx, B. Maxx), getmathmin (A. Maxy, B. Maxy)])
};

These three classes are objects that provide screen coordinate descriptions. These are also available in the previous APIs, but the previousCodeIt is very simple, does not contain any method, and the applicable scope includes the coordinates of geographical points, but it is not suitable for such use now.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.