用VB绑定地图 [英] Bing maps with VB

查看:79
本文介绍了用VB绑定地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我编写了一段代码,该代码使程序可以从文本框中获取邮政编码,然后为用户在Bing中键入该邮政编码.当我使用www.bing.com时,这非常正常,但是如果我要使用 http://www.bing.com/maps/?mkt=zh-CN ,以便将邮政编码直接输入到Bing地图中,然后崩溃.我已经提供了我的代码的副本,该代码可与标准Bing搜索一起使用,但希望获得一些建议,以使程序可以直接在Bing地图中搜索而不会导致程序崩溃.

Hi I have written a piece of code which allows the program to take a postcode from a text box then type it into Bing for the user. This works perfectly fine when I use www.bing.com but if I was to use http://www.bing.com/maps/?mkt=en-gb so that the postcode is type directly into Bing maps then it crashes. I have included a copy of my code which works with the standard Bing search but would like some advice on allowing the program to search directly into Bing maps without the program crashing.

谢谢

公共类表格1

Dim Automate As Boolean


Private Sub BTNMAPP_Click(sender As Object, e As EventArgs) Handles BTNMAPP.Click
    Automate = True
    BingBrowserWindow.Navigate("https://www.bing.com")
End Sub


Private Sub BingBrowserWindow_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles BingBrowserWindow.DocumentCompleted
    If Automate = True Then Automate = False Else Exit Sub
    Dim txt As HtmlElement = BingBrowserWindow.Document.GetElementById("q")
    Dim btn As HtmlElement = BingBrowserWindow.Document.GetElementById("go")

    txt.SetAttribute("value", PostcodeTextBox.Text)
    btn.InvokeMember("click")

End Sub

推荐答案

您可以在此处找到有关如何为Bing Maps消费者网站创建自定义URL的文档:

You can find documentation on how to create a custom URL to the Bing Maps consumer site here: https://msdn.microsoft.com/en-us/library/dn217138.aspx

也就是说,您确实应该在应用程序内部使用Bing Maps WPF控件.它可以带来更好的用户体验,并使您与Bing Maps的使用条款保持一致.同样,您应该使用Bing搜索API,而不是在应用程序中加载Bing搜索页面.

That said, you really should be using the Bing Maps WPF control inside of your app. It makes for a much better user experience and would make your align with the terms of use of Bing Maps. Similarly you should be using the Bing search API's instead of loading the Bing search page in your app.

这篇关于用VB绑定地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆