问题
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.
Thank you
Public Class Form1
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
回答1:
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
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.
来源:https://stackoverflow.com/questions/29904788/bing-maps-with-vb