|
阅读:1158回复:1
请教斑竹!
<P>上次看了您的"如何获取图层上某一点的经纬度坐标"程序段:</P>
<P>mousemove的事件片段,下面还有个转换的函数, Dim curX As Double, curY As Double Dim Loc As New MapObjects2.point Set Loc = Map1.ToMapPoint(x, Y) Dim Deg As Integer, Min As Integer, Sec As Integer Dim Deg1 As Integer, Min1 As Integer, Sec1 As Integer Dim s As String, s1 As String curX = Loc.x curY = Loc.Y Dim cx As String, cy As String '度转为度分秒 cx = OriDegToDms(curX) cy = OriDegToDms(curY) Deg = Int(cx): Min = Int(100 * (cx - Deg)): Sec = Int(100 * (100 * (cx - Deg) - Min)) Deg1 = Int(cy): Min1 = Int(100 * (cy - Deg1)): Sec1 = Int(100 * (100 * (cy - Deg1) - Min1)) s = CStr(Deg) ; "°" ; CStr(Min) ; "′" ; CStr(Sec) ; "″" s1 = CStr(Deg1) ; "°" ; CStr(Min1) ; "′" ; CStr(Sec1) ; "″" frmMain.MO_StatusBar.Panels(2).Text = "经度:" ; s ; " 纬度:" ; s1 Public Function OriDegToDms(Deg As Double) As Double Dim TempDeg#, Zd#, AllF, Zf, strZf, p TempDeg# = Deg If InStr(str(Deg), ".") = 0 Then OriDegToDms = str(Deg) + ".0000" Exit Function End If Zd# = Int(TempDeg#) AllF = (TempDeg# - Zd#) * 60 Zf = Int(AllF) If Zf < 10 Then strZf = "0" + Trim$(str(Zf)) Else strZf = Trim$(str(Zf)) If Val(strZf) = 60 Then Zd# = Zd# + 1 End If Dim Allm, Strm Allm = (AllF - Zf) * 60 If Allm < 10 Then Strm = "0" + Trim$(str(Int(Allm))) Else If Allm >= 60 Then strZf = str(Val(strZf) + 1) Strm = str(Allm - 60) If Val(strZf) = 60 Then Zd# = Zd# + 1 strZf = "00" End If Else Strm = Trim$(str(Allm)) End If p = InStr(Strm, ".") If p <> 0 Then Strm = Left(Strm, p - 1) + Mid(Strm, p + 1) End If End If OriDegToDms = CDbl(str(Zd#) + "." + strZf + Strm) End Function</P> <P>在我机子上运行后出现溢出错误,将Deg,Deg1改成long后好了,但出现了有些地图经纬度很大(最前面有六位)的情况,是什么原因呢,是不是地图的问题,我是个新手,请斑竹指教</P> |
|
|
|
1楼#
发布于:2004-07-25 02:32
可能是你地图单位不是经纬度?
|
|
|