Partilhar via


Location Class

Note

Bing Maps Web Control SDK retirement

Bing Maps Web Control SDK is deprecated and will be retired. Free (Basic) account customers can continue to use Bing Maps Web Control SDK until June 30th, 2025. Enterprise account customers can continue to use Bing Maps Web Control SDK until June 30th, 2028. To avoid service disruptions, all implementations using Bing Maps Web Control SDK will need to be updated to use Azure Maps Web SDK by the retirement date that applies to your Bing Maps for Enterprise account type. For detailed migration guidance, see Migrate from Bing Maps Web Control SDK and Migrate Bing Maps Enterprise applications to Azure Maps with GitHub Copilot.

Azure Maps is Microsoft's next-generation maps and geospatial services for developers. Azure Maps has many of the same features as Bing Maps for Enterprise, and more. To get started with Azure Maps, create a free Azure subscription and an Azure Maps account. For more information about azure Maps, see Azure Maps Documentation. For migration guidance, see Bing Maps Migration Overview.

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.

Constructor

Location(latitude: number, longitude: number)

Properties

Name Type Description
latitude number The latitude of the location.
longitude number The longitude of the location.

Static Methods

The Location class has the following static methods.

Method Return Value Description
areEqual(loc1: Location, loc2: Location) boolean Determines if the specified Location objects are equal.
normalizeLongitude(longitude: number) number Normalizes the specified longitude so that it is between -180 and 180.
parseLatLong(str: string) Location Parses a location string of the form "lat,long".

Methods

The Location class has the following methods.

Method Return Value Description
clone() Location Returns a copy of the Location object.
toString() string Converts the Location object to a string.