Share via


GetLocation method

Returns a Location object for a given latitude and longitude coordinate. Does not change the map view.

Applies to

Objects: Map

Syntax

object.GetLocation(Latitude, Longitude, [Altitude])

Parameters

Part

Description

object

Required. An expression that returns a Map object.

Latitude

Required Double. A numerical coordinate that measures how far north (+) or south (-) of the Equator a place is located, measured in decimal degrees. Range is 0° to (+/-)90°. For example, "34.33896".

Longitude

Required Double. A numerical coordinate that measures how far east (+) or west (-) of the Prime Meridian a place is located, measured in decimal degrees. Range is 0° to (+/-)180°. For example, "-79.43433".

Altitude

Optional Double. The height above the earth's surface from which the map is viewed, in GeoUnits. If not specified, the resulting Location object will use the current altitude for the GoTo method.

Remarks

Example

[Microsoft Visual Basic 6.0]
  Sub ZoomToLocation()
    Dim objApp As New MapPoint.Application
    Dim objLoc As MapPoint.Location
    'Get the location of Los Angeles, CA, using latitude and longitude
    Set objLoc = objApp.ActiveMap.GetLocation(34.05321 , -118.24502, 100)
    objLoc.GoTo
  End Sub

[C#]
void zoomToLocation()
{
  //zoomToLocation using GetLocation
  MapPoint.ApplicationClass objApp = new MapPoint.ApplicationClass();
  MapPoint.Location objLoc = null;

  //Set up the application
  objApp.Visible = true;
  objApp.UserControl = true;

  //Get the location of Los Angeles, CA, using latitude and longitude
  objLoc = objApp.ActiveMap.GetLocation(34.05321, -118.24502, 100);
  objLoc.GoTo();
}

Note   This sample code is specifically for use in MapPoint North America; it is for illustration purposes only.