Welcome to MapForums!

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

## getting the coordinates of puspins within MapPoint

This is a discussion on getting the coordinates of puspins within MapPoint within the MapPoint Desktop Discussion forums, part of the Map Forums category; I have a set of customer-defined pushpins and I want the coordinates of them. I have some code-snipplet (com-addin .dll ...

1. Member Yellow Belt
Join Date
Dec 2002
Posts
39

## getting the coordinates of puspins within MapPoint

I have a set of customer-defined pushpins and I want the coordinates of them. I have some code-snipplet (com-addin .dll with VB) for one pushpin. Everybody out there who did the stuff I explained before. Or has an idea where to start?

Thanks a lot

Peter

2. The simplest way would probably be to get the Pushpin Tool: http://www.mp2kmag.com/downloads/pushpin.tool/

Eric

3. Junior Member Yellow Belt
Join Date
Jan 2003
Posts
17
How about if you want to get the Lat/Long of pushpins programatically?

I have considered using the .LocationToX and .LocationToY methods and interpolating values by referencing a set of pushpins with known coordinates, but this would be approximate at best. MapPoint for .NET has API calls which allow access to the Lat/Long of a location.

Brian.

4. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137

## Lon/Lat from Location

Picked this up from the web somewhere:

Option Explicit

Const PI = 3.14159265358979
Dim locNorthPole As MapPoint.Location
Dim locSantaCruz As MapPoint.Location ' Center of western hemisphere
Dim dblHalfEarth As Double ' Half circumference of the earth (as a sphere)
Dim dblQuarterEarth As Double ' Quarter circumference of the earth (as a sphere)

' Compute latitude and longitude given a location object
' Author: Gilles Kohl
' (gilles@compuserve.com)
'
' This code is copyrighted freeware - use freely, but please leave this

Function Arccos(x As Double) As Double
If x = 1 Then
Arccos = 0
Exit Function
End If
Arccos = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)

End Function

Function CalcPos(objMap As MapPoint.Map, locX As MapPoint.Location, dblLat As Double, dblLon As Double) As Boolean

Dim l As Double
Dim d As Double

On Error GoTo CalcPosError

' Check if initialization already done
If locNorthPole Is Nothing Then
Set locNorthPole = objMap.GetLocation(90, 0)
Set locSantaCruz = objMap.GetLocation(0, -90)

' Compute distance between north and south poles == half earth circumference
dblHalfEarth = objMap.Distance(locNorthPole, objMap.GetLocation(-90, 0))

' Quarter of that is the max distance a point may be away from locSantaCruz and still be in western hemisphere
dblQuarterEarth = dblHalfEarth / 2
End If

' Compute latitude from distance to north pole
dblLat = 90 - 180 * objMap.Distance(locNorthPole, locX) / dblHalfEarth

' Compute great circle distance to locX from point on Greenwich meridian and computed Latitude
d = objMap.Distance(objMap.GetLocation(dblLat, 0), locX)

l = (dblLat / 180) * PI

' Compute Longitude from great circle distance
dblLon = 180 * Arccos((Cos((d * 2 * PI) / (2 * dblHalfEarth)) - Sin(l) * Sin(l)) / (Cos(l) * Cos(l))) / PI

' Correct longitude sign if located in western hemisphere
If objMap.Distance(locSantaCruz, locX) < dblQuarterEarth Then dblLon = -dblLon

CalcPos = True

CalcPosExit:
Exit Function

CalcPosError:
CalcPos = False
MsgBox Err.Description, , "CalcPos"
Resume CalcPosExit

End Function

Function InitialiseCalcPos() As Boolean
'1.1
On Error Resume Next

Set locNorthPole = Nothing
Set locSantaCruz = Nothing

End Function

5. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137

## Lat/long from location

Just remembered where I found it. It was here!!! (http://www.mp2kmag.com/articles.asp?ArticleID=13)