怎样用vb.net在网站中加入地图功能

ygrobin 2010-05-09 07:57:52
我刚用vb.net开发网站,现在需要加入一个地图(某个城市即可),只需要点击地图上某个区便可连接到别处,该怎样实现?不需要太复杂,只是需要显示,放大缩小,能够响应鼠标点击就行。搜了一下,网上的google 和 百度API都太繁琐了,mapx也不清楚。谢谢!最好能有源码。
...全文
277 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2010-05-09
  • 打赏
  • 举报
回复
WebBroswer控件,打开地图页面
皇城龙三 2010-05-09
  • 打赏
  • 举报
回复
VB.NET与googlemap url谷歌地图连接
    Dim address As String
Private Function GetAddress(ByVal digits As Integer, ByVal lon As Double, ByVal lat As Double)
Const Pi = 3.1415926535897
Dim x As Double
Dim y As Double
Dim quad As String
Dim lookup(4) As String
Dim i As Integer
Dim m As Integer
Dim n As Integer

digits = Val(Text3.Text)
lon = Val(Text1.Text)
lat = Val(Text2.Text)

x = (180# + lon) / 360#
y = -lat * Pi / 180#
y = 0.5 * Log((1 + Sin(y)) / (1 - Sin(y)))
y = y * (1# / (2 * Pi))
y = y + 0.5

quad = "t"

lookup(0) = "q"
lookup(1) = "r"
lookup(2) = "t"
lookup(3) = "s"

For i = 1 To digits
x = x - Int(x)
y = y - Int(y)

If x >= 0.5 Then
m = 1
Else
m = 0
End If
If y >= 0.5 Then
n = 2
Else
n = 0
End If

quad = quad + lookup(m + n)
x = x * 2
y = y * 2
Next i
GetAddress = quad

End Function
Function GetNextTileX(ByVal addr As String, ByVal forward As Boolean)
If addr = "" Then
addr = addr
End If
Dim parent As String
Dim last As String

parent = Left(addr, Len(addr) - 1)
last = Right(addr, 1)

If last = "q" Then
last = "r"
If Not forward Then
parent = GetNextTileX(parent, forward)
End If
ElseIf last = "t" Then
last = "s"
If Not forward Then
parent = GetNextTileX(parent, forward)
End If
ElseIf last = "r" Then
last = "q"
If forward Then
parent = GetNextTileX(parent, forward)
End If
ElseIf last = "s" Then
last = "t"
If forward Then
parent = GetNextTileX(parent, forward)
End If
End If

GetNextTileX = parent + last

End Function
Function GetNextTileY(ByVal addr As String, ByVal forward As Boolean)
If addr = "" Then
addr = addr
End If
Dim parent As String
Dim last As String

parent = Left(addr, Len(addr) - 1)
last = Right(addr, 1)

If last = "q" Then
last = "t"
If Not forward Then
parent = GetNextTileY(parent, forward)
End If
ElseIf last = "r" Then
last = "s"
If Not forward Then
parent = GetNextTileY(parent, forward)
End If
ElseIf last = "s" Then
last = "r"
If forward Then
parent = GetNextTileY(parent, forward)
End If
ElseIf last = "t" Then
last = "q"
If forward Then
parent = GetNextTileY(parent, forward)
End If
End If

GetNextTileY = parent + last

End Function
Function DoRebuild()
Dim addr As String
Dim cursor As String
Dim i As Integer
Dim j As Integer
Dim n As Integer
n = 0
addr = GetAddress(Val(Text3.Text), Val(Text1.Text), Val(Text2.Text))
cursor = Left(addr, Val(Text3.Text))
cursor = GetNextTileX(cursor, False)
cursor = GetNextTileY(cursor, False)
Label1.Width = 0
For i = 1 To 3
Dim c2 As String
c2 = cursor
cursor = GetNextTileX(cursor, True)
For j = 1 To 3
n = n + 1
address = "http://kh.google.com/kh?v=3&t=" + c2
c2 = GetNextTileY(c2, 1)
List1.AddItem address
Download address, "c:\map\" & CStr(j) & "-" & CStr(i) & ".jpg"
Label1.Width = (n / 900) * Picture1.Width
Label2.Caption = "正在下载:" + CStr(n / 9) + "%"
Next j
Next i

End Function

Private Sub Download(UrtFile As String, localfile As String)
Dim bData() As Byte '数据变量
Dim intfile As Integer '可用文件变量
Dim i As Integer
Dim ttt As String
Dim c As String
Dim h() As String

intfile = FreeFile() '将 intFile 设置为未使用的文件
' OpenURL 方法的结果首先传入 Byte 数组,
'然后将 Byte 数组保存到磁盘。
On Error Resume Next
Kill localfile
On Error GoTo 0

bData() = Inet1.OpenURL(UrtFile, icByteArray)
c = Inet1.GetHeader()
h = Split(c, vbCrLf)
If InStr(1, h(0), "HTTP/1.1 404", vbTextCompare) Then
MsgBox "在该分辨率下找不到卫星图片!"
ElseIf InStr(1, h(0), "HTTP/1.1 200 OK", vbTextCompare) Then
Open localfile For Binary Access Write As #intfile
Put #intfile, , bData()
Close #intfile
End If
Exit Sub
err1:
MsgBox "error!"
Resume
End Sub

Private Sub cmdCreate_Click()
DoRebuild

End Sub
yuanhuiqiao 2010-05-09
  • 打赏
  • 举报
回复
xysyzj 2010-05-09
  • 打赏
  • 举报
回复
调用Google api吧,几句代码就搞定,楼主可以查下Google api的资料

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧