Hello Experts
I have attempted to use Gile Coles code to obtain the Latitude and longitude for a map position resulting from a mouse event. I am using visual studio 2005, latitude and longitude are returned as 0 . Visual studio has altered the formula names in Accros Function from:
Arccos = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)
To:
Arccos = Atan(-x / Sqrt(-x * x + 1)) + 2 * Atan(1)
I believe these are only name changes in system.math,. The full codes used is reproduced below can you see the problem.
Private Sub AxMappointControl1_BeforeDblClick(ByVal sender As System.Object, ByVal e As AxMapPoint._IMappointCtrlEvents_BeforeDblClickEven t) Handles AxMappointControl1.BeforeDblClick
Try
Dim objMap As MapPoint.Map
objMap = Me.AxMappointControl1.ActiveMap
Dim objDataSet As MapPoint.DataSet
Dim txt1, txt2, txt0 As String
Dim Ilat, Ilong As Double
For Each objDataSet In objMap.DataSets 'clear pushpins
If objDataSet.Name = "My Pushpins" Then
objDataSet.Delete()
End If
Next
Dim objResult As Object
Dim objResults As MapPoint.FindResults
'Display the name of each object where user double-clicks on map
objResults = objMap.ObjectsFromPoint(e.x, e.y)
Dim i As Int16 = 0
For Each objResult In objResults
If (i) = 0 Then txt0 = objResult.name
If (i) = 1 Then txt1 = objResult.name
If (i) = 2 Then txt2 = objResult.name
i = i + 1
Next
Dim objLoc As MapPoint.Location
objLoc = objMap.XYToLocation(e.x, e.y)
objMap.AddPushpin(objLoc, "Current location")
objMap.AddPushpin(objLoc, "Current location").Highlight = True
CalcPos(objMap, objLoc, Ilat, Ilong)
txt0 = txt0 & ", " & txt1 & " ," & txt2
MsgBox("Current Location" & vbCrLf & txt0 & vbCrLf & Ilat & " Latitude" & vbCrLf & Ilong & " Longitude")
Catch ex As Exception
MsgBox(Err.Description)
End Try
End Sub
I would value any help with this.
Regards,
Joe