A Koul
A Koul

Reputation: 33

google map in vb.net

I want to display google map in a vb.net application,except the left side panel of the google map. For this i made a function called map() which queries the google map api with the latitude and longitude that i have.Following is the code of map() function, this code will be put in a richtext box and a browser should run the code in that richtext box.The problem is that the html code gets written in the richtext box but still the web browser is not showing the map,and the program does not show any error, but just does not work as expected. I don't know if my approach to solving this issue is right.Is there any other way. Any help will be appreciated. Thanks.

Public Sub map()
    ' Dim addr As String
    Dim html As String
    html = "<!DOCTYPE html>" _
    & "<html>" _
    & "<head>" _
    & "<title>Simple Map</title>" _
    & "<meta name='viewport' content='initial-scale=1.0, user-scalable=no'>" _
    & "<meta charset='utf-8'>" _
    & "<style>" _
    & "html, body, #map-canvas {" _
    & "height: 100%;" _
    & "margin: 0px;" _
    & "padding: 0px" _
    & "}" _
    & "</style>" _
    & "<script type='text/javascript' src='https://maps.googleapis.com/maps/api/js?      v=3.exp&sensor=false'></script>" _
    & "<script>" _
    & "var map;" _
    & "function initialize() {" _
    & "var mapOptions = {" _
    & "zoom: 8," _
    & "center: new google.maps.LatLng(" & TextBox2.Text & "," & TextBox3.Text & ")" _
    & "};" _
    & "map = new google.maps.Map(document.getElementById('map-canvas')," _
    & "mapOptions);" _
    & "}" _
    & "google.maps.event.addDomListener(window, 'load', initialize);" _
    & "</script>" _
    & "</head>" _
    & "<body>" _
    & "<div id='map-canvas'></div>" _
    & "</body>" _
    & "</html>" _

    RichTextBox1.Text = html
    WebBrowser1.Navigate(RichTextBox1.Text)

    End Sub

Upvotes: 0

Views: 4040

Answers (1)

bek
bek

Reputation: 21

Instead of "Navigate", you should use "DocumentText".

WebBrowser1.DocumentText=RichTextBox1.Text

Upvotes: 1

Related Questions