Using the MapPoint API with OSGB

You can use OSGB grid references programmatically, if you have data in an external file.

I do not know of any interface that will directly accept a string with a OSGB grid reference in place of a latitude longitude position.

The GetLocation method only reads in Latitude, Longitude and Altitude.

Here's how to find an example using an external file:

From Map Help

Hit the contents tab

At the bottom hit "Programming Information"

At the bottom now hit "Microsoft MapPoint Visual Basic reference"

Hit "Methods"

Hit "ImportData Method" or "LinkData method"

Yes, you can import OSGB - but with position error. The lack of Helmert Transform I keep talking about.

Using the GetLocation Method

This interface uses latitude and longitude:

Private Sub Command1_Click()
    Dim objApp As New MapPoint.Application
    Dim objLoc As MapPoint.Location
    objApp.Visible = True
    objApp.UserControl = True
    Set objLoc = objApp.ActiveMap.GetLocation(52, -0.0)
    'Add a Pushpin to the map at this location
    objApp.ActiveMap.AddPushpin objLoc, "Nick's Added Pushpin"
End Sub

Use the LED_OSGB_POS OCX and the OSGB coordinate system is available:

Private Sub Command1_Click()
    Dim objApp As New MapPoint.Application
    Dim objLoc As MapPoint.Location    
    objApp.Visible = True
    objApp.UserControl = True
    
    Set o = CreateObject("LED_OSGB_POS.Application")
    o.convert "SP 84000 35550"

    Set objLoc = objApp.ActiveMap.GetLocation(o.Latitude, o.Longitude)
    'Add a Pushpin to the map at this location
    objApp.ActiveMap.AddPushpin objLoc, "Nick's Added Pushpin"
End Sub

This sample code contains data that is specific for a roundabout in Milton Keynes; it is for illustration purposes only.

Back to the mapping page