Location Class

Bing
 

This class stores the coordinate information needed to mark locations on a map. The Location class consists of two properties: latitude and longitude.

The latitude property is used to represent how far north or south a location is. This value is an angle measured around the center of the earth from the equator towards the poles. A positive value is in the northern hemisphere and a negative value is in the southern hemisphere. This value has a range of -90 to 90 degrees however due to the mathematics involved in representing the spherical globe as a flat 2D map, some calculations approach infinity as you approach polar latitudes. To avoid this, Bing Maps and many other mapping platforms that use the Mercator projection system clip the latitude coordinates to approximately -85 and 85 degrees.

The longitude property stores the angle of horizontal offset from the prime meridian (0 degrees). This property has a value between -180 and 180 degrees.

Location(latitude: number, longitude: number)

NameTypeDescription
latitudenumberThe latitude of the location.
longitudenumberThe longitude of the location.

The Location class has the following static methods.

MethodReturn ValueDescription
areEqual(loc1: Location, loc2: Location)booleanDetermines if the specified Location objects are equal.
normalizeLongitude(longitude: number)numberNormalizes the specified longitude so that it is between -180 and 180.
parseLatLong(str: string)LocationParses a location string of the form "lat,long".

The Location class has the following methods.

MethodReturn ValueDescription
clone()LocationReturns a copy of the Location object.
toString()stringConverts the Location object to a string.
Show: